Swap Face

POSThttps://api.newportai.com/api/async/swap_face

The Swap Face API performs a one-way facial transfer, seamlessly replacing the facial features in a target image with those from a source face. The generated output preserves the original pose, lighting, and background of the target image while accurately adopting the facial characteristics of the source subject.

  • Submit a POST request to the Swap Face API to obtain a taskId.
  • Submit a POST request to the Polling API to retrieve the face-swapped results.
  • Configure a Callback URL to receive results automatically on completion.

Request Headers

Content-Type string Required

Enum: application/json

Authorization string Required

Bearer authentication token. Example: Bearer {{APIKey}}.

Request Body

url string Required

The URL of the target image. It must contain exactly one detectable face. Constraints: maximum resolution of 16 megapixels and a maximum file size of 10MB.

faceImgUrl string Required

The URL of the source image containing the face to be transposed. It must contain exactly one detectable face. Constraints: maximum resolution of 16 megapixels and a maximum file size of 10MB.

Response

code integer

Returns 0 for success, or a specific error code.

message string

Returns "success" or a descriptive error message.

data object
taskId string

The unique identifier for the task. Use this ID with the Polling API to retrieve the generated output.

Errors

10192Illegal param

Polling

Use the Polling API to retrieve the processing results.

Callback

Alternatively, you can enable Callback to receive task results automatically upon completion.

0Task Completed
{
  "code": 0,
  "message": "success",
  "data": {
    "task": {
      "taskId": "b08337dc08d7428daa64b3d5e61b8350",
      "status": 3,
      "taskType": "swap_face"
    },
    "images": [
      {
        "imageType": "jpg",
        "imageUrl": "https://api.newportai.com/docs/merge-face-2.jpg"
      }
    ]
  }
}
Request
cURL
curl -X POST 'https://api.newportai.com/api/async/swap_face' \
  -H "Authorization: Bearer {{key}}" \
  -H 'Content-Type: application/json' \
  -d '{
  "url": "https://d2t5pyzt5qvy2d.cloudfront.net/api/static_resource/prod/default/INj5UrnnrKIzCR1uYBWv0.png",
  "faceImgUrl": "https://d2t5pyzt5qvy2d.cloudfront.net/api/static_resource/prod/default/VE-i9SzS3ZRdVTSzJWTcA.jpeg"
}'
0Successful
{
  "code": 0,
  "message": "success",
  "data": {
    "taskId": "b08337dc08d7428daa64b3d5e61b8350"
  }
}