Skip to content

Receive webhooks

Developers

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.

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.

  1. Build a route on your server that accepts POST requests with a JSON body. It must be reachable from the internet over HTTPS.

  2. Register it with POST /v1/webhooks (scope webhooks: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"]
    }'
  3. Save the secret from the response somewhere safe. It starts with whsec_ 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…"
    }
  4. 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 is 202 with "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.

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.

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_url and estimated_delivery_at are left out when the delivery doesn’t have them.
  • Failure details aren’t in the event. On delivery.failed, get the delivery for failed_attempt and the timeline. See Tracking and statuses.
  • Location events don’t carry the position. delivery.location.updated sends the same delivery fields as other events. Read the position from GET /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.

Check every request came from Shipr before you act on it. Shipr signs each request with your endpoint’s secret:

  1. Read t and v1 from the Shipr-Signature header.
  2. Join t, a full stop and the raw request body, exactly as received: <t>.<body>.
  3. Compute an HMAC-SHA256 of that string, using the whole secret (including whsec_) as the key, and write it as lowercase hex.
  4. Compare it with v1 using a constant-time comparison.
  5. Reject the request if t is 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);
});

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.

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.

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.

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 (scope webhooks:read) lists the endpoint’s 50 most recent events with their status (queued, delivered or failed), attempt_count and last_response_status.
  • POST /v1/webhooks/{webhook_id}/retry with { "event_id": "…" } (scope webhooks:write) sends one event again.
  • Or get the deliveries you care about with GET /v1/deliveries and read their current status.

The dashboard shows the same history, with a Retry button for each event. See Webhooks.

  • You may get an event more than once, for example if your server saved it but answered too slowly. Store each event id you’ve handled and skip repeats.
  • Events can arrive out of order. Retries and parallel sending mean a delivery.delivered can reach you before the delivery.out_for_delivery that came first. Compare created_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.