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

# Extract Data from Video (Async)

> Queue a structured-data extraction and return a `task_id` immediately.

**Use this instead of `POST /extract/video` whenever `transcribe` is left on and the video may run past ~10 minutes.** The extraction itself is fast; the speech-to-text step in front of it is what makes a synchronous request time out. This endpoint has no duration cap.

Accepts the same body as `POST /extract/video` — JSON, YAML and `multipart/form-data` all work here too — plus `webhook_url`. The schema is validated at submit time, so an invalid schema is rejected on the `POST`, before any transcription.

`include_usage` is not accepted here: pass it on `GET /extract/video/{task_id}` once `task_status=completed`.

See https://docs.vidnavigator.com/guides/async-jobs

**Submit-time check:** the submit endpoint returns `402` instead of a `task_id` when the account has almost no credits left. A job can still fail later with `402` when the media needs more than the remaining balance. An invalid or deactivated API key is rejected with `401`, and a key without the endpoint's permission with `403`; no task is created in either case.

Extract structured data from an online video of **any length**. The job runs in the background: you get a `task_id` immediately, then collect the result by polling or through a [webhook](https://docs.vidnavigator.com/webhooks.md).

> [!NOTE]
>
> Use this endpoint instead of [`POST /extract/video`](https://docs.vidnavigator.com/api-reference/endpoint/extract-video.md) when speech-to-text is needed (`transcribe=true`) and the video may run past **10 minutes** — the synchronous endpoint rejects it with `video_too_long`. The extraction itself is fast; the transcription in front of it is what takes time.

## How It Works

**1. Submit the job**

`POST /extract/video/async` with the **same body** as [`POST /extract/video`](https://docs.vidnavigator.com/api-reference/endpoint/extract-video.md), plus an optional `webhook_url`. You get `202 Accepted` with a `task_id` and a `check_status_url`.

**2. Wait for the result**

Poll `GET /extract/video/{task_id}` every few seconds while `task_status` is `processing` — polling is free — or receive a [webhook](https://docs.vidnavigator.com/webhooks.md) when the job finishes.

**3. Read the result**

On `completed`, `data.result` is identical to the synchronous response's `data` block, so the same parsing code works for both. On `failed`, `data.error` carries the same error code the synchronous endpoint would have returned.

> [!TIP]
>
> Accepts the same body as the synchronous endpoint — JSON, YAML and `multipart/form-data` all work. The schema is validated at submit time, so an invalid schema is rejected on the `POST`, before any transcription is billed.

## Billing

Billed **exactly like** [`POST /extract/video`](https://docs.vidnavigator.com/api-reference/endpoint/extract-video.md) — the async mode costs nothing extra. Charges are made in the background worker, so pass `include_usage=true` on the result request (not on the submit) to see them. A failed job has all of its charges reverted.

## Submit the job

`POST https://api.vidnavigator.com/v1/extract/video/async`

| Parameter         | Type    | Required | Description                                                                                                                                                                                                                                                                      |
| ----------------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `video_url`       | string  | Yes      | URL of the video to extract data from.                                                                                                                                                                                                                                           |
| `schema`          | object  | Yes      | Extraction schema (same rules as the synchronous endpoint).                                                                                                                                                                                                                      |
| `what_to_extract` | string  | No       | Optional guidance for what to extract.                                                                                                                                                                                                                                           |
| `transcribe`      | boolean | No       | Auto-transcribe when no platform transcript is available. Default `true`.                                                                                                                                                                                                        |
| `webhook_url`     | string  | No       | Where to POST the result when the job finishes. Overrides the account default set in [Studio → API](https://vidnavigator.com/studio/api); pass `""` to opt this job out of the default. Must be a public `https` URL. See [Webhooks](https://docs.vidnavigator.com/webhooks.md). |

> [!NOTE]
>
> `include_usage` is not accepted on the submit request — pass it on the poll request instead.

```bash cURL
curl -X POST "https://api.vidnavigator.com/v1/extract/video/async" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "video_url": "https://www.tiktok.com/@user/video/1234567890",
    "schema": {
      "main_topics": {
        "type": "Array",
        "description": "List of main topics discussed",
        "items": { "type": "String", "description": "A topic" }
      },
      "key_takeaway": {
        "type": "String",
        "description": "The single most important takeaway"
      }
    },
    "webhook_url": "https://example.com/hooks/vidnavigator"
  }'
```

```python Python
import time
import requests

BASE = "https://api.vidnavigator.com"
HEADERS = {"X-API-Key": "YOUR_API_KEY"}

task = requests.post(
    f"{BASE}/v1/extract/video/async",
    headers=HEADERS,
    json={
        "video_url": "https://www.tiktok.com/@user/video/1234567890",
        "schema": {
            "key_takeaway": {"type": "String", "description": "The single most important takeaway"}
        },
    },
).json()["data"]

while True:
    job = requests.get(BASE + task["check_status_url"], headers=HEADERS).json()["data"]
    if job["task_status"] != "processing":
        break
    time.sleep(5)

if job["task_status"] == "completed":
    print(job["result"])                # the extracted fields
    print(job["video_info"]["title"])   # the video's metadata
else:
    print("Failed:", job["error"]["error"], job["error"]["message"])
```

```javascript JavaScript
const BASE = 'https://api.vidnavigator.com';
const HEADERS = { 'X-API-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' };

const { data: task } = await (await fetch(`${BASE}/v1/extract/video/async`, {
  method: 'POST',
  headers: HEADERS,
  body: JSON.stringify({
    video_url: 'https://www.tiktok.com/@user/video/1234567890',
    schema: {
      key_takeaway: { type: 'String', description: 'The single most important takeaway' }
    }
  })
})).json();

let job;
do {
  await new Promise(r => setTimeout(r, 5000));
  ({ data: job } = await (await fetch(BASE + task.check_status_url, { headers: HEADERS })).json());
} while (job.task_status === 'processing');

console.log(job.task_status === 'completed' ? { data: job.result, video_info: job.video_info } : job.error);
```

> [!TIP]
>
> The [Python](https://docs.vidnavigator.com/sdks/python.md#structured-extraction) and [JavaScript](https://docs.vidnavigator.com/sdks/javascript.md#structured-extraction) SDKs (v2.1.0) do the submit and polling for you: `client.extract_video_data(...)` / `vn.extractVideoData(...)` return the extracted `data` and the video's `video_info` in one call.

### Response (202 Accepted)

```json
{
  "status": "success",
  "data": {
    "task_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "task_status": "processing",
    "job_type": "extract_video",
    "expires_at": "2026-09-23T13:00:00Z",
    "check_status_url": "/v1/extract/video/7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "webhook_url": "https://example.com/hooks/vidnavigator",
    "message": "Extraction job accepted."
  }
}
```

| Status | `error`                                                                             | Description                                                            |
| ------ | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| `400`  | `missing_parameter`, `request_body_required`, `invalid_schema`, `invalid_parameter` | Invalid request or schema.                                             |
| `401`  | —                                                                                   | Invalid or deactivated API key.                                        |
| `402`  | `limit_exceeded`                                                                    | Less than 60 seconds of transcription credit left. No task is created. |
| `403`  | —                                                                                   | The API key lacks permission for this endpoint.                        |
| `429`  | `too_many_active_jobs`                                                              | Too many jobs already running for this account.                        |

## Get the result

> [!NOTE]
>
> The playground above only covers the submit request. Call the result endpoint with cURL or your HTTP client.

`GET https://api.vidnavigator.com/v1/extract/video/{task_id}`

| Parameter       | In    | Required | Description                                                                               |
| --------------- | ----- | -------- | ----------------------------------------------------------------------------------------- |
| `task_id`       | path  | Yes      | The `task_id` returned by `POST /extract/video/async`.                                    |
| `include_usage` | query | No       | When `true` and `task_status=completed`, attaches a `usage` block with the final charges. |

Polling is **free**. Results are kept for **1 hour after the job finishes**, and reading a task doesn't delete it.

On `completed`, `data.result` is **identical** to the `data` block of a successful [synchronous `POST /extract/video`](https://docs.vidnavigator.com/api-reference/endpoint/extract-video.md) response, and `data.video_info` holds the same `video_info` the synchronous endpoint returns beside it.

```json
{
  "status": "success",
  "data": {
    "task_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "task_status": "completed",
    "job_type": "extract_video",
    "created_at": "2026-09-23T12:00:00Z",
    "started_at": "2026-09-23T12:00:01Z",
    "completed_at": "2026-09-23T12:04:10Z",
    "expires_at": "2026-09-23T13:04:10Z",
    "check_status_url": "/v1/extract/video/7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "webhook": null,
    "result": {
      "main_topics": ["machine learning", "neural networks"],
      "key_takeaway": "Start with clean data before choosing a model architecture"
    },
    "video_info": {
      "title": "Machine Learning Fundamentals",
      "channel": "Tech Academy",
      "duration": 1843.0,
      "url": "https://www.youtube.com/watch?v=abc123"
    },
    "error": null
  }
}
```

`video_info` is only present once `task_status` is `completed`.

On `failed`, `data.result` is `null` and `data.error` carries the same code the synchronous endpoint would have returned (e.g. `transcript_not_available`, `http_status: 404`). All charges are reverted.

| Status | `error`          | Description                                                                      |
| ------ | ---------------- | -------------------------------------------------------------------------------- |
| `404`  | `task_not_found` | Unknown `task_id`, expired, owned by another account, or not an extraction task. |

## Webhook

Pass `webhook_url` on the submit request, or configure a default endpoint in [Studio → API](https://vidnavigator.com/studio/api), to be called back when the job finishes. See [Webhooks](https://docs.vidnavigator.com/webhooks.md) for the payload and signature verification, and [Async Jobs](https://docs.vidnavigator.com/guides/async-jobs.md) for the full workflow.

## OpenAPI

````yaml POST /extract/video/async
openapi: 3.0.3
info:
  title: VidNavigator Developer API
  version: 1.0.0
servers:
  - url: https://api.vidnavigator.com/v1
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /extract/video/async:
    post:
      summary: Extract structured data from a video asynchronously (long videos)
      description: |-
        Queue a structured-data extraction and return a `task_id` immediately.

        **Use this instead of `POST /extract/video` whenever `transcribe` is left on and the video may run past ~10 minutes.** The extraction itself is fast; the speech-to-text step in front of it is what makes a synchronous request time out. This endpoint has no duration cap.

        Accepts the same body as `POST /extract/video` — JSON, YAML and `multipart/form-data` all work here too — plus `webhook_url`. The schema is validated at submit time, so an invalid schema is rejected on the `POST`, before any transcription.

        `include_usage` is not accepted here: pass it on `GET /extract/video/{task_id}` once `task_status=completed`.

        See https://docs.vidnavigator.com/guides/async-jobs

        **Submit-time check:** the submit endpoint returns `402` instead of a `task_id` when the account has almost no credits left. A job can still fail later with `402` when the media needs more than the remaining balance. An invalid or deactivated API key is rejected with `401`, and a key without the endpoint's permission with `403`; no task is created in either case.
      operationId: extractVideoDataAsync
      tags:
        - Extraction
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - video_url
                - schema
              properties:
                video_url:
                  type: string
                  format: uri
                  description: URL of the video to extract data from
                  example: https://www.tiktok.com/@user/video/1234567890
                schema:
                  $ref: "#/components/schemas/ExtractionSchema"
                what_to_extract:
                  type: string
                  description: Optional guidance for what to extract from the transcript
                transcribe:
                  type: boolean
                  default: true
                  description: When true, automatically transcribes the video audio if no platform transcript is available.
                webhook_url:
                  type: string
                  format: uri
                  description: Where to POST the result when the job finishes. Overrides the account-level default configured in Studio → API. Pass an empty string to opt this job out of that default. Must be a publicly reachable https URL — private, loopback and link-local hosts are rejected. See https://docs.vidnavigator.com/guides/webhooks
                  example: https://example.com/hooks/vidnavigator
      responses:
        "202":
          description: Job accepted and started.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AsyncJobAccepted"
        "400":
          description: Bad request — missing parameters or an invalid extraction schema.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - error
                  error:
                    type: string
                    enum:
                      - missing_parameter
                      - request_body_required
                      - invalid_schema
                      - invalid_parameter
                  message:
                    type: string
        "402":
          description: Insufficient credits to queue the job; no task is created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - error
                  error:
                    type: string
                    enum:
                      - limit_exceeded
                  error_code:
                    type: string
                    enum:
                      - limit_exceeded
                  message:
                    type: string
        "429":
          description: Too many jobs already running for this account.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - error
                  error:
                    type: string
                    enum:
                      - too_many_active_jobs
                  message:
                    type: string
        "500":
          $ref: "#/components/responses/InternalServerError"
components:
  schemas:
    ExtractionSchema:
      type: object
      description: Custom extraction schema defining the fields to extract. Max 10 root-level fields, max 3 nesting levels. Each field must have `type` and `description`.
      additionalProperties:
        type: object
        required:
          - type
          - description
        properties:
          type:
            type: string
            enum:
              - String
              - Number
              - Boolean
              - Integer
              - Object
              - Array
              - Enum
            description: The data type of the field
          description:
            type: string
            description: Description of what this field should contain
          properties:
            type: object
            description: Sub-fields for Object type
          items:
            type: object
            description: Item schema for Array type
          enum:
            type: array
            items:
              type: string
            description: Allowed values for Enum type. The extracted value is always one of these. `values` is accepted as a legacy alias.
      example:
        main_topics:
          type: Array
          description: List of main topics discussed
          items:
            type: String
            description: A topic
        sentiment:
          type: Enum
          description: Overall sentiment of the video
          enum:
            - positive
            - negative
            - neutral
        key_takeaway:
          type: String
          description: The single most important takeaway
    AsyncJobAccepted:
      type: object
      description: 202 response from an async submit endpoint.
      properties:
        status:
          type: string
          enum:
            - success
        data:
          type: object
          properties:
            task_id:
              type: string
              description: Identifier to poll with.
              example: 550e8400-e29b-41d4-a716-446655440000
            task_status:
              type: string
              enum:
                - processing
            job_type:
              type: string
              enum:
                - transcribe
                - extract_video
                - tweet_statement
                - watch
            expires_at:
              type: string
              format: date-time
              description: Results are deleted after this time. Until the job finishes this is a provisional submit-time bound; on completion it is pushed out to finish time + 1 hour.
            check_status_url:
              type: string
              description: Relative URL to poll for status and the result.
              example: /v1/transcribe/550e8400-e29b-41d4-a716-446655440000
            webhook_url:
              type: string
              nullable: true
              description: The URL this job's result will be POSTed to, or null if no webhook applies.
            message:
              type: string
            docs_url:
              type: string
  responses:
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              error:
                type: string
                enum:
                  - metadata_fetch_failed
                  - audio_extraction_failed
                  - transcription_failed
                  - internal_server_error
              message:
                type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key authentication. Include your VidNavigator API key in the X-API-Key header.
````
