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

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

This guide covers the problems you meet when Railway sends project webhooks to your endpoint, and how to handle each one. These are the deployment status and alert events Railway sends about a project. To receive other services' webhooks in an app you host on Railway, see [how to receive and replay external webhooks in Railway](/webhooks/platforms/how-to-receive-and-replay-external-webhooks-in-railway-with-hookdeck).

What Railway sends is on the [Railway webhooks](/webhooks/railway) overview and [Railway webhook events](/webhooks/railway/events), and how to check your custom header is on [Verify Railway webhooks](/webhooks/railway/verify).

## At a glance

| Problem | What to do | With Event Gateway |
| --- | --- | --- |
| [Timeouts](#timeouts) | Return within 30 seconds; process in a background job | Answers Railway at once, then queues the event for your service |
| [Duplicates](#duplicates) | Make handlers idempotent, and don't drop repeated crash events | Drops repeats on the fields you choose |
| [Ordering](#ordering) | Read the deployment's current state from the public API | Stores each event it receives, so you can inspect and replay them |
| [Retries](#retries) | Keep the endpoint up, and reconcile after an outage | Your downtime doesn't count against your Railway URL |
| [Choosing events](#choosing-events) | Route on the `type` prefix and filter by environment | Filters and routes on any field in the body |
| [Testing](#testing) | Click **Test Webhook**, then trigger a real deployment | Forwards to localhost and replays past requests |
| [Other limits](#other-limits) | Use a long random custom header over HTTPS | Compares the header you name with the value you enter |

## Railway's 30-second timeout {#timeouts}

Return a response within 30 seconds, then do the work in a background job. [Each delivery attempt has a 30-second timeout](https://docs.railway.com/observability/webhooks#delivery), and a timeout counts as a failure.

**Why it happens:** A handler that opens an incident, calls a paging tool and runs smoke tests before it responds can run past the limit. Railway then retries the event, and the failure counts towards the threshold that pauses your URL.

**Fix it in your handler:**

1. Check the header, store the body and return `200`. See [why to process webhooks asynchronously](/webhooks/guides/why-implement-asynchronous-processing-webhooks).
2. Do the work in a worker, outside the request.

**With Event Gateway:** Hookdeck answers Railway as soon as an event arrives, then delivers it to your service with a [delivery timeout](/docs/destinations#set-a-delivery-timeout) you choose.

## Duplicate Railway events {#duplicates}

Railway doesn't document duplicate deliveries, but a retry can repeat an event you've already handled. Make every handler safe to run twice.

**Why it happens:** If your handler finishes but its response is slow or lost, Railway treats the attempt as failed and retries it. The documented body has no event ID to deduplicate on. Some repeats are also real: Railway's [alerts guide](https://railway.com/guides/alerts-crashes-failed-deploys) treats repeated crash events for the same service as a signal worth paging on, so don't discard them all.

**Fix it in your handler:**

1. Key each event on `resource.deployment.id`, `type` and `timestamp`. Railway doesn't say whether a retry keeps the same `timestamp`, so log a few retries before you rely on it. See our [guide to webhook idempotency](/webhooks/guides/implement-webhook-idempotency).
2. Make the action itself repeatable, for example by updating an open incident for that deployment rather than opening a new one.
3. Count `Deployment.crashed` events for a service over a short window, rather than discarding repeats.
4. Capture a real alert before you choose a key for alerts, because Railway publishes no alert payload.

**With Event Gateway:** Hookdeck [deduplicates](/docs/deduplication) requests before they reach your endpoint, using the fields you choose.

## Out-of-order and missing Railway events {#ordering}

Railway doesn't guarantee delivery or order. Its docs say to [treat a webhook as a prompt to act](https://docs.railway.com/observability/webhooks#delivery), and to reconcile against the [public API](https://docs.railway.com/integrations/api) when you need certainty.

**Why it happens:** Delivery is best-effort, so a later state can arrive before an earlier one and an event can fail to arrive at all.

**Fix it in your handler:**

1. When the current state matters, read the deployment from the public API using `resource.deployment.id` rather than trusting the arrival order.
2. If you store state from events alone, compare `timestamp` with the last one you stored before you overwrite anything.
3. Read the state from `type`. Railway's example pairs `Deployment.failed` with `"status": "SUCCESS"` in `details`, so the two may not agree.

**With Event Gateway:** Hookdeck stores every event it receives, so you can inspect the history and replay any of it. It can't recover an event Railway never sent, so keep your API check.

## Railway retries and paused URLs {#retries}

Railway [retries a failed delivery up to 3 times](https://docs.railway.com/observability/webhooks#delivery) with exponential backoff. If a URL reaches 100 failures within a 6-hour window, Railway stops sending to it for 24 hours.

**Why it happens:** Any `2xx` or `3xx` response counts as success, and any other status, a timeout or a connection error counts as a failure. Railway doesn't publish the backoff intervals or say whether each attempt counts separately towards the 100. It doesn't say whether events from the 24-hour pause are sent later, and it documents no way to resend one, so assume they're gone. It also documents no notice when a URL is paused.

A `3xx` counts as delivered, and Railway doesn't say it follows redirects, so a URL that redirects can look healthy while your handler receives nothing.

**Fix it in your handler and project:**

1. Keep the endpoint thin and highly available, and respond before doing any work.
2. Alert on errors from your own endpoint, so you notice well before the threshold.
3. Point the webhook at the final URL, and confirm it answers `2xx` directly.
4. If the receiver runs on Railway, [deploy it in its own project](https://railway.com/guides/alerts-crashes-failed-deploys), so an outage in the project you monitor can't take your alerting down with it.
5. After an outage, read recent deployments from the public API to find what you missed.

**With Event Gateway:** Hookdeck accepts each event as it arrives and stores it, so failures in your service don't count against Railway's threshold. It delivers to your service with [retries](/docs/retries) on a schedule you control, and you can replay anything that failed.

## Choosing and routing Railway events {#choosing-events}

Choose only the events you act on, route on the part of `type` before the dot, and filter by environment.

**Why it happens:** [Railway describes categories](https://docs.railway.com/observability/webhooks#platform-events) rather than a list: deployment status changes, volume usage alerts and CPU/RAM monitor alerts. Its webhook docs name only `Deployment.failed`. Its own [agent skill](https://github.com/railwayapp/railway-skills/blob/main/plugins/railway/skills/use-railway/references/configure.md) adds `Deployment.crashed` and `Deployment.oom_killed` as defaults for its `create-webhook` tool.

The [deployment reference](https://docs.railway.com/deployments/reference#deployment-states) lists states such as `Building` and `Active`, but not how each one is written in `type`, so don't build names from it. Alert names aren't documented at all.

A webhook also fires across every environment in the project, including ephemeral ones. [CPU/RAM monitors](https://railway.com/guides/alerts-crashes-failed-deploys#add-monitors-for-resource-thresholds) need the Pro plan and are set per environment, so a webhook only sees alerts from the environments you've set up.

**Fix it in your handler:**

1. Split `type` on the first dot, and handle the states you know.
2. Return `200` for anything else and log it, so you learn the real names from your own traffic.
3. Check `resource.environment.name` and `isEphemeral` before you page anyone. Through the MCP tools, `includePreviewEnvironments` turns off preview environments for a webhook.

**With Event Gateway:** Hookdeck [filters](/docs/filters) can route on `type`, `severity` or any `resource` field, for example sending only production `Deployment.failed` events to your paging tool. Hookdeck also logs each full body, which shows you the `type` values your project really sends.

## Testing Railway webhooks locally {#testing}

Click **Test Webhook** after every header change, then trigger a real deployment to confirm the whole path.

**Why it matters:** Railway's servers can't reach `localhost`. **Test Webhook** sends a sample with your custom headers and shows the status your endpoint answered, with a 10-second timeout rather than 30. Railway's pages disagree about where it comes from: the [webhooks page](https://docs.railway.com/observability/webhooks#testing-webhooks) says Railway sends it, and the [alerts guide](https://railway.com/guides/alerts-crashes-failed-deploys) says your browser does, so CORS can make a working endpoint look like a failure. A real deployment settles it either way.

**How to test it:**

1. Run `hookdeck listen 3000 railway` and use the URL it prints as the webhook URL.
2. Add your custom header and click **Test Webhook**.
3. Trigger a deployment and check your endpoint receives it. Railway publishes no alert payload, so you need a real alert to see one.

**With Event Gateway:** The [Hookdeck CLI](/docs/cli) forwards requests to localhost, and you can replay past requests without deploying again.

## Other Railway limits {#other-limits}

**A custom header isn't a signature.** Railway [doesn't sign payloads](https://docs.railway.com/observability/webhooks#verifying-the-sender), and the `timestamp` in the body isn't signed. Your custom header proves the sender knows the secret, but it doesn't cover the body, and a captured request can be replayed. Use a long random value over HTTPS, and confirm the deployment's state through the API before you act on anything consequential, such as a rollback.

**A secret in the URL is a weaker fallback.** Railway says a hard-to-guess path or query parameter works if your receiver can't read headers, but URLs tend to end up in access logs.

**Discord and Slack URLs get a different body.** Railway [rewrites the payload](https://docs.railway.com/observability/webhooks#muxers-provider-specific-webhooks) for those destinations, so what they receive isn't the JSON documented for your own URL.

**No source IPs are published.** Railway's webhooks page names no addresses to allow, so authenticate with the header rather than a firewall rule.

**With Event Gateway:** Create a source with the Railway type, then enter your custom header's name as **API Key Header** and its whole value as **API Key**, including any `Bearer ` prefix. A request that fails the check is recorded as failed verification and never reaches your service. The source checks a header only, so don't use Railway's URL fallback with it.

[Get started with Hookdeck](https://dashboard.hookdeck.com/signup) for free and handle Railway webhooks reliably in minutes.