# Oyster webhooks in production: duplicates, ordering, retries and timeouts

Agent skill: `npx skills add hookdeck/webhook-skills --skill oyster-webhooks` ([details](https://hookdeck.com/webhooks/oyster/skill))

This guide covers the problems Oyster webhooks cause in production and how to handle each one. What Oyster sends and how endpoints are registered is on the [Oyster webhooks](/webhooks/oyster) overview, every event type is on [Oyster webhook events](/webhooks/oyster/events), and the header check is on [Verify Oyster webhooks](/webhooks/oyster/verify).

## At a glance

| Problem | What to do | With Event Gateway |
| --- | --- | --- |
| [Timeouts](#timeouts) | Answer with a `200` within 5 seconds; process in a background job | Answers Oyster on arrival, then queues the event for your service |
| [Duplicates](#duplicates) | Record each `id`; make handlers idempotent | Can drop repeats before they reach your handler |
| [Ordering](#ordering) | Compare `eventTimestamp`, or re-fetch the record | Logs every event, so you can see what arrived when |
| [Retries](#retries) | Stay available; check dispatches and reconcile after an outage | Accepts deliveries while your service is down and replays them |
| [Choosing events](#choosing-events) | Filter on `eventName` in your handler | Filters and routes events by type |
| [Testing](#testing) | Use the test endpoint and the developer sandbox | Forwards to localhost and replays past events |
| [Other limits](#other-limits) | Treat the secret as the only credential; keep the endpoint ID | Checks the shared secret and keeps Oyster's URL stable |

## Oyster webhook timeouts and slow handlers {#timeouts}

Answer with a `200` within 5 seconds, then do the work in a background job.

**Why it happens:** Oyster requires a `200` inside its 5-second timeout. Without one, it counts the dispatch as failed and tries again later. A handler that updates an HRIS or payroll system before responding can miss that window. Oyster's docs name only `200`, so don't rely on another success code such as `202` or `204`.

**Fix it in your handler:**

1. Check the `Authorization` header, store the event and return `200` straight away.
2. Process the event in a background job. See [why to process webhooks asynchronously](/webhooks/guides/why-implement-asynchronous-processing-webhooks).
3. Return `200` for events you ignore too, so they aren't retried.

**With Event Gateway:** Hookdeck answers Oyster as soon as each webhook arrives and stores it, then delivers it to your service on your own schedule and timeout, so slow processing doesn't cause retries.

## Duplicate Oyster webhooks {#duplicates}

Oyster says webhooks may be delivered more than once and that your endpoint should be idempotent. Record each `id` you process and skip repeats.

**Why it happens:** Retries run for about 48 hours, and a handler can finish its work and still miss the 5-second window, so Oyster sends the event again. The `id` is globally unique per notification and always prefixed `wh_`. Oyster doesn't state outright that a retry keeps its `id`, but its dispatch records show a single `id` with `firstSentAt`, `sentAt` and `retries`.

**Fix it in your handler:**

1. Store each `id` before processing, in a table with a unique constraint.
2. Make every handler [idempotent](/webhooks/guides/implement-webhook-idempotency): the same result however many times it runs.
3. If several developer applications feed one system, don't deduplicate across them on `id`. Each application gets a different `id` for the same event, so key on `eventName` and the IDs in `data` instead.

**With Event Gateway:** Hookdeck can [deduplicate](/docs/deduplication) events before they reach your endpoint, so repeats are filtered at the infrastructure level rather than in each handler.

## Out-of-order Oyster webhooks {#ordering}

Oyster doesn't document an ordering guarantee. Compare `eventTimestamp` with the state you last stored, or re-fetch the record.

**Why it happens:** Retries over 48 hours mean an older event can land after a newer one. A retried `time_off.request_created` can arrive after the matching `time_off.request_status_changed`. Oyster says `eventTimestamp` is when the event occurred, in ISO 8601 UTC, and that you can use it for ordering events and debugging delayed deliveries.

**Fix it in your handler:**

1. Store the `eventTimestamp` of the last event you applied to each record.
2. Skip an event older than that, unless it records something you still need.
3. Re-fetch the record from the Oyster API when order matters. `data` mostly holds IDs and a few status fields, so you often need the API anyway.

**With Event Gateway:** Every webhook is stored in Hookdeck with its body and arrival time, so you can see what arrived when, and replay events after fixing your handler.

## Oyster webhook retries {#retries}

Oyster makes up to 9 attempts in total over about 48 hours. It doesn't document what happens after the last one.

**Why it happens:** After a failed delivery, Oyster retries on an increasing schedule: 30 seconds, 5 minutes, 30 minutes, 1 hour, 3 hours, 6 hours, 12 hours and 1 day, with a small random jitter. An outage longer than that can lose events. Oyster describes no way to resend a dispatch, and doesn't say whether repeated failures disable an endpoint, although the endpoint object has an `enabled` field.

**Fix it in your handler:**

1. Keep the endpoint available through deploys, so retries are the exception.
2. After an outage, call `GET /v1/webhooks/dispatches`, which lists each dispatch's `lastResponseCode` and `retries` for your Developer Application.
3. Re-read the affected records from the Oyster API, since you can't ask for a dispatch again.
4. Check `enabled` with `GET /v1/webhooks` if deliveries stop.

**With Event Gateway:** Hookdeck accepts Oyster's deliveries while your service is down and keeps them, so you can replay them when it's back rather than depending on Oyster's 48-hour schedule.

## Choosing which Oyster events to handle {#choosing-events}

Creating an endpoint takes only a `url` and a `sharedSecret`, with no list of events, so filter on `eventName` in your handler.

**Why it matters:** Oyster documents 97 event types: 96 across 12 namespaces such as `hiring` and `payments`, plus `async_operation_completed`, which has no namespace. Its docs present `eventName` as the way to filter for the events you care about. The full list is on [Oyster webhook events](/webhooks/oyster/events).

**Fix it in your handler:**

1. Split `eventName` on the first dot and route by namespace, so new events in a namespace you already handle reach the right code.
2. Allow for names without a dot, because Oyster says only that names will usually have a namespace.
3. Return `200` for anything you don't handle.

**With Event Gateway:** Hookdeck [filters](/docs/filters) and routes events by type or any other property, so one Oyster endpoint can feed several services and each gets only what it handles.

## Testing Oyster webhooks {#testing}

Send test payloads with Oyster's test endpoint, and build against its developer sandbox.

**Why it matters:** Oyster's event reference pages give a schema for each event, with `data` key names and types, but no example body. You have to build fixtures from those schemas, or from what you receive.

**Test your handler:**

1. Request a developer sandbox account. It comes with seed data and has its own API at `https://api-sandbox.oysterhr.com`.
2. Register an endpoint there, then call `POST /v1/webhooks/{id}/test` with a `data` object of at least one property.
3. Handle names you don't recognise. Oyster's dispatch examples use the `eventName` `test.webhook`, which isn't in the event list.
4. When you move to production, create a production Developer Application, tokens and endpoint.

**With Event Gateway:** The [Hookdeck CLI](/docs/cli) receives webhooks on your machine without a public server, and you can replay past events to your handler as you change it.

## Other Oyster webhook limits {#other-limits}

Plan for a static secret, endpoints you can only manage through the API, and no published IP addresses.

**A bearer secret, not a signature.** Oyster repeats the same bearer value on every request and computes nothing over the body. Anyone who learns the secret can send convincing HR events, such as an approved expense or a terminated engagement, and a captured request passes the check again. Use a long random secret and HTTPS only, keep the header out of logs, and re-read sensitive records from the API using the IDs in `data`.

**Secret rotation.** Update the secret with `PATCH /v1/webhooks/{id}`, then update your receiver, and accept both values briefly while retries drain. The API returns the secret in the endpoint object, so limit who holds a token that can read your endpoints.

**No dashboard for endpoints.** Oyster's docs describe creating, updating and deleting endpoints only through the API, using the ID returned at creation. Store that ID with your configuration, next to the secret. `GET /v1/webhooks` lists your endpoints if you lose it.

**No published IPs.** Oyster names no source IP addresses, so you can't allowlist them.

**Partners.** Partners receive events for many customers. Look up the customer by `companyId` before doing anything else.

**With Event Gateway:** Create a source with the Oyster type and enter your `sharedSecret` in its **Shared Secret** field, with or without the `Bearer ` prefix. Hookdeck answers Oyster with a `200` either way, then records a request without the right secret as failed verification, so it never reaches your destination. The URL Oyster holds also stays the same while you move or change the service behind it, so most changes don't need an Oyster API call.