Webhook

What is Webhook

Token360 can POST to your HTTPS endpoint when an asynchronous job reaches a terminal state, so you do not have to poll continuously.

Videocallback_url on POST /v1/videoscompleted / failed
Batch jobscallback_url on POST /v1/batches, or account default in console Batch jobs → Webhookcompleted / failed / cancelled / expired
Async ChatNot supported. Poll GET /v1/async/chat/completions/{job_id}. For many lines with a callback, use Batch Jobs.

Use webhooks when your application needs to react in the background (update an order, persist output URLs, notify a user).

How to Enable Webhook

When calling POST /v1/videos, include two fields:

  • callback_url: your HTTPS endpoint that receives the POST callback.
  • request_id: your business ID, such as an order ID. Token360 echoes this value in the callback envelope so you can match the callback to your local record.
Shell
1curl -X POST https://api.token360.ai/v1/videos \
2  -H "Authorization: Bearer sk-your-api-key" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "model": "seedance-2.5",
6    "prompt": "A paper crane unfolds into a real bird and flies away.",
7    "resolution": "480p",
8    "duration": 5,
9    "aspect_ratio": "16:9",
10    "generate_audio": false,
11    "callback_url": "https://your-app.example.com/webhooks/video",
12    "request_id": "your-order-id-001"
13  }'

If callback_url is omitted, no callback fires and you must poll GET /v1/videos/{video_id} yourself.

When the Callback Fires

  • Token360 sends the callback once when the video task reaches a terminal state: completed or failed.
  • Intermediate states, such as queued and in_progress, do not trigger callbacks.
  • A given video task delivers at most one successful callback. If all delivery attempts fail, Token360 gives up.

Retry and Timeout

  • Per-attempt timeout: 30 seconds.
  • Maximum attempts: 3 total attempts, including the first delivery.
  • Retry backoff intervals: 1 second before the second attempt, then 3 seconds before the third attempt.
  • Any 2xx response stops retrying and marks delivery as successful.
  • After following redirects, any final non-2xx response triggers a retry. A redirect chain that resolves to 2xx is treated as successful.
  • After 3 failed attempts, Token360 gives up and does not redeliver. Use GET /v1/videos/{video_id} to recover the final state if needed.

Idempotency

  • A given video task id delivers at most one successful callback.
  • If you reuse the same request_id across multiple video tasks, each task can still deliver its own callback.
  • Network conditions may still produce rare duplicate deliveries during retry.
  • Implement your endpoint idempotently, for example by deduplicating on id and status.

Video Callback Request

Authentication

The POST request that Token360 sends to your callback_url carries no authentication headers. Protect your receiving endpoint by:

  • Exposing only HTTPS.
  • Using an unguessable random path, or embedding a verification token in the callback URL.
  • Checking request_id against your local records before acting on the payload.

Request Body

idstringrequired

Video task ID. This matches the id returned by the submit response.

statusenum<string>required

Terminal state of the video task.

payloadobjectrequired

Full video object. It matches the response from GET /v1/videos/{video_id}, including id, object, status, model, prompt, url, video_url, duration, parameters, content, usage, and error fields when available.

request_idstring

Business ID echoed from the video creation request. Omitted when not provided.

errorobject | null

Error details. Present only when status is failed.

error.codestring

Provider or platform error code.

error.messagestring

Human-readable error message.

Response

status_codeintegerrequired

Return any 2xx HTTP status code to acknowledge delivery. After following redirects, any final non-2xx response triggers a retry.

bodyany

Optional response body. Token360 ignores the body content.

Request

JSON
1{
2  "id": "video_b5c3cb639d804319b1015025",
3  "request_id": "your-order-id-001",
4  "status": "completed",
5  "payload": {
6    "id": "video_b5c3cb639d804319b1015025",
7    "object": "video",
8    "status": "completed",
9    "model": "seedance-2.5",
10    "prompt": "A paper crane unfolds into a real bird and flies away.",
11    "created_at": 1778197436,
12    "updated_at": 1778197510,
13    "duration": 5,
14    "resolution": "480p",
15    "ratio": "16:9",
16    "parameters": {
17      "duration": 5,
18      "resolution": "480p",
19      "aspect_ratio": "16:9",
20      "video_mode": "text_to_video"
21    },
22    "url": "https://media.token360.ai/v-b5c3cb639d804319b1015025/2026/05/...mp4?Expires=...&Signature=...",
23    "video_url": "https://media.token360.ai/v-b5c3cb639d804319b1015025/2026/05/...mp4?Expires=...&Signature=...",
24    "content": {
25      "video_url": "https://media.token360.ai/v-b5c3cb639d804319b1015025/2026/05/...mp4?Expires=...&Signature=...",
26      "last_frame_url": null,
27      "file_url": null
28    },
29    "usage": {
30      "completion_tokens": 50638,
31      "total_tokens": 50638
32    }
33  }
34}

Response

Reply with any final 2xx response to acknowledge delivery. Reply quickly, within 30 seconds, to avoid retries.

JSON
1{
2  "status_code": 204,
3  "body": null
4}

Batch job webhooks

Batch jobs fire when the job reaches a terminal state (completed, failed, cancelled, expired). Delivery is the same for execution=platform and execution=provider.

How to enable

  • Per job: pass callback_url on POST /v1/batches (HTTPS; Token360 rejects private/loopback URLs).
  • Account default: console Batch jobs → Webhook (URL + optional signing secret).

If both are set, the per-job callback_url wins. If neither is set, no callback fires — poll GET /v1/batches/{batch_id}.

Shell
1curl -X POST https://api.token360.ai/v1/batches \
2  -H "Authorization: Bearer sk-your-api-key" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "input_file_id": "file_abc123",
6    "endpoint": "/v1/chat/completions",
7    "completion_window": "24h",
8    "execution": "platform",
9    "callback_url": "https://your-app.example.com/webhooks/batch"
10  }'

Payload

The POST body is the batch object (same fields as GET /v1/batches/{batch_id}) plus event:

eventbatch.completed, batch.failed, batch.cancelled, batch.expired
idBatch ID (batch_…)
statusTerminal status
execution / execution_preference / fallback_from_providerWhich path ran
request_countstotal / completed / failed
output_file_id / error_file_idPresent when files were written
usage_billingAggregated billing after settle (when recorded)

When a signing secret is configured on the account webhook, requests include:

  • Token360-Timestamp — Unix seconds
  • Token360-Signaturesha256= HMAC-SHA256 of {timestamp}.{raw_json_body}

Verify the HMAC before processing. Acknowledge with any 2xx within 10 seconds.

Retries

Up to 3 attempts, 10s timeout per attempt, backoff 1s then 3s. Any 2xx stops retries.

See Batch Jobs and Create batch.

Was this page helpful?