This guide covers webhooks for streaming audio
transcription. For webhooks with pre-recorded audio, see
Webhooks for pre-recorded audio.
Configure webhooks for a streaming session
To use webhooks with streaming speech-to-text, add the following parameters to your WebSocket connection URL:Example WebSocket URL with webhook parameters
Add the webhook parameters as query parameters to the WebSocket URL:- Python
- Python SDK
- JavaScript
- JavaScript SDK
Handle webhook deliveries
When the streaming session ends, AssemblyAI sends aPOST HTTP request to the URL you specified. The webhook contains the complete transcript from the session.
Your webhook endpoint must return a 2xx HTTP status code within 10 seconds to indicate successful receipt. If a 2xx status is not received within 10 seconds, AssemblyAI will retry the webhook call up to a total of 10 attempts. If at any point your endpoint returns a 4xx status code, the webhook call is considered failed and will not be retried.
Static Webhook IP addressesAssemblyAI sends all webhook deliveries from fixed IP addresses:
Delivery payload
The webhook delivery payload contains the complete transcript from the streaming session as a JSON object. The payload includes the session ID and an array of messages containing all the transcript turns.Authenticate webhook deliveries
To secure your webhook endpoint, you can include custom authentication headers in the webhook request. When configuring your streaming session, provide thewebhook_auth_header_name and webhook_auth_header_value parameters.
AssemblyAI will include this header in the webhook request, allowing you to verify that the request came from AssemblyAI.
Best practices
When implementing webhooks for streaming speech-to-text, consider the following best practices:- Always verify authentication: If you configure an authentication header, always verify it in your webhook receiver to ensure requests are from AssemblyAI.
- Respond quickly: Return a response from your webhook endpoint as quickly as possible. If you need to perform time-consuming processing, do it asynchronously after returning the response.
- Handle failures gracefully: Your webhook endpoint should handle errors gracefully and return appropriate HTTP status codes.
- Use HTTPS: Always use HTTPS for your webhook URL to ensure the transcript data is encrypted in transit.
- Log webhook deliveries: Keep logs of webhook deliveries for debugging and auditing purposes.