Custom events
NeoDay can be fed events from other systems you have deployed. These events can be used to trigger any campaign you have configured. The events can contain data according to a schema defined by you and you are able to read from that data when configuring campaigns in NeoDay.
Defining events
Before you can send events into the terminal their schema has to be defined. The schema is defined using JSON Schema. The $id
must be in the format of https://gateway.{customer}.neo.day/api/1/terminal/events/{event_name}
. The schema can be defined by sending a PUT
request to the $id
URI:
PUT /api/1/terminal/events/my_event?locale=en_GB HTTP/1.1
Host: gateway.acme.neo.day
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9........
Content-Type: application/json
{
"$id": "https://gateway.acme.neo.day/api/1/terminal/events/my_event",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "My example event",
"type": "object",
"properties": {
"some_value": {
"type": "string",
"description": "Some string value."
},
"another_value": {
"description": "An integer value",
"type": "integer",
"minimum": 0
}
}
}
HTTP/1.1 200 OK
Content-Type: application/json
Sending events
Events must be submitted in the context of a single user. The endpoint for submitting an event is /api/1/terminal/{user_id}/events/{event_name}
. Where the {event_name}
must match one of the events you have defined previously. This request requires an Authorization
header that contains an access token obtained via the client-credentials
grant.
For example:
POST /api/1/terminal/r8d0h8nfx09w23o64g63rvk7q/events/my_event?locale=en_GB HTTP/1.1
Host: gateway.acme.neo.day
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9........
Content-Type: application/json
{
"some_value": "abcd",
"another_value": 100
}
HTTP/1.1 202 Accepted
Content-Type: application/json
The received events will be processed asynchronously. This may result in a slight delay between sending the event and the user being rewarded.