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

# Create and queue insta swap

> Auto-queues a render task to replace the sample seed's identity with the specified custom actor. Automatically processes and charges 1 credit. Pass `digitalSampleVariationId` to render an assembled variation cut; use `null` for the original seed when eligible (≤30s and enabled).



## OpenAPI

````yaml /openapi.yaml post /digital-samples/{id}/insta-swaps
openapi: 3.1.0
info:
  title: YPH Public API
  version: 1.0.0
  description: |
    Programmatic access to Digital Samples, Actors, Insta Swaps, and webhooks.

    Authenticate with `Authorization: Bearer yph_sk_live_…`.
servers:
  - url: https://api.yourproducthere.ai/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: System
  - name: Account
  - name: Actors
  - name: Digital Samples
  - name: Insta Swaps
  - name: Webhooks
paths:
  /digital-samples/{id}/insta-swaps:
    post:
      tags:
        - Insta Swaps
      summary: Create and queue insta swap
      description: >-
        Auto-queues a render task to replace the sample seed's identity with the
        specified custom actor. Automatically processes and charges 1 credit.
        Pass `digitalSampleVariationId` to render an assembled variation cut;
        use `null` for the original seed when eligible (≤30s and enabled).
      parameters:
        - $ref: '#/components/parameters/SampleId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - actorId
                - digitalSampleVariationId
              properties:
                actorId:
                  type: string
                  format: uuid
                  description: >-
                    The unique identifier of the actor to replace the seed
                    face/body with.
                digitalSampleVariationId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    Assembled variation id for the render seed. `null` =
                    original seed when ≤30s and enabled by the brand.
                accountToken:
                  type: string
                  maxLength: 128
                  nullable: true
                  description: >
                    Integrator token for this swap (creator or brand). Defaults
                    to the actor's `accountToken` when omitted.

                    When equal to the parent sample's `accountToken`, the swap
                    is **brand self-service** (`isBrandSelfService: true` on the
                    response).
      responses:
        '201':
          description: Swap task queued successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  instaSwap:
                    $ref: '#/components/schemas/InstaSwap'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: Insufficient credits
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                insufficientCredits:
                  summary: Insufficient Credits
                  value:
                    code: INSUFFICIENT_CREDITS
                    error: insufficient_credits
                    requiredCredits: 1
                    currentBalance: 0
                    fundingShortfall: 1
        '404':
          description: Digital sample or actor not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                sampleNotFound:
                  summary: Digital Sample Not Found
                  value:
                    code: RESOURCE_NOT_FOUND
                    error: digital sample not found
                actorNotFound:
                  summary: Actor Not Found
                  value:
                    code: RESOURCE_NOT_FOUND
                    error: Actor not found or forbidden
components:
  parameters:
    SampleId:
      name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
  schemas:
    InstaSwap:
      type: object
      description: >
        Insta swap render job. `accountToken` on the swap is the integrator id
        for whoever initiated it (creator or brand).

        `sampleAccountToken` and `productToken` are read from the parent digital
        sample.

        When `isBrandSelfService` is true, `accountToken` equals
        `sampleAccountToken` (brand-owned production, not a creator
        application).
      properties:
        id:
          type: string
          format: uuid
        orgId:
          type: string
        digitalSampleId:
          type: string
          format: uuid
        digitalSampleVariationId:
          type: string
          format: uuid
          nullable: true
          description: >-
            Variation seed used for this render; null when original seed was
            used.
        actorId:
          type: string
          format: uuid
        accountToken:
          type: string
          nullable: true
          maxLength: 128
        sampleAccountToken:
          type: string
          nullable: true
          maxLength: 128
          readOnly: true
          description: Brand token from the parent digital sample.
        productToken:
          type: string
          nullable: true
          maxLength: 128
          readOnly: true
          description: Catalog product token from the parent digital sample.
        isBrandSelfService:
          type: boolean
          readOnly: true
          description: >-
            True when swap `accountToken` equals the parent sample's
            `accountToken`.
        status:
          type: string
          enum:
            - QUEUED
            - ASSIGNED
            - RENDERING
            - PENDING_APPROVAL
            - COMPLETED
            - FAILED
            - EXPIRED
            - CANCELLED
          description: Render pipeline status. Treat unknown values as in-progress.
        triggerSource:
          type: string
          enum:
            - app
            - api
        renderingMs:
          type: integer
          nullable: true
        startedAt:
          type: string
          nullable: true
          format: date-time
        finishedAt:
          type: string
          nullable: true
          format: date-time
        signedResultVideoUrl:
          type: string
          nullable: true
          format: uri
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      example:
        id: e4e18374-f119-4b11-a8a1-d6a2bc38e41a
        orgId: org_123abc
        digitalSampleId: d3b07384-d113-4956-a5e2-416b2a41bc3c
        actorId: a1c02874-e339-4d11-8fa1-e6a2bc38c41d
        accountToken: creator_42
        sampleAccountToken: brand_nike
        productToken: sku_air_max_90
        isBrandSelfService: false
        status: COMPLETED
        triggerSource: api
        renderingMs: 4500
        startedAt: '2026-06-20T12:10:00Z'
        finishedAt: '2026-06-20T12:10:04.500Z'
        signedResultVideoUrl: https://r2.yourproducthere.ai/results/completed_video.mp4?token=sig
        createdAt: '2026-06-20T12:09:59Z'
        updatedAt: '2026-06-20T12:10:05Z'
    Error:
      type: object
      properties:
        code:
          type: string
          description: >-
            A machine-readable, uppercase error code (e.g.
            `REQUIRED_FIELD_MISSING`, `INVALID_PARAMETER`, `RESOURCE_NOT_FOUND`,
            `UNAUTHORIZED`, `CONFLICT`).
        error:
          type: string
          description: A human-readable error message explaining why the request failed.
        parameter:
          type: string
          nullable: true
          description: >-
            The name of the specific input parameter or body field that caused
            the error (e.g. `seedVideoUrl`, `title`, etc.).
        details:
          type: object
          nullable: true
          description: >-
            Additional key-value pairs providing context or structured details
            about the failure.
      example:
        code: REQUIRED_FIELD_MISSING
        error: title is required
        parameter: title
        details: null
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missingTitle:
              summary: Missing Required Title
              value:
                code: REQUIRED_FIELD_MISSING
                error: title is required
                parameter: title
            invalidFps:
              summary: Invalid FPS Value
              value:
                code: INVALID_PARAMETER
                error: renderSeedFps must be 16, 24, or 30
                parameter: renderSeedFps
            invalidWidth:
              summary: Invalid Entry Width
              value:
                code: INVALID_PARAMETER
                error: renderEntryWidth must be 480 or 720
                parameter: renderEntryWidth
            durationExceeded:
              summary: Seed Video Too Long
              value:
                code: INVALID_PARAMETER
                error: video duration exceeds maximum allowed 170 seconds
                parameter: seedVideoUrl
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthorized:
              summary: Invalid API Key
              value:
                code: UNAUTHORIZED
                error: Unauthorized
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Your organization API key starting with yph_sk_live_…

````