> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 캐릭터 에셋 업로드

> 이미지, 동영상 또는 오디오 에셋을 활성 CometAPI 에셋 그룹에 업로드하여 이후 Seedance 요청에 사용합니다.

활성 에셋 그룹에 하나의 소스를 업로드합니다. `Authorization` 헤더에는 `Bearer` 접두사 없이 액세스 토큰을 그대로 전달합니다. 실존 인물 그룹에는 이미지 에셋만 업로드할 수 있습니다.

### 파일 업로드

로컬 소스에는 `file` 필드를 사용하세요.

```bash theme={null}
curl \
  https://api.cometapi.com/api/asset/assets \
  -H "Authorization: $COMETAPI_ACCESS_TOKEN" \
  -F "group_id=<GROUP_ID>" \
  -F "asset_type=image" \
  -F "file=@/path/to/character.png"
```

### 이미지 URL 업로드

공개 URL에서 사용할 수 있는 소스에는 JSON 형식을 사용하세요.

```bash theme={null}
curl \
  https://api.cometapi.com/api/asset/assets \
  -H "Authorization: $COMETAPI_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "group_id": "<GROUP_ID>",
    "asset_type": "image",
    "url": "https://your-image-host/character.png"
  }'
```

요청에는 `file`, `url`, `data` 중 정확히 하나의 소스만 포함해야 합니다. 선택 사항인 `name` 필드는 최대 64자까지 허용합니다. 응답의 `data.id`를 저장하세요. 새 에셋은 일반적으로 `data.status=processing`을 반환하므로 [캐릭터 에셋 조회](https://apidoc.cometapi.com/ko/api/video/seedance/get-character-asset.md)를 사용하여 상태가 `active`가 될 때까지 확인하세요.

그룹이 활성 상태가 아니면 API는 그룹 상태를 설명하는 메시지와 함께 `success: false`를 반환합니다. HTTP 응답이 `200`이어도 `success`와 `message`를 확인하여 비즈니스 오류를 처리하세요.


## OpenAPI

````yaml api/openapi/video/seedance/post-upload-character-asset.openapi.json POST /api/asset/assets
openapi: 3.1.0
info:
  title: Upload character asset API
  version: 1.0.0
  description: Upload a media asset to an active CometAPI character asset group.
servers:
  - url: https://api.cometapi.com
security:
  - accessTokenAuth: []
paths:
  /api/asset/assets:
    post:
      summary: Upload a character asset
      description: >-
        Upload one image, video, or audio source to an active group. A
        real-person group accepts image assets only. Provide exactly one source
        field.
      operationId: seedance_upload_character_asset
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/UploadAssetMultipart'
            examples:
              file:
                summary: Upload an image file
                value:
                  group_id: ag-example
                  asset_type: image
                  file: <binary image file>
          application/json:
            schema:
              $ref: '#/components/schemas/UploadAssetJSON'
            examples:
              url:
                summary: Upload an image URL
                value:
                  group_id: ag-example
                  asset_type: image
                  url: https://your-image-host/character.png
      responses:
        '200':
          description: Asset accepted for processing.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - message
                  - data
                properties:
                  success:
                    type: boolean
                    description: Whether the request succeeded.
                  message:
                    type: string
                    description: Status or error message.
                  data:
                    $ref: '#/components/schemas/AssetView'
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    message: ''
                    data: {}
        '400':
          description: The request is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                message: invalid request body
        '401':
          description: The access token is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                message: unauthorized
      x-codeSamples:
        - lang: Shell
          label: Character asset request
          source: |-
            curl \
              https://api.cometapi.com/api/asset/assets \
              -H "Authorization: $COMETAPI_ACCESS_TOKEN" \
              -F "group_id=<GROUP_ID>" \
              -F "asset_type=image" \
              -F "file=@/path/to/character.png"
        - lang: Python
          label: Character asset request
          source: |
            import os
            from pathlib import Path
            import requests

            with Path("/path/to/character.png").open("rb") as image:
                response = requests.post(
                    "https://api.cometapi.com/api/asset/assets",
                    headers={"Authorization": os.environ["COMETAPI_ACCESS_TOKEN"]},
                    data={"group_id": "<GROUP_ID>", "asset_type": "image"},
                    files={"file": ("character.png", image, "image/png")},
                    timeout=60,
                )
            response.raise_for_status()
            print(response.json())
        - lang: JavaScript
          label: Character asset request
          source: >
            const form = new FormData();

            form.append("group_id", "<GROUP_ID>");

            form.append("asset_type", "image");

            form.append("file", new Blob([await
            readFile("/path/to/character.png")], { type: "image/png" }),
            "character.png");


            const response = await
            fetch("https://api.cometapi.com/api/asset/assets", {
              method: "POST",
              headers: { Authorization: process.env.COMETAPI_ACCESS_TOKEN },
              body: form,
            });


            if (!response.ok) throw new Error(await response.text());

            console.log(await response.json());
components:
  schemas:
    UploadAssetMultipart:
      type: object
      required:
        - group_id
        - asset_type
      properties:
        group_id:
          type: string
          description: Active CometAPI group ID.
          example: ag-example
        asset_type:
          type: string
          enum:
            - image
            - video
            - audio
          description: Asset media type.
        name:
          type: string
          maxLength: 64
          description: Optional asset name.
        file:
          type: string
          format: binary
          description: Local file source.
        url:
          type: string
          format: uri
          pattern: ^https://
          description: Public HTTPS source URL.
        data:
          type: string
          description: Base64 or data URI source.
      description: 'Provide exactly one source: file, url, or data.'
    UploadAssetJSON:
      type: object
      required:
        - group_id
        - asset_type
      properties:
        group_id:
          type: string
          description: Active CometAPI group ID.
          example: ag-example
        asset_type:
          type: string
          enum:
            - image
            - video
            - audio
          description: Asset media type.
        name:
          type: string
          maxLength: 64
          description: Optional asset name.
        url:
          type: string
          format: uri
          pattern: ^https://
          description: Public HTTPS source URL.
        data:
          type: string
          description: Base64 or data URI source.
      description: 'Provide exactly one source: file, url, or data.'
    AssetView:
      type: object
      required:
        - id
        - group_id
        - asset_type
        - status
        - created_at
      properties:
        id:
          type: string
          description: CometAPI asset ID.
          example: as-example
        group_id:
          type: string
          description: Owning group ID.
          example: ag-example
        name:
          type: string
          description: Optional asset name.
        asset_type:
          type: string
          enum:
            - image
            - video
            - audio
          description: Asset media type.
        status:
          type: string
          enum:
            - processing
            - active
            - failed
          description: Asset processing status.
        fail_reason:
          type: string
          description: Sanitized failure reason when processing fails.
        created_at:
          type: integer
          description: Creation time as a Unix timestamp in seconds.
    ErrorResponse:
      type: object
      required:
        - success
        - message
      properties:
        success:
          type: boolean
          description: Whether the request succeeded.
        message:
          type: string
          description: Description of the request error.
        data:
          type:
            - object
            - array
            - 'null'
          description: Error details when returned.
      additionalProperties: true
  securitySchemes:
    accessTokenAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Raw CometAPI access token. Do not prefix it with Bearer.

````

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