Skip to main content
To integrate our Webhook service into your system, you need to provide a Webhook URL, a specific endpoint where we will send notifications when a video generation task completes. Each notification requires a signature to verify the data’s security and authenticity.

1. Getting Your Secret Key

You need a Secret key for signature verification. Follow these steps to get it:
  1. Go to the Webhook page and create a new webhook key.
  2. On the Webhook page, create a new webhook key.
  3. Copy and save this key. It will be used as the secret for verifying Webhook signatures.

2. Steps to Integrate Webhooks

  1. Configure Your Webhook URL In your video generation API request Post, provide your webhookUrl, for example:
    Please note that input is video generation parameters, which vary by model and should not be changed.
  2. Verify Webhook Signatures Each Webhook message will include the following HTTP header, which you need to use to verify the authenticity of the message:
    • X-Webhook-Id:A unique identifier for the Webhook message.
    • X-Webhook-Timestamp:The timestamp of when the message was sent.
    • X-Webhook-Signature:A Base64 encoded signature that you need to use to verify that the message has not been tampered with.
  3. Signature Algorithm The signature for the Webhook message is calculated using the HMAC-SHA-256 algorithm. Here’s how it works:
    • The content to be signed consists of webhook_idwebhook_timestamp and the request body,each separated by .
    • Use the Base64 encoded Secret along with the content to calculate the HMAC-SHA-256 signature.
    Code Implementation:
  4. Signature Verification Compare X-Webhook-Signature with computedSigBase64 to ensure the message’s signature is correct. The verification code is as follows:
  5. Event Notification Structure The structure of the event notification sent by the Webhook is as follows:
    • taskId: A unique identifier for the task.
    • status: The status of the task, which can be either succeed or failed.
  6. Retry Mechanism If the received Webhook notification shows a processing failure, the system will automatically retry. The retries will be performed at certain intervals, up to a maximum of 10 attempts. If all attempts fail, the system will stop retrying until you intervene manually.

3. Example Code

3.1 Using JavaScript to Integrate Webhook

3.2 Using Python to Integrate Webhook