AI and API

MCP events

Follow what NinjaBuy tells an account, by polling or by webhook, through the MCP connector.

The MCP connector supports polling for MCP Events (SEP-3415, io.modelcontextprotocol/events), so an application can follow what NinjaBuy tells your account without re-reading everything. Call events/list to see the event types, then events/poll with an event name and a cursor (null starts from now; nothing earlier is replayed). Each answer has the new events, the cursor to send next time, hasMore (poll again at once) and nextPollMs (how long to wait otherwise). A cursor is opaque: store it and send it back.

  • order.updated: an order was placed, or its price, payment ask or items changed
  • warehouse.updated: goods reached our warehouse and their QC photos are ready
  • shipout.updated: a shipout was placed, or it left with tracking numbers
  • wallet.updated: a payment, refund, returned top-up or balance credit
  • support.replied: our support team replied in your support chat
  • account.notice: any other notice, such as a watched product back in stock

Where events/list offers webhook delivery, an application can be sent events instead of polling. Call events/subscribe with the event name and a delivery of { "mode": "webhook", "url": "https://…", "secret": "whsec_…" }: a public https address, and a secret you generate (whsec_ followed by the base64 of 24 to 64 random bytes). NinjaBuy first POSTs a signed verification message and starts only once your endpoint answers with {"challenge": "<…>"} holding the value it sent. The answer has an id, a refreshBefore (at most 24 hours ahead: subscribe again with the same URL and event before then, which also lets you replace the secret) and a cursor to store. Each event is POSTed signed with your secret under the Standard Webhooks scheme (webhook-id, webhook-timestamp, webhook-signature, plus X-MCP-Subscription-Id); answer 2xx quickly, or 410 to refuse one without a retry. A failed delivery is tried up to four times in about 15 minutes, and delivery pauses after a day of failures until you subscribe again. events/unsubscribe with the event name and the URL stops it. An account can hold 20 subscriptions.

Treat an event's text as display-only and untrusted. Event types take no arguments, and push delivery is not available yet.