Webhooks
Webhooks
Erhalten Sie Echtzeit-Benachrichtigungen, wenn Aufgaben abgeschlossen sind oder fehlschlagen.
Übersicht
Webhooks allow you to receive HTTP callbacks when your image or video generation tasks complete. Instead of polling for results, you can set up a webhook endpoint to receive automatic notifications.
Verfügbare Veranstaltungen
- job.completedTriggered when a task completes successfully
- job.failedTriggered when a task fails
API-Endpunkte
GET
/api/v1/webhooksList all your webhook configurations
Antwortbeispiel:
{
"success": true,
"data": [
{
"id": 1,
"url": "https://your-server.com/webhook",
"events": ["job.completed", "job.failed"],
"status": "active"
}
]
}POST
/api/v1/webhooksCreate a new webhook endpoint
Beispielanfrage:
{
"url": "https://your-server.com/webhook",
"events": ["job.completed", "job.failed"],
"secret_key": "your-secret-key"
}Parameter:
urlstringErforderlichYour webhook endpoint URL
eventsstring[]ErforderlichEvents to subscribe to
secret_keystringOptionalSecret for signature verification
Antwortbeispiel:
{
"success": true,
"data": {
"id": 1,
"url": "https://your-server.com/webhook",
"events": ["job.completed", "job.failed"],
"status": "active"
}
}DELETE
/api/v1/webhooks/{id}Delete a webhook endpoint
Antwortbeispiel:
{
"success": true,
"data": { "id": 1 }
}Webhook-Payload
Format der Webhook-Benachrichtigungen, die an Ihren Endpunkt gesendet werden
| Kopfzeile | Beschreibung |
|---|---|
| X-Nano-Timestamp | Unix timestamp of the request |
| X-Nano-Signature | HMAC-SHA256 signature for verification |
Beispiel-Nutzlast:
{
"id": "job.completed:task_xxx",
"type": "job.completed",
"created_at": 1734948000,
"data": {
"task_id": "task_xxx",
"model": "veo3",
"status": "completed",
"video_url": "https://cdn.example.com/video.mp4"
}
}Signaturprüfung
const crypto = require('crypto');
function verifySignature(rawBody, signature, secret, timestamp) {
const message = `${timestamp}.${rawBody}`;
const expectedSig = crypto
.createHmac('sha256', secret)
.update(message)
.digest('hex');
return `v1=${expectedSig}` === signature;
}