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

# Video Face Scan API

> Find every person in a video before a multi-person face swap. Returns a face thumbnail and screen time for each person, ready to pick who gets swapped.

The scan is the first step of a [multi-person face swap](https://docs.goenhance.ai/api-reference/face-swap/video-generate.md#multi-person-face-swap). It finds the distinct people in a video and returns one thumbnail per person. You then choose which people to swap and pass the scan ID to [Video Face Swap](https://docs.goenhance.ai/api-reference/face-swap/video-generate.md).

## Pricing

1 token per scan (= \$0.02 USD). The length of the video does not change the price.

The scan and the swap are billed separately. The swap costs the same as a single-person swap, see [Video Face Swap pricing](https://docs.goenhance.ai/api-reference/face-swap/video-generate.md#pricing).

## Request

```bash theme={null}
curl --request POST \
  --url https://api.goenhance.ai/api/v1/videofaceswap/scan \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "reference_video": "https://example.com/party.mp4"
  }'
```

* `reference_video` follows the same rules as in [Video Face Swap](https://docs.goenhance.ai/api-reference/face-swap/video-generate.md#supported-inputs): the same formats, a 100 MB limit and 2 to 120 seconds for videos, and the usual GIF limits for GIFs.
* The whole video is scanned. To swap only part of it, set `start_time` and `end_time` in the swap request.

The response contains the scan ID:

```json theme={null}
{
  "code": 0,
  "msg": "Success",
  "data": {
    "img_uuid": "8d3f2a61-5b7c-4e0a-9f12-3c4d5e6f7a8b",
    "cost": 1
  }
}
```

## Result

Poll [Task Detail](https://docs.goenhance.ai/api-reference/tasks/detail.md) with the `img_uuid`. When the scan succeeds, `data.json` has one entry per person:

```json theme={null}
"json": [
  {
    "type": "image",
    "value": "https://.../person_0.jpg",
    "person": 0,
    "appearances": 86,
    "first_seen": 0.0,
    "last_seen": 56.0
  },
  {
    "type": "image",
    "value": "https://.../person_1.jpg",
    "person": 1,
    "appearances": 75,
    "first_seen": 0.0,
    "last_seen": 56.0
  }
]
```

| Field | Meaning |
| - | - |
| `value` | Thumbnail of the person's face. Show it to your users so they can pick who to swap. |
| `person` | The person's index, starting at 0. Use it in `faces[].person` in the swap request. |
| `appearances` | How many sampled frames the person appears in. The video is sampled at 2 frames per second, so 86 is roughly 43 seconds on screen. |
| `first_seen`, `last_seen` | First and last time the person appears, in seconds. |

* People are sorted by `appearances`, most frequent first, so `person: 0` is the person on screen the longest.
* At most 10 people are returned. If the video has more, you get the 10 who appear most.
* If no face is found anywhere in the video, the task fails with the message `No face detected in the video`.
* The scan ID can be used for swaps for 7 days. After that, scan the video again.

## Next step

Send the scan ID as `scan_id` and the people you want to swap as `faces` to [Video Face Swap](https://docs.goenhance.ai/api-reference/face-swap/video-generate.md#multi-person-face-swap).


## OpenAPI

````yaml POST /api/v1/videofaceswap/scan
openapi: 3.1.0
info:
  title: GoEnhance API
  description: ''
  version: 1.0.0
servers:
  - url: https://api.goenhance.ai
security:
  - bearerAuth: []
tags:
  - name: Basic
  - name: Video2Video
paths:
  /api/v1/videofaceswap/scan:
    post:
      tags: []
      summary: Scan Video Faces
      description: >-
        Find the distinct people in a video so you can swap several of them with
        `POST /api/v1/videofaceswap/generate`.


        **Pricing:** 1 token per scan (= $0.02), whatever the video length.


        The scan is asynchronous: poll `GET /api/v1/jobs/detail` with the
        returned `img_uuid`. On success `data.json` lists up to 10 people, most
        frequent first. Each entry has `type: "image"`, `value` (a thumbnail of
        the person's face), `person` (index, from 0), `appearances` (number of
        sampled frames the person appears in, sampled at 2 frames per second),
        `first_seen` and `last_seen` (seconds). If the video has no face, the
        task fails with `No face detected in the video`.


        Use the returned `img_uuid` as `scan_id` in the generate request. It is
        valid for 7 days.
      parameters:
        - name: Authorization
          in: header
          description: ''
          required: true
          example: ''
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                reference_video:
                  type: string
                  description: >-
                    Video or GIF URL to scan. Same formats and limits as Video
                    Face Swap: .mp4, .mov, .avi, .wmv, .flv, .webm (max 100 MB,
                    2-120 seconds) and .gif (max 20 MB, at least 2 frames). The
                    format is taken from the extension in the URL path. The
                    whole video is scanned.
              required:
                - reference_video
            example:
              reference_video: https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  msg:
                    type: string
                  data:
                    type: object
                    properties:
                      img_uuid:
                        type: string
                        description: >-
                          Scan ID. Poll it with GET /api/v1/jobs/detail and pass
                          it as `scan_id` to POST
                          /api/v1/videofaceswap/generate.
                      cost:
                        type: number
                        description: >-
                          Tokens deducted for this request. This is the amount
                          actually charged, so it already reflects any discount
                          active on your account and can be lower than the
                          listed price. Tokens are deducted when the task is
                          accepted, and refunded automatically if the generation
                          ends in failure.
                        example: 1
                    required:
                      - img_uuid
                      - cost
                required:
                  - code
                  - msg
                  - data
              example:
                code: 0
                msg: Success
                data:
                  img_uuid: 8d3f2a61-5b7c-4e0a-9f12-3c4d5e6f7a8b
                  cost: 1
          headers: {}
        '401':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                code: 401
                msg: Token Error
          headers: {}
        '500':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                code: 500
                msg: ''
          headers: {}
      deprecated: false
      security: []
components: {}

````

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