Shadow Traffic
A shadow destination receives sampled copies of your real production webhooks, with personal data replaced by realistic fakes. Point one at your tunnel or at a preview or staging deployment, and new code runs against the payloads your providers actually send.
Production delivery doesn't change. Your live routes deliver every event as before. A copy never creates a delivery, never changes an event's status and isn't billed.
Shadow traffic is available on Pro and Business.
When to Use It
A developer on a tunnel. You're rewriting your Stripe handler. You start a tunnel, create a shadow destination that points at it, and route your Stripe source to it. While you work, every real Stripe event also reaches your laptop as a scrubbed copy, so you test against the events your account really gets. When your laptop is offline, its copies fail and production carries on.
A PR preview at 5%. Each pull request gets a preview deployment. You give it a shadow destination
and a route with "sampleRate": 0.05, and one matching event in twenty goes to the preview. Reviewers
can watch the new code handle live traffic before the merge.
Copies are best effort. Each one is sent once, with no retries, and copies are skipped while the receiver is down. Use shadow traffic to watch new code run, and keep data that must arrive on live routes.
How It Works
Shadow is a property of the destination. You create a destination with "purpose": "shadow", and
every route to it is a shadow route. When an event arrives:
┌─▶ live route ───▶ production endpoint every matching event, retried
Source ──▶ event ───┤
└─▶ shadow route ─▶ sample ─▶ scrub ─▶ tunnel a sample, one try
or preview- Live routes deliver the event as usual.
- Each shadow route checks whether the event is in its sample and passes its filter and schema. If it is and it does, Hookbase scrubs a copy, signs it with the shadow destination's own secret and sends it once.
- The outcome goes in the route's shadow deliveries log.
Set Up
1. Create a shadow destination
curl -X POST https://api.hookbase.app/api/destinations \
-H "Authorization: Bearer whr_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Stripe handler (my laptop)",
"slug": "stripe-shadow-laptop",
"type": "http",
"url": "https://api.hookbase.app/t/my-laptop/webhooks/stripe",
"purpose": "shadow"
}'The response has "purpose": "shadow" and, this once, the destination's signingSecret. Your code
verifies copies with it. You can reveal it again later, as for any destination.
A shadow destination:
- Is an HTTP destination. It needs
"type": "http"and aslug, like any destination. Other types are refused withSHADOW_DESTINATION_HTTP_ONLY. - Points at a tunnel or an external URL.
- A tunnel URL is
https://api.hookbase.app/t/<subdomain>, optionally followed by a path, as in the example. The tunnel must belong to your organization (SHADOW_TUNNEL_NOT_FOUNDotherwise). Copies go straight to the tunnel. - An external URL, such as a preview deployment, follows the rules for any destination URL: HTTP or
HTTPS, a standard port, and no private or internal address. To reach
localhost, use a tunnel. - Any other Hookbase URL, such as a source's ingest URL or the API, is refused with
SHADOW_URL_REFUSED.
- A tunnel URL is
- Has no static IP.
"useStaticIp": trueis refused withSHADOW_STATIC_IP_UNSUPPORTED. - Keeps its purpose. A live destination can't become a shadow destination, or the reverse (409
PURPOSE_IMMUTABLE). Create a new destination instead.
The destination's method, custom headers and auth apply to copies as they do to deliveries. Its timeout and throttle settings don't (see Limits and Guarantees). It counts toward your plan's destination limit.
2. Route a source to it
curl -X POST https://api.hookbase.app/api/routes \
-H "Authorization: Bearer whr_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Stripe to my laptop",
"sourceId": "11111111-1111-4111-8111-111111111111",
"destinationId": "55555555-5555-4555-8555-555555555555",
"sampleRate": 0.05
}'The route is a shadow route because its destination is a shadow destination. Its read-only mode is
"shadow".
sampleRateis the share of matching events to copy, from0.0001(one in 10,000) to1(every event). The default is1. Rates are kept in steps of 0.0001, and other values are rounded to the nearest step. Only shadow routes take a rate: a live route refuses it withSAMPLE_RATE_NOT_ALLOWED.- Filters, schemas and transforms apply as on any route. An event that fails the route's filter or schema gets no copy.
- No failover. A shadow route can't have failover destinations (
SHADOW_ROUTE_FAILOVER), and a live route can't fail over to a shadow destination (SHADOW_FAILOVER_NOT_ALLOWED). - A route stays on its side. A route can't move between a live and a shadow destination (409
ROUTE_PURPOSE_CONFLICT). Create a new route instead. - Shadow routes count toward your plan's route limit.
3. Keep the live route
Leave your live route to production as it is. The live route and the shadow route run side by side on the same events, and neither affects the other.
In the dashboard
When you create an HTTP destination, turn on the Shadow destination switch. A route to a shadow
destination has a Sample rate field, which the dashboard shows as a percentage (5% is 0.05 in the
API). The route's page shows its Shadow deliveries log.
Info
The SDKs and the Terraform provider can't create shadow destinations or routes yet. Use the dashboard, the API, the CLI (2.19.0 or later), the MCP server (2.19.0 or later) or the Postman collection.
Sampling
Sampling is deterministic. Whether a route copies an event depends only on the event, the route and the rate, so at a given rate a route always copies a given event or never does.
- Two shadow routes sample independently of each other.
- Raising a route's rate keeps every event the lower rate picked and adds more. Lowering it keeps a subset.
- Each event is copied to a route at most once. Copies are made when an event arrives, so replaying an event's live deliveries doesn't make a new copy.
What a Copy Looks Like
Hookbase builds a copy the way it builds a delivery, with scrubbing added. In order:
- Your redaction policies with
deliveryorbothscope are applied. - The payload is scrubbed.
- The route's transform runs on the scrubbed payload.
- The transform's output gets a last pass for emails, IP addresses and secret-looking values, to catch data the transform copied into new fields.
- The request is signed with the shadow destination's signing secret.
- It's sent once, with
X-Hookbase-Shadow: 1.
Steps 3 and 4 run only when the route has a transform.
A copy carries the same headers as a
delivery, plus
X-Hookbase-Shadow:
| Header | Value |
|---|---|
Content-Type | application/json, or the content type of the transform's output |
User-Agent | Hookbase/1.0 |
X-Delivery-ID | The copy's id: shd_ followed by the id of its log entry |
X-Event-ID | The event's id, the same one its live deliveries carry |
X-Hookbase-Shadow | 1 |
webhook-id, webhook-timestamp, webhook-signature | The Standard Webhooks signature, made with the shadow destination's secret. webhook-id is the copy's id |
x-hookbase-id, x-hookbase-timestamp, x-hookbase-signature | The same values under the legacy names |
The destination's custom headers and auth header come with it. Custom headers can't set or replace
X-Hookbase-Shadow.
Verifying a Copy
Verify a copy as you verify any Hookbase delivery, with the shadow destination's signing secret:
import express from 'express';
import { Webhook } from '@hookbase/sdk';
const app = express();
// The shadow destination's secret, not your production destination's.
const wh = new Webhook(process.env.HOOKBASE_SHADOW_SECRET); // whsec_...
app.post('/webhooks/stripe', express.raw({ type: '*/*' }), (req, res) => {
let event;
try {
event = wh.verify(req.body, req.headers);
} catch {
return res.status(401).send('Invalid signature');
}
// The signature covers webhook-id, so a verified id that starts with shd_ is a shadow copy.
const isShadowCopy = String(req.headers['webhook-id']).startsWith('shd_');
// handle event...
res.sendStatus(200);
});- Tell a copy by its verified
webhook-id. It starts withshd_. The signature doesn't coverX-Hookbase-Shadow. - Provider signatures don't verify on copies. Scrubbing changes the body, so a signature the
provider made over the original body can't match it. Hookbase deliveries don't carry provider
signature headers such as
Stripe-Signaturein any case. Where your code checks a provider signature, check the Hookbase signature in the environment that receives copies. - Copies can't loop back in. Ingest refuses any request that carries
X-Hookbase-Shadowwith 400SHADOW_COPY_REFUSED, so a copy that reaches a Hookbase source never becomes an event.
Scrubbing
Scrubbing is always on, and there is no setting to turn it off. If a copy can't be scrubbed, it's
skipped with scrubber_unavailable. Hookbase never sends a copy unscrubbed.
Copies use the same scrubber as webhook tests in CI.
It finds personal data by key name and value format: emails, phone numbers, names, handles, street
addresses, cities, postal codes, IP addresses, dates of birth, government ids and card numbers. Each
value becomes a realistic fake in the same format. A phone number keeps its country code, and a card
number keeps its length and a valid check digit. Emails and phone numbers become fakes from reserved
ranges, such as elena.rossi.9c4f@example.com or +1 305 555 0149. Secrets, such as passwords and
tokens, become empty strings.
Fakes are pseudonyms. The same real value becomes the same fake everywhere in your organization, so you can follow one customer across events. Other organizations get different fakes. Scrubbing doesn't anonymize a copy: what stays (below) can still identify a person.
Masked and encrypted fields always become fakes. The source's maskFields and encryptFields
paths are faked whatever they hold, unless the value is already [REDACTED] or a redaction digest.
Values that are already fakes are left alone: example.com and other reserved email domains,
documentation IP ranges, 555-01NN phone numbers, test card numbers, empty strings, and values that are
already redacted ([REDACTED], *** masks, digests).
Warning
Test with values that aren't reserved. A test event with jane@example.com or
4242 4242 4242 4242 comes through unchanged, because those values already are fakes. To see
scrubbing at work, send something like jane@yourcompany.com or a real-looking phone number.
What stays. Provider ids (cus_…, pi_…), amounts, currencies, countries, timestamps and booleans
stay as they are, because handlers depend on them. The scrubber doesn't look for names or addresses in
free text, such as a description or note field. It does replace emails, IP addresses and
secret-looking values wherever they appear. To remove anything else, add a redaction policy with
delivery or both scope.
Warning
Ids are real. A handler that calls the provider's API with an id from a copy reaches the real object. Give the environment that receives copies its own database and test-mode or read-only provider keys.
JSON only. Copies are made from JSON object and array payloads. Form, XML, text and other bodies are
skipped with non_json, because the scrubber needs field names to find personal data. A route's
transform can still output another format.
Each entry in the shadow deliveries log has scrubbedValues, the number of values replaced in that
copy.
Limits and Guarantees
Delivery
- One attempt. A copy is sent at most once, with no retries.
- 15 minutes. A copy is skipped (
expired) when its event arrived more than 15 minutes before the copy's turn to be sent. - 10-second timeout. A copy to an external URL is a direct request with a 10-second timeout. It never uses a static IP, and redirects aren't followed. A copy to a tunnel goes straight to the tunnel, which answers 504 if your local server hasn't responded within about 9 seconds.
- A 60-second pause after failures. A network error, a timeout or a 502, 503 or 504 response
pauses the route for 60 seconds, and copies in that time are skipped (
paused). A tunnel whose CLI isn't connected answers 502. So an offline laptop costs about one failed copy a minute, and nothing else waits on it. - 256 KB. A copy is skipped (
too_large) when the stored payload, or the body after scrubbing and any transform, is over 256 KB. - The response is logged. The log keeps the receiver's status code, latency and up to 2 KB of its response body. For a source in transient mode, no response body is kept.
Isolation from Production
- Copies never create deliveries. They don't affect event status, analytics, alerts, notifications, circuit breakers, the DLQ or replays.
- "No routes" events. An event that matches only shadow routes gets no delivery, so its status is no routes.
- Not billed. The event is counted once, as before. Its copies aren't events or deliveries, so they add nothing to your usage. Copies to a tunnel show in the tunnel's request log and don't count toward tunnel usage.
- Only scrubbed payloads. A replay with a destination override can't target a shadow destination (400
SHADOW_DESTINATION_NOT_ALLOWED), because a replay sends the stored payload as it is. For the same reason, a test from Tools → Testing can't send your own payload to a shadow destination (400SHADOW_DESTINATION_NOT_ALLOWED). A test without a payload, and the destination's own Test, send the standard test payload. A test isn't a copy: it has noX-Hookbase-Shadowheader, and itswebhook-idstarts withtest_.
Plans
- Creating a shadow destination or a shadow route needs Pro or Business. Free, Starter and Pay As You
Go get 403
FEATURE_DISABLED. - After a move to one of those plans, copies stop. Your shadow destinations and routes stay, and you can still edit or delete them. Copies start again when you move back to Pro or Business.
The Shadow Deliveries Log
Copies never appear in deliveries. Each shadow route has its own log: the Shadow deliveries log on the route's page in the dashboard, or this endpoint:
curl "https://api.hookbase.app/api/routes/{routeId}/shadow-deliveries?limit=50" \
-H "Authorization: Bearer whr_your_api_key"It returns { "shadowDeliveries": [...], "nextCursor": "..." }, newest first. Pass nextCursor as
cursor for the next page. The Routes API lists
every field.
The log has an entry for each event that was in the route's sample and passed its filter and schema. Entries last as long as their event, by your plan's retention, and go when the route is deleted.
| Status | Meaning |
|---|---|
sending | The copy is being prepared or sent |
delivered | The receiver answered with a 2xx status |
failed | The copy failed. reason says why |
skipped | The copy wasn't sent. reason says why |
unknown | The copy was still sending an hour later, and its outcome wasn't recorded. It may or may not have been sent. It's never sent again |
Reasons
| Reason | Status | What happened |
|---|---|---|
expired | skipped | The event arrived more than 15 minutes before the copy's turn came, so the copy wasn't sent late |
paused | skipped | A copy on this route failed with a network error, a timeout or a 502, 503 or 504 in the last 60 seconds |
route_unavailable | skipped | The route or its shadow destination couldn't be found when the copy's turn came, for example because it was just deleted |
inactive | skipped | The route or the destination was deactivated while the copy waited |
source_mismatch | skipped | The route was moved to another source after the event arrived |
url_refused | skipped | The destination's URL isn't allowed, such as a Hookbase URL other than one of your tunnels, or a private address. error says why |
tunnel_unavailable | skipped | The URL names a tunnel that isn't one of your organization's, such as one you deleted |
scrubber_unavailable | skipped | Scrubbing couldn't run, or one of the source's masked or encrypted field paths couldn't be read |
payload_unavailable | skipped | The event's stored payload couldn't be read |
undecryptable | skipped | The payload's encrypted fields couldn't be decrypted |
too_large | skipped | The stored payload, or the body after scrubbing and any transform, is over 256 KB |
redaction_failed | skipped | Your delivery redaction policies couldn't be loaded or applied |
non_json | skipped | The payload isn't a JSON object or array |
transform_unavailable | skipped | The route has a transform, and Hookbase couldn't run it at that moment |
transform_failed | failed | The transform threw an error. error holds its message, scrubbed |
destination_config | failed | The destination's headers, auth or signing secret couldn't be used. error says which |
timeout | failed | No response within 10 seconds. The route pauses for 60 seconds |
network_error | failed | The request got no response, for example after a DNS, connection or TLS error, and the route pauses for 60 seconds. Also recorded for an internal error while preparing the copy |
http_status | failed | The receiver answered with a status outside 200–299, in statusCode. A 502, 503 or 504 pauses the route for 60 seconds. A redirect counts too, because redirects aren't followed |
Checking a Shadow Route
- Simulator. The source simulator marks a shadow route as a shadow copy, with its sample rate and the URL the copy would go to.
- Event debugger. For a stored event, the debugger shows whether the event is in each shadow route's sample at the route's current rate.
- A test event. A test event sent from a source (Tools → Testing) goes through real ingest, so
each shadow route copies it if it's in the sample. With a sample rate of
1, every test event is copied.
Pausing and Stopping
| To | Do this |
|---|---|
| Pause copies | Deactivate the route ("isActive": false) or the shadow destination. Copies already on their way are skipped with inactive |
| Send fewer | Lower the route's sampleRate |
| Stop | Delete the route, or the destination. Deleting the destination also deletes its routes and their logs |