Custom Event API

Updated on October 2, 2024

The Custom Event API #

The custom event API allows you to insert bulk custom event data to Releva. Any insert submitted through this API will be live within 10 seconds of receiving a successful response.

Do I need to call it? #

Yes, if you want to update user profile data with custom events from your back end.

Request Parameters #

You may perform requests to the API using the following curl equivalent:

curl -H 'Content-Type: application/json' -H 'Authorization: Bearer <secretKey>' -XPOST https://releva.ai/api/v0/events -d'{
    "events": [
        {
            "locale": "bg",
            "action": "search",
            "products": [
                {"id": "123"},
                {"id": "456"},
                {"id": "789"}
            ],
            "custom": {
                "string": [
                    {
                        "key": "agent",
                        "values": [
                            "manual"
                        ]
                    },
                    {
                        "key": "name",
                        "values": [
                            "I. Z."
                        ]
                    },
                    {
                        "key": "imageURL",
                        "values": [
                            "https://....."
                        ]
                    },
.....
                ]
            },
            "email": "georgi@releva.ai"
        },
        {
            "locale": "bg",
            "action": "clicked",
            "products": [
                {
                  "id": "123",
                  "custom": {
                    "string": [
                      {"key": "color", "values": ["black"]}
                    ]
                  }
                },
                {"id": "456"},
                {"id": "789"}
            ],
            "phoneNumber": "+359123"
....
        }
    ]
}'

The products Array #

This object is an array of Objects with the following properties.

FieldTypeDescription
emailStringThe phoneNumber of the user this event refers to. Either this or “phoneNumber” needs to be set.
phoneNumberStringThe phoneNumber of the user this event refers to. Either this or “email” needs to be set.
actionStringThis is the name of the action this event refers to.
localeISO-639-1 StringIf you support multiple languages or currencies, set this to the current locale.
products[].idString (Optional)Products identifiers associated with this event.
products[].customObject (Optional)Product custom fields
timestampISO-8601 String (Optional)The date and time when this event happened.
customObject (Optional)The custom fields associated with the event.

Response Format #

A successful response will return HTTP Status 202 with an empty response body ({}).

An error response will return a HTTP 4xx or 5xx status code and have the following structure:

{
  "message": "A description of the error and how to fix it, if it's a client error."
}