Documentation · API reference
POST
/api/v1/sites/{site}/events/batchSend events in a batch
This page as Markdown, or in an AI chatMore ways to read this page
Up to 500 events in one request. A malformed one refuses the batch before any of it is counted.
# Send events in a batch
> tidekeeper's API reference: https://tidekeeper.eu/docs/api/post-sites-site-events-batch
`POST /api/v1/sites/{site}/events/batch`
Up to 500 events in one request. A malformed one refuses the batch before any of it is counted.
## What to send
`A list of EventIn`: An event sent from a backend (IN-09), counted on the same model as one the script sends.
- `currency` (string or null)
- `name` (string or null): The event's name. Leave it out to count a view.
- `props` (object)
- `referrer` (string or null)
- `url` (string, needed): The page it happened on: a full address on one of the site's hostnames.
- `value` (number or null): An amount with its currency: `{ "amount": 29.0, "currency": "EUR" }`.
- `visitor` (EventVisitor or null)
## The answer
202, `EventsTaken`: What became of a batch of events.
- `counted` (integer, needed)
- `left_out` (integer, needed)
- `repeated` (boolean, needed): The whole batch was sent before under the same key, and counts nothing.
- `why` (object, needed): Why, and how many for each reason.
## Asking
```sh
curl -X POST https://tidekeeper.eu/api/v1/sites/example.org/events/batch \
-H "Authorization: Bearer $TIDEKEEPER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"url": "…"}'
```
What to send
A list of EventIn An event sent from a backend (IN-09), counted on the same model as one the script sends.
- currency
- string or null
- name
- string or nullThe event's name. Leave it out to count a view.
- props
- object
- referrer
- string or null
- url
- stringneededThe page it happened on: a full address on one of the site's hostnames.
- value
- number or nullAn amount with its currency: `{ "amount": 29.0, "currency": "EUR" }`.
- visitor
- EventVisitor or null
The answer
Status 202
EventsTaken What became of a batch of events.
- counted
- integerneeded
- left_out
- integerneeded
- repeated
- booleanneededThe whole batch was sent before under the same key, and counts nothing.
- why
- objectneededWhy, and how many for each reason.
Asking
curl -X POST https://tidekeeper.eu/api/v1/sites/example.org/events/batch \ -H "Authorization: Bearer $TIDEKEEPER_TOKEN" \ -H "Content-Type: application/json" \ -d '{"url": "…"}'
const answer = await fetch("https://tidekeeper.eu/api/v1/sites/example.org/events/batch", { method: "POST", headers: { Authorization: `Bearer ${process.env.TIDEKEEPER_TOKEN}`, "Content-Type": "application/json", }, body: JSON.stringify({"url": "…"}), }).then((r) => r.json());