Set up webhooks

12 min readUpdated 23 Nov 2026Advanced

Receive updates when quotes, orders, customers, payments, Inbox messages, purchase orders or warranty claims change. OrderPilot sends a signed event to your HTTPS address. Your server verifies it, responds and fetches the latest record.

Build a receiver in Node or Python, send a test event and learn how to recover missed updates.

What you’ll need

API access

Ask us to enable the API for your store. You can then create keys in Settings › API and integrations.

A public HTTPS address

The address can’t use localhost or a private network, or contain a username or password.

Secure secret storage

Save the signing secret in an environment variable or secret manager. It’s shown only once.

A queue

Store events for processing so your receiver can respond promptly.

In these examples, $BASE means https://api.meetorderpilot.com/connect/v1 and $ORDERPILOT_KEY is your API key.

Build and test the receiver

  1. Step 1: Create a key with webhook access

    Create a key with Manage webhooks in SettingsAPI and integrations. Add the read permission listed for each event you need. You can receive events only for records your key can read.

    EventWhat triggers itRequired permission
    quote.createdA new quote is createdRead quotes
    quote.updatedA quote is updatedRead quotes
    order.createdA new order is createdRead orders
    order.updatedAn order is updatedRead orders
    customer.createdA customer record is createdRead customers
    customer.updatedA customer record is updatedRead customers
    payment.receivedA full or partial payment is recordedRead orders
    conversation.message_receivedThe Inbox receives a customer message or vendor emailRead the Inbox
    purchase_order.createdA purchase order is createdRead purchase orders
    purchase_order.updatedA purchase order is updatedRead purchase orders
    purchase_order.receivedItems on a purchase order are receivedRead purchase orders
    warranty_claim.createdA warranty claim is createdRead warranty claims
    warranty_claim.status_changedA warranty claim’s status changesRead warranty claims

    Webhooks stop if the key used to create them expires or is revoked.

  2. Step 2: Register the receiving address

    Send your HTTPS address and chosen events to POST /webhooks. Include the required Idempotency-Key so retrying returns the original response without creating another webhook.

    curl -X POST $BASE/webhooks \
      -H "Authorization: Bearer $ORDERPILOT_KEY" \
      -H "Idempotency-Key: 3b8f2c1e-erp-webhook" \
      -H "Content-Type: application/json" \
      -d '{
        "url": "https://hooks.harlowandfinch.example/orderpilot",
        "events": ["quote.updated", "order.updated", "payment.received"]
      }'
    Response201 Created
    {
      "id": "cm3xw9k2b0004whf8ka1z7q2d",
      "url": "https://hooks.harlowandfinch.example/orderpilot",
      "events": ["quote.updated", "order.updated", "payment.received"],
      "active": true,
      "secret": "whsec_••••••••••••••••••••••Qm7X",
      "created_at": "2026-11-18T14:05:31Z"
    }
    Save the secret nowSave secret from this response. Retrying with the same key returns secret_redacted: true without the secret. If you lose it, follow Replace a lost secret.

    You can register up to 10 webhooks per key and 25 per store.

  3. Step 3: Verify each event’s signature

    Each event includes OrderPilot-Signature: t=…,v1=…. Calculate v1 by applying HMAC-SHA256 to "<t>.<raw body>" with your secret. Compare signatures in constant time. Reject events with a t more than five minutes old.

    What arrivesBody shown formatted; check the bytes as they came
    POST /orderpilot
    Content-Type: application/json
    User-Agent: OrderPilot-Webhooks/1
    OrderPilot-Delivery: cm3xwb7tq0009whf8m2k4p8sz
    OrderPilot-Signature: t=1795016531,v1=ff4f2770cee955e9…7a8176f2a461
    
    {
      "id": "evt_6f1c2a9b0d4e8f7a3b5c1d2e",
      "type": "quote.updated",
      "created_at": "2026-11-18T15:42:11Z",
      "data": { "id": "qt_8KX2M4", "kind": "quote" }
    }
    receiver.js
    import crypto from "node:crypto";
    
    // raw: the body exactly as it arrived (a Buffer), before JSON.parse
    export function verify(header, raw, secret) {
      const parts = header.split(",").map((p) => p.trim().split("="));
      const t = Number(parts.find(([k]) => k === "t")?.[1]);
      const age = Math.abs(Date.now() / 1000 - t);
      if (!Number.isInteger(t) || age > 300) return false;
    
      const expected = crypto.createHmac("sha256", secret)
        .update(`${t}.`).update(raw).digest();
      // for 24 hours after a rotation there are two v1 values: either may match
      return parts.filter(([k]) => k === "v1").some(([, v = ""]) => {
        const given = Buffer.from(v, "hex");
        return given.length === expected.length
          && crypto.timingSafeEqual(given, expected);
      });
    }
    When replacing a secretFor 24 hours after POST /webhooks/{id}/rotate-secret, the header includes two v1 signatures, one for each secret. Accept either while updating your receiver, then remove the old secret.
  4. Step 4: Respond within 8 seconds

    Return any 2xx status. The eight-second timeout covers the connection, TLS and your response, including any time spent sending it. OrderPilot ignores the response body.

    Return 200 before processingQueue the event and respond. Process the queued event to fetch and save the record.
    receiver.js
    import express from "express";
    
    const app = express();
    // express.raw keeps the body as bytes, so the signature can be checked
    app.post("/orderpilot", express.raw({ type: "application/json" }), (req, res) => {
      const header = req.get("OrderPilot-Signature") ?? "";
      if (!verify(header, req.body, process.env.ORDERPILOT_WEBHOOK_SECRET)) {
        return res.sendStatus(400);
      }
      // answer first: the whole attempt is cut off after 8 seconds
      res.sendStatus(200);
      // then hand the event to your own queue
      jobs.add(JSON.parse(req.body));
    });
  5. Step 5: Skip repeat events and fetch the record

    The same event can arrive again if OrderPilot didn’t receive your response. Save each processed event’s id and skip any you’ve already handled.

    The event’s data includes only the record’s id and kind. Fetch the record to read its current details.

    receiver.js
    const BASE = "https://api.meetorderpilot.com/connect/v1";
    const PATHS = { quote: "quotes", order: "orders", customer: "customers" };
    
    // runs from your queue, after you answered
    async function handle(event) {
      if (event.type === "ping") return;
      // at least once: the same event can arrive twice
      if (await seen(event.id)) return;
      // a thin event: fetch the record for its current state
      const { id, kind } = event.data;
      const res = await fetch(`${BASE}/${PATHS[kind]}/${id}`, {
        headers: { Authorization: `Bearer ${process.env.ORDERPILOT_KEY}` },
      });
      await saveToErp(await res.json());
      await markSeen(event.id);
    }
    Count payments, not eventspayment.received includes the order’s ID. Record revenue for each payment, since events can repeat.
  6. Step 6: Test delivery

    Call POST /webhooks/{id}/ping to send a ping event. The request returns before your server responds. Check GET /webhooks/{id}/deliveries for the result. It lists the last 50 deliveries, kept for a week.

    # send a test event to this webhook now
    curl -X POST $BASE/webhooks/cm3xw9k2b0004whf8ka1z7q2d/ping \
      -H "Authorization: Bearer $ORDERPILOT_KEY"
    
    # then see what happened
    curl $BASE/webhooks/cm3xw9k2b0004whf8ka1z7q2d/deliveries \
      -H "Authorization: Bearer $ORDERPILOT_KEY"
    Response200 OK
    {
      "items": [
        {
          "event_id": "evt_8Pq3Lm1",
          "type": "ping",
          "state": "DELIVERED",
          "attempts": 1,
          "last_status": 200,
          "last_error": null,
          "created_at": "2026-11-18T15:30:04Z",
          "delivered_at": "2026-11-18T15:30:04Z",
          "next_attempt_at": "2026-11-18T15:30:04Z"
        }
      ]
    }

    Check state: PENDING means delivery attempts remain. The final state is DELIVERED or FAILED.

Delivery timing and retries

Delivery starts when the record changes. Changes made close together to one record become one event, sent about two seconds after the first change. Customer and payment updates are checked every minute, so those events can arrive about a minute later.

  1. 1First attemptabout 2 s after the change
  2. 2+1 mafter the last failure
  3. 3+5 mafter the last failure
  4. 4+30 mafter the last failure
  5. 5+2 hafter the last failure
  6. 6+6 hafter the last failure
  7. ✕FAILEDNo further attempts

Each attempt has a fresh signature with a new t. Six attempts are made, ending about eight and a half hours after the first.

Failed attemptYour response isn’t 2xx, the attempt takes over 8 seconds or the address can’t be reached.
410 GoneThat delivery stops at once, with no more attempts.
20 consecutive failuresAfter 20 failed deliveries in a row, OrderPilot turns the webhook off (active: false) and emails the store owner.
3 daysA delivery waiting more than 3 days becomes FAILED, with last_error set to EXPIRED.
5,000 pending deliveriesAbove this limit, the oldest deliveries become FAILED with OVERFLOW. OrderPilot emails the store owner.
Address restrictionsOrderPilot won’t follow redirects or send to an address that resolves to a private network.
Delivery rateEach webhook can have up to 2 attempts running at once. A working receiver handles about 130 a minute.
Updates without content changesShopify sync updates that don’t change record content don’t trigger events. To track them, check for updates with updated_since.

If something goes wrong

Signatures never match
Message: 400 from your own check

Use the body exactly as received, before parsing JSON, with <t>. before it. Use the secret returned when you registered the webhook; it starts with whsec_.

Delivery times out
Message: The receiver didn’t answer in time.

Each attempt ends after 8 seconds. Return 2xx before processing the event from your queue.

An event arrives again
Message: Same event_id twice

Retries can repeat events. Save processed event IDs and skip repeats.

The test says the webhook is off
Message: 422 WEBHOOK_OFF

OrderPilot turned it off after 20 consecutive delivery failures. Fix the receiver, register the webhook again and use updated_since to catch up.

Deliveries show EXPIRED or OVERFLOW
Message: EXPIRED · OVERFLOW

They waited more than 3 days, or the queue exceeded 5,000 deliveries. Read the lists with updated_since to recover missed updates.

An event can’t be registered
Message: 403 SCOPE_MISSING

Add its required read permission to the key, such as Read quotes, Read orders or Read customers.

The webhook limit is reached
Message: 422 CAP_REACHED

Each key allows 10 webhooks and each store allows 25. Remove an unused webhook with DELETE /webhooks/{id}.

The address is rejected
Message: 400 INVALID_BODY

Use a public HTTPS address without a username or password. Private addresses aren’t allowed.

The secret is lost
Message: secret_redacted: true

Get a replacement with POST /webhooks/{id}/rotate-secret. Events remain signed with the old secret for 24 hours while you update your receiver.

Next steps

Was this guide useful?