> ## 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.

# 템플릿 패키지 업로드

> 템플릿과 템플릿에 쓰인 모든 리소스 파일을 한 번에 등록한다. multipart/form-data로 보낸다.

| 파일 | 필드 | 설명 |
|---|---|---|
| `token.jwt` | `token` | 리소스 토큰 |
| `template.json` | `doc` | InDesign에서 내보낸 JSON |
| `metadata.json` | `meta` | Edicus doc 변환 파라미터 |
| `template-dp.png` | `dp` | 템플릿 썸네일. 파일 이름이 `template-dp`로 시작하면 되고 PNG나 JPG를 쓴다. 가로나 세로가 300px를 넘으면 300px 안으로 줄여 저장한다 |
| `layout-dp-n.png` | `dp` | 레이아웃 썸네일. `generate_layout: true`일 때만 필요하고 `template.json`의 페이지 수만큼 보낸다 |
| 리소스 파일 | `res` | SVG, PNG, JPG. 파일명이 `template.json`의 page-item-id여야 한다(예: `234.png`) |

<Warning>전체 업로드 용량이 32MB를 넘으면 `entry too large` 오류가 난다. 그런 경우 대용량 업로드 URL을 발급받아 zip으로 올린다.</Warning>

응답의 `unregistered_fonts_found`와 `unresolved_font_group_ids`가 둘 다 빈 배열이어야 정상이다. 하나라도 값이 있으면 폰트에 문제가 있는 상태다.



## OpenAPI

````yaml /api-reference/openapi.json post /resapi/package
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/package:
    post:
      tags:
        - Templates
      summary: 템플릿 패키지 업로드
      description: >-
        템플릿과 템플릿에 쓰인 모든 리소스 파일을 한 번에 등록한다. multipart/form-data로 보낸다.


        | 파일 | 필드 | 설명 |

        |---|---|---|

        | `token.jwt` | `token` | 리소스 토큰 |

        | `template.json` | `doc` | InDesign에서 내보낸 JSON |

        | `metadata.json` | `meta` | Edicus doc 변환 파라미터 |

        | `template-dp.png` | `dp` | 템플릿 썸네일. 파일 이름이 `template-dp`로 시작하면 되고 PNG나
        JPG를 쓴다. 가로나 세로가 300px를 넘으면 300px 안으로 줄여 저장한다 |

        | `layout-dp-n.png` | `dp` | 레이아웃 썸네일. `generate_layout: true`일 때만 필요하고
        `template.json`의 페이지 수만큼 보낸다 |

        | 리소스 파일 | `res` | SVG, PNG, JPG. 파일명이 `template.json`의 page-item-id여야
        한다(예: `234.png`) |


        <Warning>전체 업로드 용량이 32MB를 넘으면 `entry too large` 오류가 난다. 그런 경우 대용량 업로드
        URL을 발급받아 zip으로 올린다.</Warning>


        응답의 `unregistered_fonts_found`와 `unresolved_font_group_ids`가 둘 다 빈 배열이어야
        정상이다. 하나라도 값이 있으면 폰트에 문제가 있는 상태다.
      operationId: uploadTemplatePackage
      parameters:
        - name: download-json
          in: header
          required: false
          schema:
            type: boolean
            default: false
          description: >-
            `true`면 응답에 변환이 끝난 `doc`(edicus-doc)이 포함된다. 파일로 저장해 디자이너 모드 편집기의 템플릿
            불러오기로 테스트할 수 있다.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - token
                - doc
                - meta
                - dp
              properties:
                token:
                  type: string
                  format: binary
                  description: token.jwt
                doc:
                  type: string
                  format: binary
                  description: template.json
                meta:
                  type: string
                  format: binary
                  description: metadata.json
                dp:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: template-dp.png와 layout-dp-n.png
                res:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: 이미지 리소스 파일들
      responses:
        '200':
          description: 성공.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplatePackageResponse'
        '400':
          description: >-
            필수 파라미터가 없습니다. **body가 객체가 아니라 JSON 문자열 하나입니다.** 예: `"no token"`


            이 엔드포인트가 내는 값: `no token`, `no template`, `no meta`, `no dp files`,
            `invalid token`, `no res files`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceBadRequest'
              example: no token
        '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:
    TemplatePackageResponse:
      type: object
      properties:
        template_uri:
          type: string
          description: 등록된 템플릿의 uri. 편집기 띄우기의 입력으로 쓴다
        template_dp_url:
          type: string
          format: uri
        layout_uris:
          type: array
          items:
            type: string
        res_uris:
          type: array
          items:
            type: string
        doc:
          type: string
          description: '`download-json: true`일 때만. 변환이 끝난 edicus-doc'
        unregistered_fonts_found:
          type: array
          items:
            $ref: '#/components/schemas/UnregisteredFont'
          description: 등록되지 않은 폰트를 사용한 경우. 빈 배열이어야 정상이다
        unresolved_font_group_ids:
          type: array
          items:
            type: string
          description: 해석되지 않은 font group id. 빈 배열이어야 정상이다
      example:
        template_uri: gcs://template/partners/motion1/res/template/284.json
        layout_uris: []
        res_uris: []
    ResourceBadRequest:
      type: string
      description: 리소스 API의 파라미터 누락 응답입니다. 객체가 아니라 JSON 문자열 하나로 옵니다.
      examples:
        - no option
    ResourceAuthError:
      type: object
      description: 리소스 API의 인증 실패 응답입니다. Server API의 `ErrorBody`와 모양이 다릅니다.
      properties:
        code:
          type: string
    UnregisteredFont:
      type: object
      properties:
        familyName:
          type: string
        typeStyle:
          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.