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

Published · Updated

This guide covers the problems Truework webhooks cause in production and how to handle each one. What Truework sends is on the Truework webhooks overview, both events and their example payloads are on Truework webhook events, and the token check is on Verify Truework webhooks.

Truework documents periodic retries over 48 hours, failure emails and possible duplicates. It doesn't publish a timeout, a retry interval or an event ID, so this guide says so where those matter.

At a glance

ProblemWhat to doWith Event Gateway
TimeoutsReturn a 200 once the token checks out; process in a background jobAccepts the delivery at once, then queues it for your service
DuplicatesBuild a key from the event, order, verification request and stateCan drop repeats before they reach your handler
OrderingCompare hook.triggered_at, and read the order from the APILogs every event, so you can see what arrived when
RetriesAnswer 200, watch the failure emails, reconcile after long outagesAccepts deliveries while your service is down and replays them
Choosing eventsMatch the event to your verification method; answer 200 to the restFilters and routes on hook.event and data.state
TestingCreate Sandbox orders with Truework's test SSNsForwards to localhost and replays past events
Other limitsKeep tokens in step, log version, accept both state spellingsChecks the token on every request

Truework webhook timeouts and slow handlers

Truework publishes no response timeout. Check the token, store the body and return a 200 straight away, then do the rest in a background job.

Why it happens: Truework retries webhooks that fail but doesn't say how long it waits or what it counts as a failure. A handler that fetches the order before it responds could count as a failure, and there's no number to design against.

Fix it in your handler:

  1. Check X-Truework-Token, store the body and return a 200.
  2. Fetch the order from a worker. See why to process webhooks asynchronously.
  3. Keep calls to the Truework API and other services out of the request path. The API allows 10 requests per second by default, per IP address and per account, so a burst of deliveries that each fetch an order can hit 429.

With Event Gateway: Hookdeck accepts each Truework delivery as it arrives, then queues it and delivers it to your service with its own retries. Your handler's speed no longer affects how Truework sees the delivery.

Truework webhook duplicates

Truework can send an event more than once, and says handlers should be idempotent. It documents no event ID or delivery header, so you have to build the key yourself.

Why it happens: Truework says duplicates are possible but not when they happen. hook.id is the ID of the webhook, so every delivery from one webhook shares it and it can't identify a repeat.

Fix it in your handler:

  1. Build a key from hook.event, data.order_id, data.verification_request_id and data.state. On order.completed, the event and order ID are enough.
  2. Store the key before you process, in the same transaction as your write. See our guide to webhook idempotency.
  3. Allow for IDs of up to 255 characters. Truework says that's the maximum and that their format can change.

With Event Gateway: Deduplication can compare the fields you choose, such as data.order_id and data.state, and drop repeats within a time window before they reach your handler.

Truework webhook ordering

Truework doesn't document a delivery order. Treat a state change as a prompt to read the order, and don't let an older state overwrite a newer one.

Why it happens: A verification request can pass through several states, each with its own webhook, and failed webhooks are retried for up to 48 hours. A retried delivery could arrive after one for a later state.

Fix it in your handler:

  1. Store hook.triggered_at for each verification request, and skip a delivery older than the one you've stored.
  2. Read the current state from GET /orders/{order_id}, whose verification_requests list shows each request's state, before you act on anything final.
  3. Don't wait for a particular sequence of states. Handle completed and canceled whenever they arrive.

With Event Gateway: Hookdeck logs every event and attempt, so you can see the order things arrived in when you're debugging.

Truework webhook retries and failures

Truework retries failed webhooks periodically over 48 hours and emails your service account about webhooks that fail to send. The interval isn't documented, and neither is any way to resend a delivery.

Why it happens: Retries end after 48 hours, so a longer outage can leave you without those updates. The failure notice goes to the service account's email address, which may not be one anyone watches.

Fix it in your handler:

  1. Return a 200 for anything you've stored, including events you don't handle.
  2. Make sure the service account's email reaches someone who will act on it.
  3. After a longer outage, list orders with GET /orders and read the ones you haven't closed. GET /orders/{order_id}/events returns all the events on an order.

With Event Gateway: Hookdeck accepts Truework's deliveries while your service is down and keeps them, so the 48-hour window no longer limits your recovery. Your service gets retries on a schedule you set, and you can replay failed events.

Choosing Truework webhook events

Use order.completed for Credentials and Documents verifications, and verification_request.state.change for Smart Outreach. Instant verifications return results immediately and need no webhook.

Why it matters: order.completed fires once every verification on the order is completed or canceled, which is all most integrations need. The state change event fires on every transition, so it suits an integration that has to react during Smart Outreach, in particular to action-required.

Fix it in your handler:

  1. Route on hook.event, and answer 200 to anything you don't recognise. Truework says that otherwise, adding a subscription can cause errors, retries and failure emails. It also treats new event types as a backwards-compatible change.
  2. On the state change event, act mostly on completed, which means new data is on the order, and canceled, which means the verification couldn't be completed but may still hold information or documents from the applicant.
  3. On action-required, submit the missing information in the Truework app, or have your integration cancel the order if you don't want your users signing in to Truework.

With Event Gateway: Hookdeck filters can match on hook.event and data.state, so only the transitions you act on reach your service.

Testing Truework webhooks

Test against Truework's Sandbox, which has its own webhooks and only accepts test SSNs. A test order sends deliveries to your endpoint.

Why it matters: The state spelling below, the contents of metadata and the version on your subscription are only settled by seeing a delivery. Truework's published examples use placeholder values.

How to test:

  1. Create a webhook under Sandbox in developer settings, with its own stored token.
  2. Create an order with SSN 000-00-0000, which Truework's quickstart uses. It completes at once and fires order.completed.
  3. To see action-required, subscribe to verification_request.state.change, create a Smart Outreach order with 000-03-0000, and log data.state. The rest are in Truework's Sandbox test cases.
  4. Allow for slower results in Production. Truework warns that Credentials test cases process instantly in Sandbox, while payroll logins don't.

With Event Gateway: The Hookdeck CLI receives webhooks on your machine without a public server, and you can replay past events to your handler as you change it.

Other Truework webhook limits

These don't need a section each, but each can break a handler in production.

A static token. The token travels with every request, and no signature or timestamp is sent, so nothing protects the body and a captured request can be replayed. Keep the endpoint on HTTPS, allowlist Truework's source IP addresses where your network allows it, and read the order from the API before you act on a delivery.

Recreated webhooks. Tokens belong to webhook instances, so a new webhook for the same URL gets a different token. Update your stored token when you recreate one, and use the optional description to tell webhooks apart.

Version upgrades. Subscriptions are tied to a version of the event. New ones only get the latest version, upgrades can't be undone, and version is the only field Truework says is consistent across versions. Log version on every delivery, and test an upgrade in Sandbox before you apply it in Production.

State spelling. Truework's overview, quickstart and test cases spell the state action-required, while the event reference lists action-requred. No page shows which one is sent, so accept both until you've seen a delivery, and alert on any state you don't recognise.

A limit of ten webhooks. A service account can have ten webhooks in total. One webhook can subscribe to several event types, so you rarely need one per event.

With Event Gateway: Hookdeck's Truework source type compares the token you enter with X-Truework-Token, and records a request with a missing or wrong token as failed verification, so it creates no event. Give each Truework webhook its own source, because each has its own token.

Keep an outage from outlasting Truework's 48-hour retries.

Event Gateway checks the webhook token, accepts each Truework delivery as it arrives and queues it, so your service can catch up after an outage and retries run on your schedule.

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