Send an event
const url = 'https://api.pristo.io/v1/events/send';const options = { method: 'POST', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"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"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
The unique identifier of an event type declared in the population, for example purchase. Event-based distributions select events by this value.
The contact the event happened to. Fields you leave out keep their stored values, except language.
object
Your identifier for the contact. An existing contact with this ID (ignoring case) is updated; otherwise a new contact is created.
The contact’s email address. An invalid address is ignored.
An Israeli mobile number, such as +972501234567 or 0501234567. Other numbers are stored but cannot receive SMS.
First name. Values longer than 50 characters are cut to 50.
Last name. Values longer than 50 characters are cut to 50.
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.
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
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
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" }}Responses
Section titled “Responses”The event was stored. Contact updates and sends happen afterwards, in the background.
object
The stored event’s 22-character short ID.
Example
{ "eventId": "AbCdEfGhIjKlMnOpQrStUv"}The request is invalid. Plain-text messages:
Payload size exceeds the maximum allowed size of 10000 bytescontact is requiredtype is required and must be between 1 and 50 characters longcontact.id is required and must be between 1 and 50 characters longValue is invalid: theX-API-Keyvalue is shorter than 24 characters, ortypeorcontact.idcontains only spaces.
A missing body, invalid JSON or a field of the wrong JSON type returns a JSON problem body instead.
Example
type is required and must be between 1 and 50 characters longAn RFC 9457 problem body.
object
Examplegenerated
{ "type": "example", "title": "example", "status": 1, "detail": "example", "traceId": "example"}The X-API-Key header is missing or empty, or the key does not match an active key (wrong, deactivated or deleted).
An RFC 9457 problem body.
object
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).
Example
no population is associated with this api keyThe Content-Type header is not application/json.
An RFC 9457 problem body.
object
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
Examplegenerated
{ "type": "example", "title": "example", "status": 1, "detail": "example", "traceId": "example"}Example
Internal server error