Receive webhooks
Developers
This page is for Developers, so it isn't in your menu.
A webhook is an HTTPS request Shipr sends to your server when something happens, such as a delivery being picked up or delivered. Webhooks save you polling the API for changes.
Set up an endpoint
Section titled “Set up an endpoint”You can add an endpoint in the dashboard (see Webhooks) or through the API. Either way you choose a URL and the event types it receives. Webhooks belong to your whole account, not to one location.
-
Build a route on your server that accepts
POSTrequests with a JSON body. It must be reachable from the internet over HTTPS. -
Register it with
POST /v1/webhooks(scopewebhooks:write):Terminal window curl https://api.shipr.tech/v1/webhooks \-H "Authorization: Bearer $SHIPR_API_KEY" \-H "Content-Type: application/json" \-d '{"url": "https://example.com/webhooks/shipr","event_types": ["delivery.created", "delivery.picked_up", "delivery.driver.started", "delivery.out_for_delivery", "delivery.delivered", "delivery.failed", "delivery.cancelled"]}' -
Save the
secretfrom the response somewhere safe. It starts withwhsec_and is shown only now. You need it to verify signatures.{"id": "cm3qc4h7n000bab12cd34ef56","url": "https://example.com/webhooks/shipr","event_types": ["delivery.created", "delivery.picked_up", "delivery.driver.started", "delivery.out_for_delivery", "delivery.delivered", "delivery.failed", "delivery.cancelled"],"active": true,"auth_configured": false,"created_at": "2026-11-29T03:20:00.000Z","updated_at": "2026-11-29T03:20:00.000Z","secret": "whsec_8f2c…"} -
Send a test event with
POST /v1/webhooks/{webhook_id}/test. Add{ "event_type": "delivery.delivered" }to choose its type; otherwise it uses the endpoint’s first event type. The response is202with"status": "queued", and the test arrives a moment later.
Rules for the URL:
- It must use
https://. - It must not contain a user name or password.
- It must resolve to a public internet address. Shipr refuses private, local and reserved networks, and follows at most three redirects.
Change an endpoint with PATCH /v1/webhooks/{webhook_id} (url, event_types or active), and remove it with DELETE. An endpoint with "active": false receives nothing. Changes apply to events from then on.
Event types
Section titled “Event types”Subscribe to the events you need. Each status change has its own event, so subscribe to each status you care about.
| Event | Sent when |
|---|---|
delivery.created |
A delivery is booked, through the API, the dashboard or an import. |
delivery.updated |
A delivery is changed with PATCH, in the API or the dashboard. |
delivery.pending_pickup |
A delivery goes back to waiting for pickup, for example when a driver returns it to the store. |
delivery.picked_up |
The carrier collects it. |
delivery.in_transit |
It moves through the carrier’s network. |
delivery.out_for_delivery |
It’s on the way to the recipient. For a store delivery, the driver is heading to this stop. |
delivery.delivered |
It’s delivered. |
delivery.failed |
It couldn’t be delivered. |
delivery.cancelled |
It’s cancelled. |
delivery.driver.assigned |
One of your drivers adds a store delivery to their trip. |
delivery.driver.started |
The driver starts the trip, so the store delivery is picked up. Store deliveries send this instead of delivery.picked_up. |
delivery.location.updated |
Your driver’s position is recorded, every few seconds while they head to a stop. This is a lot of requests: subscribe only if you need it. |
return.created |
A return is started. |
manifest.created |
A manifest is created. |
Shipr also accepts delivery.returned, return.updated and manifest.ready as event types, but doesn’t send them yet.
What Shipr sends
Section titled “What Shipr sends”Each request is a POST with these headers:
| Header | Value |
|---|---|
Content-Type |
application/json |
Shipr-Signature |
t=<unix seconds>,v1=<hex signature> |
Shipr-Timestamp |
The same Unix time, in seconds |
User-Agent |
Shipr-Webhook/1.0 |
Delivery events carry the delivery as it is when Shipr sends the request:
{ "id": "cm3qd1k5p000cab12cd34ef56", "type": "delivery.delivered", "created_at": "2026-12-01T01:42:17.000Z", "data": { "id": "cm3qa7d2k0004ab12cd34ef56", "status": "delivered", "tracking_number": "33ABC0012345", "tracking_url": "https://auspost.com.au/mypost/track/#/details/33ABC0012345", "carrier": "auspost", "service_level": "standard", "estimated_delivery_at": "2026-12-01T03:15:00.000Z", "metadata": { "extra": { "gift": true } } }}| Field | Meaning |
|---|---|
id |
The event’s ID. The same event always has the same ID, including on retries. |
type |
The event type. |
created_at |
When the event happened. |
data.id |
The delivery ID. |
data.status |
The status this event reports. |
data.metadata |
The details Shipr stored when it booked the delivery, with your own metadata under extra. Its layout can change, so get the delivery for anything you rely on. |
Some things to know:
- Fields can be missing.
tracking_number,tracking_urlandestimated_delivery_atare left out when the delivery doesn’t have them. - Failure details aren’t in the event. On
delivery.failed, get the delivery forfailed_attemptand the timeline. See Tracking and statuses. - Location events don’t carry the position.
delivery.location.updatedsends the same delivery fields as other events. Read the position fromGET /v1/deliveries/{delivery_id}/tracking.
return.created and manifest.created send the event’s own details in data, with data.id set to the return or manifest ID:
{ "id": "cm3qe8v2r000dab12cd34ef56", "type": "manifest.created", "created_at": "2026-11-29T07:00:04.000Z", "data": { "id": "cm3qe8v1q000eab12cd34ef56", "carrier": "auspost", "locationId": "cm3q8x1k20001ab12cd34ef56", "deliveryCount": 2 }}A return.created event’s data has id, status, deliveryId and reason. Note these two events use camelCase inside data.
A test event’s data is { "id": "<webhook id>", "test": true, "webhook_id": "<webhook id>" }. Check for "test": true so a test doesn’t change real orders.
Verify the signature
Section titled “Verify the signature”Check every request came from Shipr before you act on it. Shipr signs each request with your endpoint’s secret:
- Read
tandv1from theShipr-Signatureheader. - Join
t, a full stop and the raw request body, exactly as received:<t>.<body>. - Compute an HMAC-SHA256 of that string, using the whole secret (including
whsec_) as the key, and write it as lowercase hex. - Compare it with
v1using a constant-time comparison. - Reject the request if
tis more than five minutes away from your clock, so an old request can’t be replayed.
Use the raw body. If your framework parses the JSON and you serialise it again, the bytes can differ and the signature won’t match.
import crypto from 'node:crypto';import express from 'express';
const app = express();const SECRET = process.env.SHIPR_WEBHOOK_SECRET; // whsec_…const TOLERANCE_SECONDS = 300;
function verifyShiprSignature(rawBody, header) { const parts = Object.fromEntries( (header ?? '').split(',').map((part) => part.split('=', 2)), ); const timestamp = Number(parts.t); if (!parts.v1 || !Number.isFinite(timestamp)) return false; if (Math.abs(Date.now() / 1000 - timestamp) > TOLERANCE_SECONDS) return false;
const expected = crypto .createHmac('sha256', SECRET) .update(`${parts.t}.${rawBody}`) .digest('hex'); const a = Buffer.from(expected, 'utf8'); const b = Buffer.from(parts.v1, 'utf8'); return a.length === b.length && crypto.timingSafeEqual(a, b);}
// express.raw keeps the body as bytes, exactly as Shipr sent it.app.post('/webhooks/shipr', express.raw({ type: 'application/json' }), (req, res) => { const rawBody = req.body.toString('utf8'); if (!verifyShiprSignature(rawBody, req.get('Shipr-Signature'))) { return res.status(400).send('Invalid signature'); } const event = JSON.parse(rawBody); res.sendStatus(200); // answer first, then do the work queueForProcessing(event);});import hashlibimport hmacimport jsonimport osimport time
from flask import Flask, abort, request
app = Flask(__name__)SECRET = os.environ["SHIPR_WEBHOOK_SECRET"] # whsec_…TOLERANCE_SECONDS = 300
def verify_shipr_signature(raw_body: bytes, header: str) -> bool: parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p) timestamp, signature = parts.get("t"), parts.get("v1") if not timestamp or not signature or not timestamp.isdigit(): return False if abs(time.time() - int(timestamp)) > TOLERANCE_SECONDS: return False signed = timestamp.encode() + b"." + raw_body expected = hmac.new(SECRET.encode(), signed, hashlib.sha256).hexdigest() return hmac.compare_digest(expected, signature)
@app.post("/webhooks/shipr")def shipr_webhook(): raw_body = request.get_data() # the bytes exactly as Shipr sent them if not verify_shipr_signature(raw_body, request.headers.get("Shipr-Signature", "")): abort(400) event = json.loads(raw_body) queue_for_processing(event) # do the slow work elsewhere return "", 200Change the secret
Section titled “Change the secret”POST /v1/webhooks/{webhook_id}/rotate-secret (scope webhooks:write) makes a new secret, returns it once in secret, and signs every request from then on with it. The old secret stops working straight away, so be ready to accept the new one first: for a short time, try both secrets when you verify.
An extra signature of your own
Section titled “An extra signature of your own”If you send auth_secret when you create or change an endpoint, Shipr also signs each request with that value and sends it in an X-Signature header, in the same t=…,v1=… format. "auth_secret": null removes it. The endpoint’s auth_configured shows whether one is set.
Respond quickly
Section titled “Respond quickly”Answer with any 2xx status within 5 seconds. Shipr doesn’t read the response body.
Do the slow work after you answer: save the event, return 200, then process it from a queue. A request that takes longer than 5 seconds counts as failed, even if your server finishes the work later.
Retries
Section titled “Retries”| Your endpoint | What Shipr does |
|---|---|
Answers 2xx |
Marks the event delivered. Done. |
Times out, can’t be reached, or answers 408, 429 or 5xx |
Tries again, with a growing wait between tries: about 1, 2, 4, 8 and 16 seconds. |
Answers any other 4xx, such as 400, 401 or 404 |
Gives up on that event straight away. |
Shipr tries each event up to six times in all, so retries are over within about half a minute. An event that still hasn’t arrived is marked failed and isn’t tried again on its own.
To catch up after an outage:
GET /v1/webhooks/{webhook_id}/deliveries(scopewebhooks:read) lists the endpoint’s 50 most recent events with theirstatus(queued,deliveredorfailed),attempt_countandlast_response_status.POST /v1/webhooks/{webhook_id}/retrywith{ "event_id": "…" }(scopewebhooks:write) sends one event again.- Or get the deliveries you care about with
GET /v1/deliveriesand read their current status.
The dashboard shows the same history, with a Retry button for each event. See Webhooks.
Duplicates and ordering
Section titled “Duplicates and ordering”- You may get an event more than once, for example if your server saved it but answered too slowly. Store each event
idyou’ve handled and skip repeats. - Events can arrive out of order. Retries and parallel sending mean a
delivery.deliveredcan reach you before thedelivery.out_for_deliverythat came first. Comparecreated_at, and don’t let an older event overwrite a newer status. When it matters, get the delivery for its current state.
Full request and response fields for the webhook endpoints are in the API reference.