RESTful API |
|
Summary |
|
|
When you need a bit more control, you can create/update customers and track custom events through out RESTful API. This is a currently a write-only API. |
API Endpoint
https://track.customer.io/api
Summary of URL patterns
/v1/customers/{CUSTOMER_ID}
/v1/customers/{CUSTOMER_ID}/events |
Authentication |
|
|
All requests to the Customer.io API must be authenticated via HTTP Basic Auth. Also, HTTPS must be used for all API requests. Any attempts to use HTTP will result in failure. To authenticate, you provide your same site id used in the javascript snippet above as the username, and your secret API key as the password. You can find these values in the tracking area. |
Example request
curl -i https://track.customer.io/api/v1/customers/5/events \
-u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \
-d name=eventName |
Errors |
|
|
Customer.io uses conventional HTTP response codes to indicate success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the provided information (e.g. a required parameter was missing, a charge failed, etc.), and codes in the 5xx range indicate an error with Customer.io’s servers. |
HTTP Status Code Summary
200 OK - Everything worked as expected.
400 Bad Request - Often missing a required parameter.
401 Unauthorized - No valid API key provided.
404 Not Found - The requested item does not exist.
500, 502, 503, 504 Server errors - something went wrong on our end. |
Creating or updating customers |
|
|
Creating or updating customers via the API accomplishes the same goal as
the Arguments
POST data
ResponseA 200 response code signifies the customer was created or updated. All other response codes mean something went wrong. You can use the errors section above to diagnose the error. |
Definition
PUT https://track.customer.io/api/v1/customers/{CUSTOMER_ID}
Example request
curl -i https://track.customer.io/api/v1/customers/5 \
-X PUT \
-u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \
-d email=customer@example.com \
-d name=Bob \
-d plan=premium
|
Deleting customers |
|
|
Deleting a customer will remove them, and all their information from Customer.io. Note: if you’re still sending data to Customer.io via other means (such as the javascript snippet), the customer could be recreated. Arguments
ResponseA 200 response code signifies the customer was created or updated. All other response codes mean something went wrong. You can use the errors section above to diagnose the error. |
Definition
DELETE https://track.customer.io/api/v1/customers/{CUSTOMER_ID}
Example request
curl -i https://track.customer.io/api/v1/customers/5 \
-X DELETE \
-u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE |
Track a custom event |
|
|
To send an event to Customer.io outside of the browser, say from your server side code, you can POST to the events resource for a given customer. Arguments
POST data
ResponseA 200 response code signifies the event was successfully tracked. All other response codes mean something went wrong. You can use the errors section above to diagnose the error. |
Definition
POST https://track.customer.io/api/v1/customers/{CUSTOMER_ID}/events
Example request
curl -i https://track.customer.io/api/v1/customers/5/events \
-u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \
-d name=purchased \
-d data[price]=23.45 |