Skip to content
snagr
Snagr docs

HTTP API

Send events to Snagr and read a visitor's flags and nudges.

POST /api/v1/batch

Send one or more identify or track messages.

  • From your server: Authorization: Bearer snagr_sk_…. You can identify people by email.
  • From the browser: the SDK sends these for you with your publishable key.
curl https://www.snagr.sh/api/v1/batch \
  -H "Authorization: Bearer $SNAGR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "batch": [{
      "type": "track",
      "email": "sam@example.com",
      "event": "purchase_completed",
      "messageId": "order_123",
      "properties": { "revenue": 49, "currency": "USD" }
    }]
  }'

Each message needs type, and a track message needs event. Identify the person with anonymousId, userId or (server only) email. The response has a results array with an ok flag per message, so check every item.

FieldNotes
messageIdYour stable ID, such as an order ID. Makes retries safe.
properties.revenueMajor currency units: 49, not 4900.
properties.urlOn start events, where the follow-up links back to.

GET /api/v1/state

Returns a visitor's active flags and nudges. The browser SDK calls this for you.

GET /api/v1/state?key=snagr_pk_…&anonymousId=…&userId=…

Read-only, publishable key only.

Machine-readable

The full schema is at /openapi.json.