Track Your First Custom Event
Custom events allow you to record specific actions your contacts take — like abandoning a cart or making a purchase — and associate those actions with additional metadata.
This guide walks you through sending your first custom event using the SendX REST API.
1. Prerequisites
Before you begin:
Your API Key is required for authentication. Keep it private and secure.
2. Push a Custom Event
Use the /events/custom endpoint to track a user action with optional metadata.
curl --request POST \
--url https://api.sendx.io/api/v1/rest/events/custom \
--header 'Content-Type: application/json' \
--header 'X-Team-ApiKey: <YOUR_TEAM_API_KEY>' \
--data '{
"name": "abandoned_cart",
"identifier": "john.doe@example.com",
"data": {
"price": "29.99",
"currency": "USD",
"item_count": "3"
},
"time": 1669990400
}'
import requests
url = "https://api.sendx.io/api/v1/rest/events/custom"
payload = {
"name" : "abandoned_cart" ,
"identifier" : "john.doe@example.com" ,
"data" : {
"price" : "29.99" ,
"currency" : "USD" ,
"item_count" : "3"
},
"time" : 1669990400 # Optional: Unix timestamp in seconds
}
headers = {
"X-Team-ApiKey" : "<YOUR_TEAM_API_KEY>" ,
"Content-Type" : "application/json"
}
response = requests.post(url, json = payload, headers = headers)
print (response.text)
package main
import (
" fmt "
" strings "
" net/http "
" io/ioutil "
)
func main () {
url := "https://api.sendx.io/api/v1/rest/events/custom"
payload := strings . NewReader ( `{
"name": "abandoned_cart",
"identifier": "john.doe@example.com",
"data": {
"price": "29.99",
"currency": "USD",
"item_count": "3"
},
"time": 1669990400
}` )
req , _ := http . NewRequest ( "POST" , url , payload )
req . Header . Add ( "X-Team-ApiKey" , "<YOUR_TEAM_API_KEY>" )
req . Header . Add ( "Content-Type" , "application/json" )
res , _ := http . DefaultClient . Do ( req )
defer res . Body . Close ()
body , _ := ioutil . ReadAll ( res . Body )
fmt . Println ( string ( body ))
}
HttpResponse < String > response = Unirest . post ( "https://api.sendx.io/api/v1/rest/events/custom" )
. header ( "X-Team-ApiKey" , "<YOUR_TEAM_API_KEY>" )
. header ( "Content-Type" , "application/json" )
. body ( "{ \n \" name \" : \" abandoned_cart \" , \n \" identifier \" : \" john.doe@example.com \" , \n \" data \" : { \n \" price \" : \" 29.99 \" , \n \" currency \" : \" USD \" , \n \" item_count \" : \" 3 \"\n }, \n \" time \" : 1669990400 \n }" )
. asString ();
What This Does
This request records an event named abandoned_cart for the contact john.doe@example.com, along with additional metadata:
price: 29.99
currency: USD
item_count: 3
time: 1669990400 (optional - if omitted, server will use current time)
Custom Events API Learn more about how to track custom events with additional data.
3. Next Steps
Once you’ve recorded events, you can:
Segment contacts based on event properties
Trigger automations using event names
Analyze custom events in your dashboard
Explore the full API Reference to see what’s possible.