Developer Docs/Actor Swap API

Actor Swap API

Build Actor Swap integrations with A2E. Review authentication, request parameters, task creation, status, and result endpoints.

Overview

Replace an actor in a video segment with a different person, retaining original motion, camera angle, and scene continuity.

Primary Endpoint

POST/api/v1/actorSwap/start

"Generate actor swap video by swapping actor from image to video.". ### Request - This operation permits anonymous requests. Authenticated callers may send a bearer token. - Supply `x-anonymous-id` headers as documented in the parameter schema, including any anonymous identity requirements. - Send an `application/json` body. Required fields: `image_url`, `video_url`. - API-token callers may include `webhook_url` and `webhook_token` for best-effort terminal-state notifications; ordinary JWT/cookie calls ignore these fields. ### Behavior - This is an asynchronous operation: a successful submission creates a task and returns before processing finishes. - Persist the returned task identifier and use the corresponding detail or list operation to observe progress. - Treat the detail endpoint as the source of truth even when webhook delivery is enabled. ### Response - A `200` response confirms task acceptance; it does not by itself mean media generation has completed. - Retain the returned identifier and wait for a documented terminal status before using output URLs. - JSON object responses, including error responses, normally carry a top-level `trace_id` string for this request; include it when contacting support. It is not a task identifier. - Do not infer undocumented fields or statuses; clients should tolerate additional response properties. ### Errors - `401` — Unauthorized - Invalid or missing JWT token. - `422` — Content moderation rejected the `image_url` character image. Code `1003` means confirmed minor content. Code `1004` means suspected minor content. For `1004`, confirm the input and retry with `minor_suspected_skip: true`. ### Related Operations - `GET /api/v1/actorSwap/allRecords` — Get all task records. - `GET /api/v1/actorSwap/{_id}` — Get task details. - `DELETE /api/v1/actorSwap/{_id}` — Delete task. Authentication: set header Authorization: Bearer <token> (supports user JWT or sk_ API token).

Request Parameters

NameTypeRequiredDescription
ai_sharing_consentobjectNoConsent receipt for newer native apps. Legacy native requests may omit this field and continue without a consent record. If present, null, malformed, expired or incomplete receipts return AI_SHARING_CONSENT_REQUIRED before generation. Valid receipts cover all actual AI recipients, including safety providers and intermediaries, and constrain later fallback. Content safety checks remain required for native requests. Web and legacy API behavior is unchanged.
ai_sharing_consent.versionenum: 2026-11-12Yes-
ai_sharing_consent.recipientsarray<string>Yes-
free_quota_expectedbooleanNoWeb request expecting a free discount; returns 12006 when the discount decreases. API tokens are ineligible.
free_quota_expected_coinsnumberNoMinimum expected free credits. If the available discount decreases, returns 12006 without creating a task or automatically charging a higher price.; minimum: 0
namestringNoName of the actor swap task
image_urlstringYesURL of the reference actor image
video_urlstringYesURL of the control video
model_versionenum: v1 | v2NoV1 uses the classic workflow; V2 uses A2E V2 character swap at 10 credits per second and requires sign-in.; default: "v1"
promptstringNoEditable positive prompt for V1 and V2. V2 defaults to the English character swap prompt when omitted or blank.
negative_promptstringNoNegative prompt for V1. V2 ignores this field and sends an empty negative prompt.
timeoutintegerNoTimeout in seconds; default: 300
minor_suspected_skipbooleanNoSet to true when retrying after error code 1004 to confirm and bypass the suspected-minor soft block.; default: false
webhook_urlstringNoHTTPS URL to receive task.completed / task.failed notifications. Best-effort delivery, single attempt, no retries; clients should treat the detail API as the source of truth.; maxLength: 2048
webhook_tokenstringNoOptional plaintext token returned in the X-A2e-Webhook-Token header so receivers can verify the request originated from a2e.; maxLength: 256
Request schema and conditional rules
{
  "allOf": [
    {
      "type": "object",
      "properties": {
        "ai_sharing_consent": {
          "type": "object",
          "description": "Consent receipt for newer native apps. Legacy native requests may omit this field and continue without a consent record. If present, null, malformed, expired or incomplete receipts return AI_SHARING_CONSENT_REQUIRED before generation. Valid receipts cover all actual AI recipients, including safety providers and intermediaries, and constrain later fallback. Content safety checks remain required for native requests. Web and legacy API behavior is unchanged.",
          "required": [
            "version",
            "recipients"
          ],
          "properties": {
            "version": {
              "type": "string",
              "enum": [
                "2026-11-12"
              ]
            },
            "recipients": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": [
                "A2E",
                "Alibaba Cloud"
              ]
            }
          }
        },
        "free_quota_expected": {
          "type": "boolean",
          "description": "Web request expecting a free discount; returns 12006 when the discount decreases. API tokens are ineligible."
        },
        "free_quota_expected_coins": {
          "type": "number",
          "minimum": 0,
          "description": "Minimum expected free credits. If the available discount decreases, returns 12006 without creating a task or automatically charging a higher price."
        },
        "name": {
          "type": "string",
          "description": "Name of the actor swap task",
          "example": "My Actor Swap"
        },
        "image_url": {
          "type": "string",
          "description": "URL of the reference actor image",
          "format": "uri",
          "example": "https://example.com/actor.jpg"
        },
        "video_url": {
          "type": "string",
          "description": "URL of the control video",
          "format": "uri",
          "example": "https://example.com/video.mp4"
        },
        "model_version": {
          "type": "string",
          "enum": [
            "v1",
            "v2"
          ],
          "default": "v1",
          "description": "V1 uses the classic workflow; V2 uses A2E V2 character swap at 10 credits per second and requires sign-in."
        },
        "prompt": {
          "type": "string",
          "description": "Editable positive prompt for V1 and V2. V2 defaults to the English character swap prompt when omitted or blank.",
          "example": "high quality, realistic"
        },
        "negative_prompt": {
          "type": "string",
          "description": "Negative prompt for V1. V2 ignores this field and sends an empty negative prompt.",
          "example": "blurry, distorted"
        },
        "timeout": {
          "type": "integer",
          "description": "Timeout in seconds",
          "default": 300,
          "example": 300
        },
        "minor_suspected_skip": {
          "type": "boolean",
          "default": false,
          "description": "Set to true when retrying after error code 1004 to confirm and bypass the suspected-minor soft block."
        }
      },
      "required": [
        "image_url",
        "video_url"
      ]
    },
    {
      "$ref": "#/components/schemas/WebhookInput"
    }
  ]
}

Response Fields

code: integer
data: object
data.hasRefundCoin: boolean
Stored refund flag; true does not confirm crediting while refund_pending is true. Omitted when unknown, including legacy records without a stored flag.
data.refund_pending: boolean
True means refund pending resolution and takes precedence over hasRefundCoin. Explicit false is preserved; omitted when unknown, including legacy records without a stored flag.
data._id: string
data.name: string
data.image_url: string
data.video_url: string
data.model_version: enum: v1 | v2
data.current_status: string
data.coins: number
data.createdAt: string
trace_id: string
Trace ID of this HTTP request. Include it when contacting support about this request. It is generated per request and is not a task identifier; use the returned task `_id` to query results.

Request Example

curl -X POST "https://www.a2e.com.cn/api/v1/actorSwap/start" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "My Actor Swap",
  "image_url": "https://example.com/actor.jpg",
  "video_url": "https://example.com/video.mp4",
  "model_version": "v2",
  "timeout": 300
}'

Related Endpoints

Responses

200

Actor swap task started successfully

401

Unauthorized - Invalid or missing bearer token

422

Content moderation rejected the `image_url` character image. Code `1003` means confirmed minor content. Code `1004` means suspected minor content. For `1004`, confirm the input and retry with `minor_suspected_skip: true`.

Actor Swap API Documentation