# Async tasks

> Submit image and video tasks, then poll for the result or receive a callback.

> **Note** This feature is not available yet. The content below describes how it will work at launch.

Image and video generation runs as async tasks: submit, get a `task_id`, then poll for the result or receive a callback.

## Endpoints

| Method | Path | Description |
| --- | --- | --- |
| `POST` | `/v1/images/generations` | Submit an image task |
| `POST` | `/v1/video/generations` | Submit a video task |
| `GET` | `/v1/tasks/{task_id}` | Task status and result |

## States

`pending`, `processing`, `completed`, `failed` or `cancelled`. A completed task returns file URLs with `expires_at`. Only the team member who created the task, or an admin of the same account, can see it; anyone else gets 404.

## Callbacks

Pass `callback_url` when submitting and Relayvia POSTs the result there, with `X-Robi-Timestamp`, `X-Robi-Event-Id` and `X-Robi-Signature`, an HMAC-SHA256 of the timestamp, event id and body made with your account's callback secret. Reject requests more than 5 minutes old or with a repeated event id. Failed callbacks are retried 3 times.

## Charges and retention

Tasks are charged when submitted and corrected when they finish: any difference is charged or refunded, and failed or cancelled tasks are refunded in full. Result files are kept for 24 hours and download URLs are valid for 1 hour.
