> ## Documentation Index
> Fetch the complete documentation index at: https://make.edicus.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 템플릿 미리보기 변환

> InDesign 템플릿을 edicus-doc으로 변환하고 미리보기용 SVG를 받는다. 등록하지 않고 결과만 확인할 때 쓴다.

<Note>결과로 오는 SVG의 내부 이미지는 로컬 절대경로 xlink로 되어 있다.</Note>

`unresolved_font_group_ids`에 값이 있으면, 해당 상품 코드에 적용된 font class와 InDesign JSON의 textframe에 표시된 div·lang 정보를 조합한 font group id(`fontclass-div-lang` 패턴)가 Edicus Manager에 만들어져 있지 않은 경우다.



## OpenAPI

````yaml /api-reference/openapi.json post /resapi/preview
openapi: 3.1.0
info:
  title: Edicus Server API
  version: 1.1.5
  description: >-
    Edicus 편집기 연동에 필요한 서버 API입니다. 토큰 발급, 프로젝트 조회, 주문 처리, 폰트와 상품 정보, 템플릿 등록을
    다룹니다.


    ## 반드시 서버에서만 호출합니다


    모든 엔드포인트는 `edicus-api-key` 헤더를 요구합니다. 이 키는 고객사 서버에만 두고 브라우저 코드나 공개 저장소에 넣지
    않습니다. 브라우저에는 이 API로 발급받은 토큰만 내려보냅니다.


    ## 오류 응답


    `api.edicus.io`는 실패를 4xx와 5xx 상태 코드로 알리고, body는 언제나 `{"error": {"code",
    "message", "details", "request_id"}}` 모양입니다. `error.code`로 분기합니다. 같은
    `request_id`가 응답 헤더 `x-request-id`에도 실립니다.


    `resource-dot-edicusbase.appspot.com`은 방식이 다릅니다. 파라미터 누락은 `400`, 인증 실패는
    `401`, 그 밖의 모든 실패는 `500`이고, body에 `error` 객체가 없습니다.


    ## 응답 형식


    응답의 `content-type`은 `application/json`입니다.
  contact:
    name: 모션원
    url: https://edicus.io
servers:
  - url: https://api.edicus.io
    description: Server API 호스트
security:
  - edicusApiKey: []
tags:
  - name: Auth
    description: 토큰 발급
  - name: Projects
    description: 프로젝트 조회, 삭제, 복제
  - name: Orders
    description: 잠정 주문, 확정 주문, 취소
  - name: Fonts
    description: 폰트 그룹과 폰트 목록
  - name: Products
    description: 상품과 상품 카테고리 정보
  - name: Templates
    description: 리소스 토큰과 템플릿 패키지 등록
  - name: Resources
    description: 리소스 검색과 사용자 이미지
paths:
  /resapi/preview:
    post:
      tags:
        - Templates
      summary: 템플릿 미리보기 변환
      description: >-
        InDesign 템플릿을 edicus-doc으로 변환하고 미리보기용 SVG를 받는다. 등록하지 않고 결과만 확인할 때 쓴다.


        <Note>결과로 오는 SVG의 내부 이미지는 로컬 절대경로 xlink로 되어 있다.</Note>


        `unresolved_font_group_ids`에 값이 있으면, 해당 상품 코드에 적용된 font class와 InDesign
        JSON의 textframe에 표시된 div·lang 정보를 조합한 font group id(`fontclass-div-lang`
        패턴)가 Edicus Manager에 만들어져 있지 않은 경우다.
      operationId: previewTemplate
      parameters: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - meta
                - doc
                - dir
              properties:
                meta:
                  type: string
                  format: binary
                  description: metadata.json
                doc:
                  type: string
                  format: binary
                  description: template.json
                dir:
                  type: string
                  description: template.json이 있는 로컬 절대 폴더 경로
                dpi:
                  type: string
                  default: '300'
                  description: SVG 생성에 쓸 dpi
                bound_mode:
                  type: string
                  default: show
                  enum:
                    - show
                    - cut
                    - none
                  description: >-
                    RenderBound 레이어가 있을 때의 처리. `show`: 전체 영역 미리보기와 RenderBound
                    표시, `cut`: RenderBound만 미리보기, `none`: 전체 영역 미리보기,
                    RenderBound 표시 없음
      responses:
        '200':
          description: 성공.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreviewTemplateResponse'
        '400':
          description: |-
            필수 파라미터가 없습니다. **body가 객체가 아니라 JSON 문자열 하나입니다.** 예: `"no template"`

            이 엔드포인트가 내는 값: `no template`, `no local root dir`, `no meta`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceBadRequest'
              example: no template
        '401':
          description: >-
            인증 실패입니다. `api.edicus.io`와 달리 `error` 객체로 감싸지 않고 `{"code": ...}`를
            그대로 내려줍니다. code는 `invalid-edicus-api-key`, `no-edicus-id-token`,
            `token-expired`, `invalid-role` 중 하나입니다.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceAuthError'
              example:
                code: invalid-edicus-api-key
        '500':
          description: >-
            처리 중 오류입니다. 리소스 API는 인증 실패와 파라미터 누락을 뺀 **모든 실패를 500으로 내려줍니다.** body는
            던져진 오류 객체를 그대로 직렬화한 것이라, Error 인스턴스인 경우 빈 객체 `{}`가 됩니다.
          content:
            application/json:
              schema:
                type: object
              example: {}
      servers:
        - url: https://resource-dot-edicusbase.appspot.com
          description: 리소스 API 호스트
components:
  schemas:
    PreviewTemplateResponse:
      type: object
      properties:
        pageInfos:
          type: array
          items:
            type: object
            properties:
              svg:
                type: string
              layers:
                type: array
                items:
                  type: object
                  properties:
                    type:
                      type: string
                    svg:
                      type: string
        unregistered_fonts_found:
          type: array
          items:
            type: string
          description: '`fontFamily/fontStyle` 형태의 배열'
        unresolved_font_group_ids:
          type: array
          items:
            type: string
          description: '예: `default-host-ja`'
    ResourceBadRequest:
      type: string
      description: 리소스 API의 파라미터 누락 응답입니다. 객체가 아니라 JSON 문자열 하나로 옵니다.
      examples:
        - no option
    ResourceAuthError:
      type: object
      description: 리소스 API의 인증 실패 응답입니다. Server API의 `ErrorBody`와 모양이 다릅니다.
      properties:
        code:
          type: string
  securitySchemes:
    edicusApiKey:
      type: apiKey
      in: header
      name: edicus-api-key
      description: 모션원에서 발급받는 API 키입니다. 외부에 유출되지 않도록 각별히 주의합니다.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.