Skip to content

Send an event

POST
/v1/events/send
curl --request POST \
--url https://api.pristo.io/v1/events/send \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <X-API-Key>' \
--data '{ "type": "purchase", "contact": { "id": "CUST-1042", "email": "dana@example.com", "phone": "+972501234567", "name": "Dana", "lastName": "Example", "language": "en", "customFields": { "tier": "gold" } }, "customFields": { "branch": "example_branch", "amount": "120" } }'

Records an event for a contact in the population of the API key’s program. The event is stored at once; a background job then creates or updates the contact (matched by contact.id) and checks the active event-based distributions. Each distribution that selects this event type, and whose filters the event and the contact match, schedules its questionnaire by SMS or email.

Media typeapplication/json
object
type
required

The unique identifier of an event type declared in the population, for example purchase. Event-based distributions select events by this value.

string
>= 1 characters <= 50 characters
contact
required

The contact the event happened to. Fields you leave out keep their stored values, except language.

object
id
required

Your identifier for the contact. An existing contact with this ID (ignoring case) is updated; otherwise a new contact is created.

string
>= 1 characters <= 50 characters
email

The contact’s email address. An invalid address is ignored.

string
phone

An Israeli mobile number, such as +972501234567 or 0501234567. Other numbers are stored but cannot receive SMS.

string
name

First name. Values longer than 50 characters are cut to 50.

string
lastName

Last name. Values longer than 50 characters are cut to 50.

string
language

Two-letter language code (ISO 639-1), for example en, es or he. If it is missing, the contact gets the population’s default language.

string
customFields

Contact attribute values, keyed by each contact attribute’s unique identifier in the population (matched ignoring case). Values are usually strings; other JSON values are converted to text. Unknown keys, empty values and values that do not fit the attribute’s type are ignored.

object
key
additional properties
any
customFields

Event attribute values, keyed by each event attribute’s unique identifier in the population. Distribution event filters compare them as text, so send strings. The API does not validate them.

object
key
additional properties
any
Example
{
"type": "purchase",
"contact": {
"id": "CUST-1042",
"email": "dana@example.com",
"phone": "+972501234567",
"name": "Dana",
"lastName": "Example",
"language": "en",
"customFields": {
"tier": "gold"
}
},
"customFields": {
"branch": "example_branch",
"amount": "120"
}
}

The event was stored. Contact updates and sends happen afterwards, in the background.

Media typeapplication/json
object
eventId
required

The stored event’s 22-character short ID.

string
>= 22 characters <= 22 characters
Example
{
"eventId": "AbCdEfGhIjKlMnOpQrStUv"
}

The request is invalid. Plain-text messages:

  • Payload size exceeds the maximum allowed size of 10000 bytes
  • contact is required
  • type is required and must be between 1 and 50 characters long
  • contact.id is required and must be between 1 and 50 characters long
  • Value is invalid: the X-API-Key value is shorter than 24 characters, or type or contact.id contains only spaces.

A missing body, invalid JSON or a field of the wrong JSON type returns a JSON problem body instead.

string
Example
type is required and must be between 1 and 50 characters long

The X-API-Key header is missing or empty, or the key does not match an active key (wrong, deactivated or deleted).

Media typeapplication/problem+json

An RFC 9457 problem body.

object
type
string
title
string
status
integer
detail
string
traceId
string
Example
{
"title": "Unauthorized",
"status": 401
}

The API key’s program has no population (no population is associated with this api key), or the population could not be found when the event was saved (Population with id not found).

Media typetext/plain
string
Example
no population is associated with this api key

The Content-Type header is not application/json.

Media typeapplication/problem+json

An RFC 9457 problem body.

object
type
string
title
string
status
integer
detail
string
traceId
string
Example
{
"title": "Unsupported Media Type",
"status": 415
}

The server could not complete the request. A failure while saving returns a JSON problem body with detail; an unexpected failure returns the plain-text body Internal server error.

An RFC 9457 problem body.

object
type
string
title
string
status
integer
detail
string
traceId
string
Examplegenerated
{
"type": "example",
"title": "example",
"status": 1,
"detail": "example",
"traceId": "example"
}