Skip to main content

Overview

Webhooks allow ElevenLabs to send real-time notifications to your application when certain events occur. This is useful for:
  • Receiving notifications when audio generation is complete
  • Tracking usage and billing events
  • Monitoring voice cloning progress
  • Staying informed about account changes

Setting Up Webhooks

Configure Your Endpoint

First, create an endpoint in your application to receive webhook events:

FastAPI Example

Webhook Signature Verification

The SDK provides the construct_event method to verify webhook signatures and prevent unauthorized requests.

How It Works

ElevenLabs signs each webhook with a secret key and includes:
  • A timestamp (t=) to prevent replay attacks
  • A signature hash (v0=) to verify authenticity
str
required
The raw webhook request body as a string. Do not parse it as JSON first.
str
required
The elevenlabs-signature header from the webhook request.
str
required
Your webhook secret from the ElevenLabs dashboard.

Verification Errors

The construct_event method raises BadRequestError for the following issues:
The elevenlabs-signature header was not included in the request.
No secret was provided to the verification function.
The signature header doesn’t contain the expected t= and v0= components.
The webhook timestamp is older than 30 minutes, indicating a potential replay attack.
The computed signature doesn’t match the provided signature.

Security Best Practices

Always verify signatures

Never process webhook events without verifying the signature first.

Use HTTPS

Only accept webhooks over HTTPS to prevent man-in-the-middle attacks.

Keep secrets secure

Store webhook secrets in environment variables, not in code.

Handle replay attacks

The 30-minute timestamp tolerance helps prevent replay attacks.

Processing Webhook Events

Once verified, process the webhook payload based on the event type:

Async Webhook Handling

The async client also supports webhook verification:
The construct_event method is synchronous even when using AsyncElevenLabs because it only performs local computation (HMAC verification). No API calls are made.

Complete Example

Here’s a complete webhook handler with proper error handling:

Testing Webhooks

During development, use tools like ngrok to expose your local server:
Use ngrok or a similar tool to test webhooks locally without deploying to a server.

Webhook Response Guidelines

Always return a 200 status code when the webhook is processed successfully, even if your business logic encounters non-critical errors.
Return 400 when signature verification fails to indicate a client error.
ElevenLabs will retry failed webhooks. Make your endpoint idempotent to handle duplicate events.
Process webhooks asynchronously if needed. Respond within 30 seconds to avoid timeouts.
Important: Always use the raw request body for signature verification. Parsing it as JSON first will cause verification to fail due to formatting differences.

Troubleshooting

Signature Verification Fails

  1. Ensure you’re passing the raw request body, not parsed JSON
  2. Check that your webhook secret matches the one in your dashboard
  3. Verify the signature header is being read correctly
  4. Check server time synchronization (timestamp tolerance is 30 minutes)

Missing Signature Header

Testing Signature Verification

Next Steps

Error Handling

Learn about webhook-specific error handling

Async Client

Use webhooks with async frameworks