Skip to main content
Download and store generated output URLs promptly. Hosted resources may expire; retention policy follows your platform agreement.

API Endpoints

Head Swap Operations

Base URL

Use the Open API root host provided by your account or integration guide. All paths below are relative to that root (example: https://openapi.akool.com).

Getting Started

Basic Workflow

  1. Submit person analysis
    Call Submit Person Analysis with video_url and type: "head". Save the returned _id (analysis record id).
  2. Poll analysis
    Call Get Analysis Result with _id until status is 3 (completed) or 4 (failed). On success, read analysis_result.media[] for obj_id and preview img_url.
  3. Create head swap task
    Use the same video_url as in step 1. In mappings, pair each obj_id with a reference face img_url (single image per mapping). Call Create Head Swap Task. Save the task _id.
  4. Poll task or use webhook
    Call Get Head Swap Task Detail until status is 3 and video_url is populated, or handle completion via webhookUrl if configured.
Person analysis and task creation must use the identical video_url. Each mappings[].obj_id must come from analysis_result.media for that analysis.

Authentication

Every request must include your API key:
HeaderExample
x-api-keyx-api-key: <your_api_key>
You may also use Authorization: Bearer {token} per Get Token. If both are sent, behavior follows the platform rule (typically Authorization takes precedence).

Response envelope

Responses are JSON:
{
  "code": 1000,
  "msg": "OK",
  "data": {}
}
FieldDescription
codeBusiness status code (integer). Treat 1000 as success.
msgHuman-readable message (e.g. Analyze success after analyze submit, often OK elsewhere).
dataPayload when successful; may be empty or omitted on some errors.
HTTP status is often 200; always use code in the body to determine success or failure.

Response Code Description

If code is not 1000, the request failed or was rejected. Do not treat the call as successful.
CodeDescription
1000Success
1003Parameter error, validation failed, or unsupported feature for the account
1014Resource not found (invalid analysis or task id, or no access)
1101Invalid authorization
1102Authorization cannot be empty
1104Insufficient credits
2001Server error
Contact support for the full code list if your integration requires it.

Limits

ItemDescription
Source video durationApproximately 3–20 seconds (exact bounds enforced server-side)
URLsvideo_url and image URLs must be http or https and reachable by the API
mappingsAt least 1 entry, at most 5 per task
Access scopeQuery endpoints only return resources belonging to the authenticated team

Status Codes

Analysis task (status on analyze records)

StatusDescription
1In queue
2Processing
3Completed — analysis_result should be ready
4Failed

Head swap generation task (status on task records)

StatusDescription
1In queue
2Processing
3Completed — check video_url for output
4Failed — check error_reason / error_code if present

Best Practices

  • Stable video_url: Use the same URL string for analyze and create; avoid redirects or URL normalization that changes the string.
  • Reference images: Use clear, front-facing reference faces; mappings[].img_url is the replacement face, not necessarily the analysis preview URL.
  • Polling: Poll analyze detail until terminal state, then create the task; poll task detail until status is 3 or 4.
  • Webhook: Prefer HTTPS for webhookUrl; payload format and retries are defined by platform documentation or support.

Support