# Get order events Subscribe to webhooks for the orders your client placed for a signed-in shopper, so you hear about shipping, delivery, refunds and returns without searching again. Order events send your callback a webhook when an order your client placed for the signed-in shopper is created or changes, so you can keep them up to date without calling `search_orders` again. They're MCP protocol methods, `events/list`, `events/subscribe` and `events/unsubscribe`, rather than tools: they don't appear in `tools/list`, and the CLI has no command for them. Shop MCP follows [OpenAI's MCP Events profile](https://developers.openai.com/plugins/build/mcp-events), and `server/discover` advertises them as `capabilities.events`. ## Before you subscribe - **A signed-in shopper.** Every events method, `events/list` included, needs the shopper's token with order access (`personal_agent` or `personal_agent:orders`). Without a token the server answers HTTP 401; with a token that has no order access, HTTP 403. [Connect a Shop account](sign-in.md) covers sign-in. - **A client enabled for order events.** Order events are off by default, and Shopify turns them on one client at a time. The client the shopper's token was issued to must have them, or `events/subscribe` fails with `client_not_eligible`. See [Application clients](authentication.md#application-clients). - **A public HTTPS callback** that can answer Shop's [verification challenge](#verify-the-callback) and [check signatures](#check-the-signature). ## What you're notified about Push is narrower than search. `search_orders` reads the shopper's whole Shop-tracked history, but events cover only orders **your client placed** for this shopper, and only changes after you subscribe. There's no replay of earlier events. | Order event | When Shop sends it | | --- | --- | | `order.created` | Shop records an order your client placed for the shopper | | `order.updated` | A shipment goes out, the delivery or tracking status changes, the merchant refunds the order and tells the shopper, the order is canceled, an edit changes its total, or a return is approved or declined | The merchant's notification choices apply: a change the merchant didn't tell the shopper about, such as a refund without a customer notification, sends no event. The shopper's push settings in the Shop app don't affect your subscription. Events stop when the shopper removes your app's order access, or disconnects it, which also deletes its subscriptions. Reconnecting doesn't bring them back, so subscribe again. ## Send an events request Events requests go to `https://mcp.shop.com/` like tool calls, with the shopper's token and an `Mcp-Method` header naming the method. They take no `Mcp-Name` header: ```sh curl -s https://mcp.shop.com/ \ -H 'Content-Type: application/json' \ -H 'Accept: application/json, text/event-stream' \ -H 'MCP-Protocol-Version: 2026-07-28' \ -H 'Mcp-Method: events/list' \ -H "Authorization: Bearer $SHOP_TOKEN" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "events/list", "params": { "_meta": { "io.modelcontextprotocol/protocolVersion": "2026-07-28", "io.modelcontextprotocol/clientInfo": { "name": "my-app", "version": "1.0.0" }, "io.modelcontextprotocol/clientCapabilities": {} } } }' ``` The result lists `order.created` and `order.updated`. This one is shortened: each event also has a `payloadSchema`, the JSON Schema of one order record, the same record `search_orders` returns. ```json { "events": [ { "name": "order.updated", "description": "New order changes from now on for the signed-in buyer and originating client only; no historical replay.", "inputSchema": { "type": "object", "properties": {}, "additionalProperties": false }, "delivery": ["webhook"] } ] } ``` ## Subscribe Subscribe to each event separately. The `_meta` object is the same as above and is left out here: ```json { "jsonrpc": "2.0", "id": 2, "method": "events/subscribe", "params": { "name": "order.updated", "arguments": {}, "delivery": { "mode": "webhook", "url": "https://callback.example/events", "secret": "whsec_" }, "ttlMs": 86400000 } } ``` | Request parameter | What to send | | --- | --- | | `name` | `order.created` or `order.updated` | | `arguments` | Always `{}`. The events take no arguments. | | `delivery.mode` | `webhook`, the only mode. It can be left out. | | `delivery.url` | Your callback: an `https` URL on port 443, up to 2,048 bytes, with no credentials, fragment or whitespace. Shop only connects to public addresses and doesn't follow redirects. | | `delivery.secret` | A signing secret you generate: `whsec_` followed by standard, padded base64 of 24 to 64 random bytes. Send it on every subscribe. Shop never returns it. | | `ttlMs` | The lifetime you'd like, in milliseconds. Shop grants between 6 hours and 7 days, and 1 day when it's left out or `null`. | | `cursor` | Left out or `null`. Replay isn't supported. | Before the subscription exists, Shop [verifies the callback](#verify-the-callback). Then it returns: ```json { "id": "", "refreshBefore": "2026-09-21T12:00:00Z", "cursor": null, "truncated": false } ``` `refreshBefore` is when the subscription expires: Shop MCP returns the end of the lifetime Shop granted, not a halfway mark. To keep it, subscribe again with the same `name`, `arguments` and `url` before then. Do it well ahead, such as halfway through, so one failed refresh doesn't end delivery. A refresh keeps the same `id`, sets a new expiry and replaces the secret with the one you send. Events sent before the refresh stay signed with the old secret, including any that are sent again, so keep accepting the old secret for 7 days after you replace it. No subscription lasts longer, so nothing signed with the old secret arrives after that. A different `url` makes a separate subscription. One shopper's connection to your client holds up to 10 subscriptions. Subscribe requests are rate-limited for each shopper and client, so don't retry them in a loop. ## Unsubscribe Unsubscribe with the same `name`, `arguments` and `url`. The subscription's `id` isn't used. You can send the same `delivery` object you subscribed with; its secret is ignored: ```json { "jsonrpc": "2.0", "id": 3, "method": "events/unsubscribe", "params": { "name": "order.updated", "arguments": {}, "delivery": { "url": "https://callback.example/events" } } } ``` The result is `{}`, whether or not the subscription existed. ## Verify the callback On every subscribe, refreshes included, Shop POSTs a challenge to the callback, signed with the secret you sent the same way as an event: ```json { "type": "verification", "challenge": "" } ``` [Check the signature](#check-the-signature), then answer HTTP 200 with the challenge in a JSON body: ```json { "challenge": "" } ``` Answer within 6 seconds, with a body under 16 KB. Any other answer fails the subscribe with `challenge_failed`, and no subscription is created or refreshed. ## Receive events Each event is a POST to the callback. Its body carries the order as the `data`, in the same record `search_orders` returns. This order is shortened from the one in [Read the results](orders.md#read-the-results): ```json { "eventId": "", "name": "order.updated", "timestamp": "2026-09-22T12:00:00Z", "data": { "id": "", "label": "#2042", "placed_at": "2026-09-20T12:00:00Z", "seller": { "name": "Example Running Co.", "domain": "running.example" }, "status": "delivered", "fulfillment": { "events": [ { "type": "delivered", "status": "DELIVERED", "occurred_at": "2026-09-22T12:00:00Z", "carrier": "Example Post", "tracking_number": "", "tracking_url": "https://carrier.example/track/" } ] }, "permalink_url": "" }, "cursor": null } ``` | Event field | What it holds | | --- | --- | | `eventId` | The event's ID. A repeated delivery of the same change has the same ID. | | `name` | `order.created` or `order.updated` | | `timestamp` | When Shop saw the change | | `data` | The order as it was when Shop sent the event, which may be newer than the change. Read it as [Track orders](orders.md#read-the-results) describes. | The event says that the order changed, not what changed: compare `data` with what you last showed the shopper. The same event can arrive more than once, and events aren't guaranteed to arrive in order, so deduplicate on `eventId`. Answer with a 2xx status once you've stored the event. Don't rely on an event your callback missed being sent again: if you think you missed one, read the order with `search_orders`. ### Check the signature Events and challenges are signed under [Standard Webhooks](https://www.standardwebhooks.com), with these headers: | HTTP header | What it contains | | --- | --- | | `webhook-id` | The message ID. For an event, it's the `eventId`. | | `webhook-timestamp` | When the request was signed, in Unix seconds | | `webhook-signature` | `v1,` followed by the base64 HMAC-SHA256 signature | | `X-MCP-Subscription-Id` | The subscription's `id` | The key is your secret's bytes after `whsec_`, base64-decoded. The signed content is `..`, over the exact body bytes you received, before you parse them. Any Standard Webhooks library checks this, along with the timestamp's age, given the `whsec_` secret. In Node.js without one: ```js import { createHmac, timingSafeEqual } from 'node:crypto'; // body is the raw request body as a Buffer, before any JSON parsing. function verify(secret, headers, body) { const id = headers['webhook-id']; const timestamp = headers['webhook-timestamp']; const signatures = headers['webhook-signature']; if (typeof id !== 'string' || typeof timestamp !== 'string' || typeof signatures !== 'string') return false; // Refuse a request signed more than 5 minutes from now, so a captured one can't be replayed later. if (!/^\d+$/.test(timestamp) || Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false; const key = Buffer.from(secret.slice('whsec_'.length), 'base64'); const signed = Buffer.concat([Buffer.from(`${id}.${timestamp}.`), body]); const expected = Buffer.from(`v1,${createHmac('sha256', key).update(signed).digest('base64')}`); // Compare bytes, not characters: timingSafeEqual throws when the two lengths differ. return signatures.split(' ').some((signature) => { const given = Buffer.from(signature); return given.length === expected.length && timingSafeEqual(given, expected); }); } ``` Drop any request that's missing one of these headers, or whose signature doesn't match or timestamp is out of range. ## Errors Events methods report failures as a JSON-RPC `error`, with a fixed `message` and a `data.reason` or `data.field`: | `code` | `data` | What it means | | --- | --- | --- | | `-32602` | `field`, or `reason` `unsupported_event`, `invalid_arguments`, `invalid_callback_url` or `invalid_secret` | A parameter was refused. Fix the request before you send it again. | | `-32015` | `reason: challenge_failed` | The callback didn't answer the [challenge](#verify-the-callback) | | `-32000` | `reason: client_not_eligible` | Your client isn't enabled for order events, or the shopper isn't connected to it | | `-32000` | `reason: subscription_limit_reached` | The connection already holds 10 subscriptions. Unsubscribe from one first. | | `-32000` | `reason: rate_limited` | Too many subscribe requests. Try again later. | | `-32000` | `reason: sign_in_required`, `insufficient_scope` or `delegation_denied` | The shopper's token doesn't allow order access. See [Authentication errors](authentication.md#authentication-errors). | | `-32603` | `reason: outcome_unknown` | Shop didn't confirm the request, so the subscription may or may not have changed. Subscribing again with the same `name`, `arguments` and `url` is safe: it refreshes the same subscription. | Shop MCP doesn't retry an events request for you.