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

> ## Agent Instructions
> Five API is a video generation REST API. Base URL: https://api.fiveapi.ai. Authenticate with the header Authorization: Bearer <API key>; read the key from the FIVEAPI_API_KEY environment variable and never hard-code it.
> Every generation is an asynchronous task: POST /v1/{brand}/{version}/{task} returns a queued task, then poll GET /v1/tasks/{task_id} or receive a signed webhook, and download output.video.url before expires_at (7 days).
> The OpenAPI spec is at https://docs.fiveapi.ai/api-reference/openapi.yaml. An installable agent skill: npx skills add https://docs.fiveapi.ai

# Production checklist

> What a robust Five API integration does before it goes live.

Use this list before you launch, and again when you change your integration.

## Security

> [!TIP]
>
> API keys live on your servers only, loaded from environment variables or a secret manager, never in client code.

> [!TIP]
>
> Each environment (production, staging, CI) has its own key, with the smallest set of [scopes](https://testweb2-docs-openapi.test765.com/authentication.md#scopes) it needs.

> [!TIP]
>
> Keys used from fixed servers carry an IP allowlist.

> [!TIP]
>
> You know how to [rotate a key](https://testweb2-docs-openapi.test765.com/authentication.md#rotate-or-revoke-a-key) without downtime.

## Creating tasks

> [!TIP]
>
> Every create request sends an [`Idempotency-Key`](https://testweb2-docs-openapi.test765.com/concepts/idempotency) derived from your own job id, and retries reuse it with the identical body.

> [!TIP]
>
> You retry `429` and `503` after `Retry-After`, `500` and network errors with backoff, and never retry other `4xx` errors.

> [!TIP]
>
> You store the task `id` as soon as the create call returns.

> [!TIP]
>
> `metadata` carries your own ids (order, user, job) so webhook handlers can route events without a lookup.

> [!TIP]
>
> Input files are served over public HTTPS from storage that answers `HEAD`, and presigned URLs stay valid for at least an hour.

## Getting results

> [!TIP]
>
> A webhook endpoint (default or per task) receives events in production; polling is only a fallback, with backoff.

> [!TIP]
>
> The webhook handler verifies the signature over the raw body, rejects old timestamps, and de-duplicates on `webhook-id`.

> [!TIP]
>
> The handler answers `2xx` within 10 seconds and processes the event asynchronously.

> [!TIP]
>
> You download `output.video.url` to your own storage on `task.completed`, well before `expires_at` (7 days).

> [!TIP]
>
> A periodic job reconciles tasks that are still open on your side by calling `GET /v1/tasks/{task_id}`.

## Failures and limits

> [!TIP]
>
> You handle `failed` tasks by `error.code`, and resubmit only when `error.retryable` is true, with a new idempotency key.

> [!TIP]
>
> Your own queue keeps queued + processing tasks below `plan.max_concurrent_tasks`.

> [!TIP]
>
> You watch `X-RateLimit-Remaining` and slow down before it reaches zero.

> [!TIP]
>
> You cancel tasks whose results you no longer need, which frees the slot and the credits at once.

## Credits and monitoring

> [!TIP]
>
> A [low-balance reminder](https://testweb2-docs-openapi.test765.com/pricing.md#low-balance-reminder) is set on the **Billing** page, so a top-up happens before tasks start failing with `402`.

> [!TIP]
>
> You log the `X-Request-Id` of every failed request, and include it when you contact support.

> [!TIP]
>
> You track your spend with `GET /v1/account/usage` or the console's usage page.


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