Skip to content

API reference / Report an event

Report an event

How a browser reports a click, an action button or a dismissal back to Push.

POST/v1/events
Auth None. The browser's event token in the body is the credential.

Push's service worker sends this when the person clicks a notification, clicks one of its buttons or dismisses it. You never call it; read the results with Get a notification. See browser events.

Request#

Body#

browserId
stringrequired
The browser reporting the event.
Rules
UUID
eventToken
stringrequired
The token the browser received when it connected. It must match browserId.
Rules
1–128 characters
attemptId
stringrequired
The attempt that showed the notification. It must belong to browserId.
Rules
UUID
type
stringrequired
What the person did.
Rules
click, action or close
action
stringoptional
The id of the button that was clicked.
Rules
^[a-z0-9][a-z0-9_-]{0,31}$; required when type is action

Response#

200 OK with { "ok": true }, also when the event changes nothing.

  • click and action set the attempt's clickedAt, and action also sets actionClicked. Only the first click is kept.
  • close sets closedAt. Only the first dismissal is kept.

Errors#

CodeHTTPWhen
VALIDATION_ERROR400The body is not valid JSON, is over 16,384 bytes or breaks a field rule, or type is action without action.
UNAUTHORIZED401browserId is not a UUID or eventToken does not match it. The message is “Invalid event token”.
NOT_FOUND404The attempt does not exist or belongs to another browser. The message is “Attempt not found”.
RATE_LIMITED429More than 300 event and disconnect requests a minute from one IP address.
INTERNAL_ERROR500Something failed on Push's side. It is safe to retry.

Example#

⫻

curl

curl https://api.meslzy.com/push/v1/events \  -H "Content-Type: application/json" \  -d '{  "browserId": "0198f0aa-1c2d-7e3f-9a4b-5c6d7e8f9012",  "eventToken": "kq3Vd9xZr2Lm8Tn4Bw6Yc1Hs7Pf5Gj0Ae2Ui9Ok4Rt8",  "attemptId": "0199b1c2-7a52-7aa0-8c11-5d0e4f3b2a91",  "type": "action",  "action": "open"}'

⫻

200 OK

HTTP/1.1 200 OKContent-Type: application/jsonX-Request-Id: req_0199b1c27a4e7c3d9f1e2b6a8d4c5e11
{  "ok": true}