1. Getting Your Secret Key
You need a Secret key for signature verification. Follow these steps to get it:- Go to the Webhook page and create a new webhook key.
- On the Webhook page, create a new webhook key.
- Copy and save this key. It will be used as the
secretfor verifying Webhook signatures.
2. Steps to Integrate Webhooks
-
Configure Your Webhook URL
In your video generation API request Post, provide your
webhookUrl, for example:Please note thatinputis video generation parameters, which vary by model and should not be changed. -
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.
-
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_id、webhook_timestampand the requestbody,each separated by. - Use the Base64 encoded Secret along with the content to calculate the HMAC-SHA-256 signature.
- The content to be signed consists of
-
Signature Verification
Compare
X-Webhook-SignaturewithcomputedSigBase64to ensure the message’s signature is correct. The verification code is as follows: -
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 eithersucceedorfailed.
- 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.