Create custom event
Creates a new custom event
Endpoint
Section titled “Endpoint”HTTP method: POST
https://api.sender.net/v2/events
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
subscriber | object required | Subscriber identifier object. Must contain at least one of: id, email, or phone. |
subscriber.id | string | Subscriber’s ID. |
subscriber.email | string | Subscriber’s email address. |
subscriber.phone | string | Subscriber’s phone number (including country code). |
type | string required | The event type name (e.g. product_viewed). |
value | float | Optional numeric value associated with the event. |
value_currency | string | ISO 4217 currency code (e.g. USD, EUR). |
properties | object | A 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. |
Request Examples
Section titled “Request Examples”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", "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));$client = new \GuzzleHttp\Client();
$json = [ "subscriber" => { "id" => "Qmp2g5", "phone" => "+1xxxxxxxxx" }, "type" => "product_viewed", "value" => 6.7, "value_currency" => "USD", "properties" => { "string" => "wawaweewa", "int" => 123, "decimal" => 4.5, "bool" => false }];
$response = $client->post( 'https://api.sender.net/v2/events', [ 'headers' => [ 'Authorization' => 'Bearer [your-token]', 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], 'json' => $json ]);
$body = $response->getBody()->getContents();$data = json_decode($body, true);print_r($data);import requestsimport json
url = "https://api.sender.net/v2/events"
headers = { "Authorization": "Bearer [your-token]", "Content-Type": "application/json", "Accept": "application/json",}
payload = { "subscriber": { "id": "Qmp2g5", "phone": "+1xxxxxxxxx" }, "type": "product_viewed", "value": 6.7, "value_currency": "USD", "properties": { "string": "wawaweewa", "int": 123, "decimal": 4.5, "bool": false }}
response = requests.request('POST', url, headers=headers, json=payload)
print(response.json())curl -X POST \"https://api.sender.net/v2/events" \-H "Authorization: Bearer [your-token]" \-H "Content-Type: application/json" \-H "Accept: application/json" \-d '{"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}}'Response
Section titled “Response”{ "success": true, "message": "Event created"}