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 byemail. - 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.
| Field | Notes |
|---|---|
messageId | Your stable ID, such as an order ID. Makes retries safe. |
properties.revenue | Major currency units: 49, not 4900. |
properties.url | On 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.