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

# Prepare an uploaded file for this connection

> Upload your file with POST /files and complete the signed multipart upload first. Send its file_id with kind=video or kind=cover. This endpoint prepares that file for the selected connection and returns a pm_ ID with status=prepared. Use the returned ID as media.prepared_video_id or media.prepared_cover_id in POST /publishing/tasks. Prepared media cannot be reused across workspaces or connections. URLs and storage paths are not accepted. Preparation does not publish content.

TikTok Shop only. The key creator must remain a workspace member with current account access. Read requests: 120/minute/workspace; writes: 30/minute/workspace (configurable). Media preparation and new submissions require Pro or higher. Video submission uses your API wallet; photos, reads, media preparation and cancellation are free. See https://www.creatok.ai/app/api-platform/pricing for current prices. Accepted tasks continue after plan downgrade. Unknown results are not automatically resent or refunded.



## OpenAPI

````yaml /api-reference/openapi.json post /publishing/media
openapi: 3.1.0
info:
  title: CreatOK API
  version: 1.3.0
  description: >-
    Asynchronous media generation and TikTok Shop publishing API. Authenticate
    with a Bearer organization API key (cok_). Personal CLI/MCP keys are not
    accepted. Resource responses are returned directly, without a code/data
    envelope. Each response includes X-Request-Id.
servers:
  - url: https://api.creatok.ai/v1
security: []
paths:
  /publishing/media:
    post:
      summary: Prepare an uploaded file for this connection
      description: >-
        Upload your file with POST /files and complete the signed multipart
        upload first. Send its file_id with kind=video or kind=cover. This
        endpoint prepares that file for the selected connection and returns a
        pm_ ID with status=prepared. Use the returned ID as
        media.prepared_video_id or media.prepared_cover_id in POST
        /publishing/tasks. Prepared media cannot be reused across workspaces or
        connections. URLs and storage paths are not accepted. Preparation does
        not publish content.


        TikTok Shop only. The key creator must remain a workspace member with
        current account access. Read requests: 120/minute/workspace; writes:
        30/minute/workspace (configurable). Media preparation and new
        submissions require Pro or higher. Video submission uses your API
        wallet; photos, reads, media preparation and cancellation are free. See
        https://www.creatok.ai/app/api-platform/pricing for current prices.
        Accepted tasks continue after plan downgrade. Unknown results are not
        automatically resent or refunded.
      operationId: preparePublishingMedia
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PreparePublishingMediaRequest'
            examples:
              video:
                value:
                  connection_uid: conn_ts_0000000000000000000000
                  kind: video
                  file_id: file_11111111-1111-4111-8111-111111111111
                  file_name: product-demo.mp4
              cover:
                value:
                  connection_uid: conn_ts_0000000000000000000000
                  kind: cover
                  file_id: file_22222222-2222-4222-8222-222222222222
      responses:
        '200':
          description: Result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreparedPublishingMedia'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              description: Polling suggestion for nonterminal tasks
              schema:
                type: integer
        '400':
          description: >-
            Request error. Recover ambiguous accepted requests using the
            original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              schema:
                type: integer
        '401':
          description: >-
            Request error. Recover ambiguous accepted requests using the
            original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              schema:
                type: integer
        '402':
          description: >-
            Request error. Recover ambiguous accepted requests using the
            original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              schema:
                type: integer
        '403':
          description: >-
            Request error. Recover ambiguous accepted requests using the
            original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              schema:
                type: integer
        '404':
          description: >-
            Request error. Recover ambiguous accepted requests using the
            original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              schema:
                type: integer
        '409':
          description: >-
            Request error. Recover ambiguous accepted requests using the
            original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              schema:
                type: integer
        '429':
          description: >-
            Request error. Recover ambiguous accepted requests using the
            original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              schema:
                type: integer
        '500':
          description: >-
            Request error. Recover ambiguous accepted requests using the
            original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              schema:
                type: integer
        '502':
          description: >-
            Request error. Recover ambiguous accepted requests using the
            original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              schema:
                type: integer
        '503':
          description: >-
            Request error. Recover ambiguous accepted requests using the
            original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            X-Request-Id:
              schema:
                type: string
            Retry-After:
              schema:
                type: integer
      security:
        - ApiKey: []
components:
  schemas:
    PreparePublishingMediaRequest:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        connection_uid:
          type: string
          minLength: 1
          description: TikTok Shop connection UID returned by GET /publishing/connections.
        kind:
          type: string
          enum:
            - video
            - cover
          description: Prepare a video for publishing or an image for use as its cover.
        file_id:
          type: string
          pattern: ^file_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          description: >-
            File ID returned by POST /files after you complete the multipart
            upload. Must belong to this workspace.
        file_name:
          description: >-
            Optional filename, up to 255 characters. Video preparation defaults
            to video.mp4.
          type: string
          minLength: 1
          maxLength: 255
      required:
        - connection_uid
        - kind
        - file_id
      additionalProperties: false
    PreparedPublishingMedia:
      type: object
      required:
        - id
        - kind
        - connection_uid
        - status
      properties:
        id:
          type: string
          pattern: ^pm_
        kind:
          enum:
            - video
            - cover
        connection_uid:
          type: string
        status:
          const: prepared
    Error:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
            code:
              type: string
            message:
              type: string
            param:
              type: string
            request_id:
              type: string
          required:
            - type
            - code
            - message
            - request_id
          additionalProperties: false
      required:
        - error
      additionalProperties: false
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: CreatOK organization API key

````

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