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

# Unggah aset karakter

> Unggah aset gambar, video, atau audio ke grup aset CometAPI yang aktif untuk digunakan dalam permintaan Seedance berikutnya.

Unggah satu sumber ke grup aset yang aktif. Kirim token akses mentah dalam header `Authorization` tanpa awalan `Bearer`. Grup orang nyata hanya menerima aset gambar.

### Unggah file

Gunakan kolom `file` untuk sumber lokal:

```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"
```

### Unggah URL gambar

Gunakan format JSON untuk sumber yang tersedia di URL publik:

```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"
  }'
```

Permintaan harus menyertakan tepat satu sumber: `file`, `url`, atau `data`. Kolom opsional `name` menerima hingga 64 karakter. Simpan `data.id` dari respons. Aset baru biasanya mengembalikan `data.status=processing`, jadi gunakan [Ambil aset karakter](https://apidoc.cometapi.com/id/api/video/seedance/get-character-asset.md) hingga statusnya `active`.

Jika grup tidak aktif, API mengembalikan `success: false` dengan pesan yang menjelaskan status grup. Periksa `success` dan `message` untuk kesalahan bisnis meskipun respons HTTP adalah `200`.


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