Speechmatics webhooks in production: duplicates, ordering, retries and timeouts

Published · Updated

This guide covers the problems you meet when a Speechmatics batch job calls your endpoint, and how to handle each one. Speechmatics calls these requests notifications, and a job sends them when it finishes.

What Speechmatics sends is on the Speechmatics webhooks overview, and how to check the header is on Verify Speechmatics webhooks.

At a glance

ProblemWhat to doWith Event Gateway
TimeoutsRespond as soon as the notification is stored; process in a background jobAnswers Speechmatics as soon as the notification is stored, then queues it for your service
DuplicatesDeduplicate on the job id and statusDrops exact duplicates before they reach your handler
OrderingKey callbacks by job and content; wait until all you need are presentSmooths bursts and lets you replay any stored callback
RetriesTreat the retry window as short; fetch missed results from the APIAccepts notifications while your service is down and retries on your schedule
Telling notifications apartRoute on status, set contents, branch on Content-TypeFilters on the status query parameter and stores every body as it arrived
TestingUse a public URL that forwards to localhostForwards to localhost and replays past notifications
Other limitsFit your size limit to contents; keep the header in one placeCompares the header and shows what actually arrived

Speechmatics notification timeouts

Return a 2xx as soon as the notification is authenticated and stored, then do the work in a background job. Speechmatics doesn't document how long it waits for a response.

Why it happens: The failure example on the notifications page records a client timeout while waiting for response headers as a failed attempt, so a slow handler can use up retries even when it's working. Handlers that write large files or call an LLM before they respond are the most exposed.

Fix it in your handler:

  1. Check the header, store the notification and return 200. See why to process webhooks asynchronously.
  2. Do the work in a worker, outside the request. For AI pipelines, see Hookdeck for AI agents and LLMs.

With Event Gateway: Hookdeck answers Speechmatics as soon as the notification is stored, then delivers it to your service at a rate it can handle. Your handler can take as long as it needs.

Duplicate Speechmatics notifications

Your endpoint can receive the same notification more than once. Record the job id with the status, plus the content you requested if a job sends several notifications to one endpoint, and skip repeats.

Why it happens: Speechmatics sends the file again after any response that isn't a 2xx, and the failure example shows it retrying after a timeout too. A handler that finished its work but responded late can see the notification again. Speechmatics documents no delivery ID, so the query string is what you have to compare.

Fix it in your handler:

  1. Store each job id and status, with the content type if you need it, under a unique constraint.
  2. Return a 2xx for a repeat without doing the work again.
  3. Make every handler idempotent.

With Event Gateway: Hookdeck's deduplication can drop exact duplicates before they reach your endpoint.

Speechmatics callbacks arrive in any order

Don't assume callbacks from one job arrive in a set order, or that all of them arrive. A step that depends on several of them should wait until everything it needs is present.

Why it happens: A job can send several notifications, for example jobinfo to your application and the transcript to an object store. Speechmatics runs them in parallel, so they can complete in any order, and some may succeed while others fail.

Fix it in your handler:

  1. Key each callback by job ID and content.
  2. Start the dependent step only once everything you need is present.
  3. Fetch any piece that hasn't arrived from the API.

With Event Gateway: A max delivery rate on the destination smooths bursts when many jobs finish at once, and you can replay any stored callback if a downstream step needs to run again. For more on the general problem, see Webhook Ordering: Why It's Hard and How to Handle It.

Speechmatics retries and failed notifications

Plan for a short retry window. Speechmatics retries until it reaches "the set timeout threshold", and its docs give neither the threshold nor the interval, so you can't tell when a notification is lost.

Why it happens: Any response that isn't a 2xx counts as a failed delivery, including a 401 or a 413. The failure example on the docs page shows four attempts over about a minute, then "Sending notification failed". That example dates from 2021, so treat it as an illustration rather than a schedule. Failures are listed in an errors array on GET /jobs/{id}. The transcript is still available from the API, for the 7-day retention period.

Fix it in your handler:

  1. Return a 2xx as soon as the notification is authenticated and stored.
  2. Run a periodic check for finished jobs that never called back, and fetch their results from the API within 7 days.
  3. Watch for repeated 401s after you change the header value, since every job submitted before the change still carries the old one.

With Event Gateway: Hookdeck accepts each notification as it arrives and delivers it to your service with automatic retries on your own schedule. Issues alert you when deliveries fail, and you can replay any stored notification without resubmitting the job.

Telling Speechmatics notifications apart

Speechmatics has no event types to choose from. Route on the status query parameter, set contents on every notification, and branch on Content-Type before you parse.

Why it happens: Each notification answers one job, so the query string carries the outcome and the body carries whatever the entry requested, with no envelope.

statusSent when
successThe job was processed successfully
errorSomething went wrong while processing the job
fetch_errorSpeechmatics couldn't fetch a data file from a URL
trim_errorSpeechmatics couldn't process the audio file before transcription

These aren't the job status values that the jobs API returns (running, done, rejected, deleted, expired), so don't reuse one enum for both.

The body follows these rules, which both Speechmatics docs pages agree on:

contents requestedContent typeBody
One of transcript, transcript.json-v2 or jobinfoapplication/jsonThe JSON item itself
One of transcript.txt or transcript.srttext/plainThe text or SRT transcript
Two or more itemsmultipart/form-dataOne attachment per item

The pages disagree on three other cases, so don't build on either reading until you've seen it in a test:

  • No contents. The notifications page says a notification with no content is only the job ID and status. The API reference says an empty contents gives an empty body, and that leaving the field out sends the transcript as an attachment named data_file.
  • data alone. The notifications page says data is sent as multipart. The API reference says a single item is the raw body, with a content type such as application/octet-stream.
  • A failed job. The notifications page says only jobinfo is sent. The API reference says items that aren't available are omitted and the format rules still apply as if they were all present.

Fix it in your handler:

  1. Always set contents. Use one setting per endpoint where you can, for example ["jobinfo"] for your application and a separate notification for the transcript.
  2. Take the outcome from status, never from the body. Record error, fetch_error and trim_error, check the job's errors from the API, and decide whether to resubmit.
  3. Read Content-Type before you parse, and accept an empty body.

With Event Gateway: Hookdeck stores every notification as it arrived, with its query string, headers and body, so you can see what a job sent. Filters can route on the status query parameter, and transformations can reshape JSON bodies before they reach your service.

Testing Speechmatics notifications locally

Point url at a public URL that forwards to your machine, then submit a short audio file with contents set to ["jobinfo"].

Why it happens: Speechmatics calls your URL from its own cloud, so it can't reach localhost. Notifications also belong to the job, and Speechmatics documents no way to resend one.

How to test it:

  1. Run hookdeck listen 3000 speechmatics --path /webhooks/speechmatics and use the URL it prints as url in notification_config.
  2. Submit a short job with your auth_headers set, and read the request that arrives.
  3. Change contents and submit again to see how the body changes.
  4. Check your server's logs for errors, and GET /jobs/{id} for any failures Speechmatics recorded.

With Event Gateway: The Hookdeck CLI forwards notifications to localhost, and you can replay past ones without submitting another job.

Other Speechmatics limits

A too-small body limit causes retries. If your server's size limit is too low for what you requested, it returns a 413, and Speechmatics keeps retrying. data is the media file you submitted, so it can make a callback very large. Set the limit to fit the largest item you request, or stop requesting data.

Up to 3 URLs per job. Each entry has its own contents, auth_headers and method. The API reference spells the method values post and put, and post is the default, so accept both on your route.

A static header isn't a signature. Speechmatics doesn't sign notifications, so the auth_headers value authenticates the sender but doesn't protect the body or stop a replay. Use HTTPS for the notification URL and keep the value out of logs.

The header lives on each job. A job submitted without auth_headers, from a script or a different service, sends notifications your receiver will reject. Build the job config in one place. To rotate the value, submit new jobs with the new one and accept the old one until jobs already running have called back.

Speechmatics publishes its outgoing IPs. If your network filters inbound traffic, allow the egress addresses for your region. Speechmatics lists EU1, EU2, US1, US2 and AU1. Treat this as a layer alongside the header check.

With Event Gateway: Create a source with the Speechmatics type, and enter the API Key Header and API Key exactly as they appear in auth_headers. For Authorization: Bearer abc123, the Header Value is Bearer abc123. The source accepts both POST and PUT. A request without a matching header is recorded as failed verification and creates no event, so it never reaches your destination, and the stored request shows the headers that actually arrived. Hookdeck's default ingestion limit is 10 MiB, so send transcripts and jobinfo through Hookdeck, and leave data out of contents unless your media files are small.

Get started with Hookdeck for free and handle Speechmatics webhooks reliably in minutes.

Keep an outage on your side from outlasting Speechmatics' retries.

Speechmatics stops retrying at a threshold its docs don't state. Event Gateway checks the header you set on each notification, stores it and retries to your service on your schedule.

Not affiliated with Speechmatics. Facts are compiled from public sources and linked inline.