Skip to Content
StarsellDocs
Developers

Events

Poll GET /events with after to read everything that happened in a store, in order - the cursor, filters, ordering, how long events are kept, and when to poll instead of using webhooks.

Everything a webhook can be told about is also recorded as an event you can read: orders placed and paid, checkouts abandoned, stock running low. GET /events returns them oldest first, from wherever you left off. It is the pull side of webhooks: same types, same payloads, same ids.

Reading events needs the Orders permission, for every event type. See Authentication.

Poll with after

curl "$BASE/events?after=4180&limit=100" -H "Authorization: Bearer $KEY"
{
  "data": [
    {
      "id": "4182",
      "type": "order.created",
      "subject_type": "order",
      "subject_id": "b5e1c9a7-2d4f-4a8b-9c3e-7f0d1a6b2e58",
      "created_at": "2026-11-27T10:14:03.512Z",
      "data": {
        "order": { "id": "b5e1c9a7-2d4f-4a8b-9c3e-7f0d1a6b2e58", "number": 1042, "label": "#1042", "total_minor": 24700, "currency": "ILS" },
        "customer": { "email": "[email protected]", "phone": "+972501234567", "name": "Dana Levi", "first_name": "Dana" }
      }
    },
    {
      "id": "4183",
      "type": "order.paid",
      "subject_type": "order",
      "subject_id": "b5e1c9a7-2d4f-4a8b-9c3e-7f0d1a6b2e58",
      "created_at": "2026-11-27T10:14:03.512Z",
      "data": { "order": {}, "customer": {} }
    }
  ],
  "pagination": { "limit": 100, "next_after": "4183", "has_more": false }
}

The order objects are cut short here; real events carry the full order object.

ParameterDefaultDescription
afternoneOnly events with a higher id than this. Leave it out (or send 0) to start from the oldest event still kept.
typeevery typeOne event type, or several separated by commas: type=checkout.abandoned,order.created. An unknown type is refused with 422.
limit501 to 100.
FieldDescription
idThe event id, as a string. Ids only grow.
typeThe event type.
subject_typeWhat the event is about: order, checkout, customer or product.
subject_idThe order, checkout or product id. For customer.first_order, the customer's email (or phone, when the order had no email).
created_atWhen it happened.
dataThe payload, exactly as a webhook gets it in data. See Event types.
paginationDescription
limitThe page size used.
next_afterThe id to pass as after next time: the last event on this page. On an empty page it repeats the after you sent, or "0" when you sent none. Never null.
has_moretrue when more settled events are waiting right now. Call again with next_after at once.

A polling loop

Keep next_after somewhere that survives a restart, and only save it after you have handled the page.

poll-events.ts
const BASE = 'https://<admin host>/api/v1/stores/<storeId>'
const headers = { Authorization: `Bearer ${process.env.VITRINA_KEY}` }

export async function pollOnce(): Promise<void> {
  let after = await loadCursor() // null the first time
  for (;;) {
    const url = new URL(`${BASE}/events`)
    url.searchParams.set('limit', '100')
    if (after) url.searchParams.set('after', after)
    const res = await fetch(url, { headers })
    if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`)
    const { data, pagination } = await res.json()
    for (const event of data) {
      if (await alreadyHandled(event.id)) continue // the same id may also have come by webhook
      await handle(event)
    }
    after = pagination.next_after
    await saveCursor(after)
    if (!pagination.has_more) return
  }
}

// Every 30 seconds is plenty. Each call is one of the key's 240 a minute.
setInterval(() => void pollOnce().catch(console.error), 30_000)

The first run walks the store's history from the oldest event still kept (up to 90 days back), 100 at a time. To start from now instead, run through once without handling the events, then keep the cursor you end on.

Ordering

  • Events come back in id order, oldest first. Ids only grow, so after never returns an event you already passed.
  • Ids are shared by every store on Starsell, so a store's ids have gaps. A gap doesn't mean you missed an event.
  • Events from one change come in the order they happened: an order placed paid gives order.created, then order.paid, then customer.first_order when it is their first, then checkout.converted, then any stock events.

Events show once they have settled

An event gets its id when it is written, and becomes readable when the change it belongs to is saved, a moment later. So that a slow save can't make a lower id appear after a higher one you already moved after past, /events only returns events that have settled:

  • written more than 2 seconds ago, and
  • older than every change still being saved in the store's database at the time of your call.

The newest events wait for your next poll, so moving after to next_after every time doesn't step over an event whose change was saved late. If you also take webhooks, skip ids you have already handled: a webhook can bring an event before /events shows it.

How long events are kept

Events are kept for 90 days, then deleted by a daily cleanup. A few older ones stay a while longer:

  • an event a webhook delivery is still waiting to send, for example to a webhook that was turned off with retries queued,
  • an event an automation run is still waiting on, such as a run in a long wait step,
  • the store's latest event of each type, which test deliveries and automation tests use as their sample.

An after older than 90 days still works: you get the oldest events that are still kept. A poller that was down for longer than that has a gap; fill it from the lists (GET /orders?updated_after=...).

Use /events to keep up, not as an archive. An event is a snapshot of the order or product at that moment. For how things stand now, read the object itself (GET /orders/{orderId}), and for a full copy of the store, page through the lists.

Test deliveries sent to a webhook are never events: they don't appear here.

Poll or webhook

WebhooksPolling /events
DelaySecondsYour polling interval, plus the 2 seconds an event takes to settle
NeedsA public URL that answers within 10 secondsOnly outbound calls: works from a laptop, a cron job, behind a firewall
If your side is downRetried for a day, then the webhook turns off after 3 days of failuresNothing is lost: pick up from your cursor whenever you are back, within 90 days
OrderUsually in order; retries can arrive after later eventsAlways in id order
CostNothing on your rate limitOne call per poll, from the key's 240 a minute
ChecksVerify the signatureThe key is the check

Use webhooks when you want to react right away: an abandoned cart reminder, a Slack message for each order, a label printed when an order is paid.

Use /events when you can't take incoming requests, when you sync in batches (every 15 minutes, nightly), and to catch up after downtime longer than a day of retries, or while a webhook was off.

Use both for anything that must not miss an event: let webhooks drive the fast path, run a poll every few minutes or nightly as a safety net, and skip ids you have already handled. A webhook body's id is the event's id here, so one store of handled ids covers both.

Related: Webhooks, Pagination and limits, List events reference.

On this page