Skip to content

Create custom event

Creates a new custom event

HTTP method: POST

https://api.sender.net/v2/events


ParameterTypeDescription
subscriberobject requiredSubscriber identifier object. Must contain at least one of: id, email, or phone.
subscriber.idstringSubscriber’s ID.
subscriber.emailstringSubscriber’s email address.
subscriber.phonestringSubscriber’s phone number (including country code).
typestring requiredThe event type name (e.g. product_viewed).
valuefloatOptional numeric value associated with the event.
value_currencystringISO 4217 currency code (e.g. USD, EUR).
propertiesobjectA flat key-value map of custom properties. Values may be strings, integers, decimals, dates, or booleans. Text values must not exceed 2KB; total properties size must not exceed 8KB.

const url = new URL("https://api.sender.net/v2/events");
let headers = {
"Authorization": "Bearer [your-token]",
"Content-Type": "application/json",
"Accept": "application/json",
};
let bodyContent = {
"subscriber": {
"id": "Qmp2g5",
"email": "[email protected]",
"phone": "+1xxxxxxxxx"
},
"type": "product_viewed",
"value": 6.7,
"value_currency": "USD",
"properties": {
"string": "wawaweewa",
"int": 123,
"decimal": 4.5,
"bool": false
}
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(bodyContent)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

Example Response
{
"success": true,
"message": "Event created"
}