This REST API allows you to identify people, add or remove people from segments, and track events from your own websites or web applications. If you want to check our API libraries click here
Here is what we will cover:
Access to all the resources available via API is over HTTPS and from the host:
https://api.convertloop.co/v1/The API Endpoint to identify people and add or remove people from segments is:
https://api.convertloop.co/v1/peopleThe API Endpoint to track events is:
https://api.convertloop.co/v1/event_logsREST API requests will require a Basic Authentication with your app_id and api_key, which you can find in Settings -> Account once you are logged in.
We use JSON to send and receive information.
| Code | Name | Description | 
| 200 | OK | General success status code. The request is successful and its information is inlcuded in the HTTP/S response | 
| 400 | Bad Request | General error for when fulfilling the request would cause an invalid state. Domain validation errors, missing data, etc. are some examples. | 
| 401 | Unathorized | Error code response for missing or invalid authentication token | 
| 404 | Not Found | Used when the requested resource is not found | 
| 422 | Unprocessable Entity | The server is unable to process the request with the given information. | 
| 500 | Server Error | Internal server error. Please try again later. | 
This endpoint is used for both identifying people and adding or removing people from segments. You need to do an HTTP POST to the following URL:
https://api.convertloop.co/v1/peopleYou can use the following keys in the JSON you send to the URL (any other key will be treated as a custom attribute of the contact):
| Attribute | Description | Value data type | 
| pid | This is the unique cookie value for each contact. You can obtain this value from the cookie  dp_pid | string Required if emailoruser_idis not present. | 
| user_id | This is the the id of a specific user in your application. You can use it to match the user in your application with the contactin ConvertLoop when the person you want to identify is logged into your site. | string Required if pidoremailis not present | 
| email | This is the attribute to assign an email value to a specific person. | string Required if pidoruser_idis not present | 
| add_to_segments | This is the attribute to add a contactto one or several segments. Learn how | string Optional | 
| remove_from_segments | This is the attribute to remove a contactfrom one or several segments. Learn how | string Optional | 
| first_seen_at | This is the first date and time a personhas visited your App. This info is sent by default to ConvertLoop if you have installed your tracking code.Learn how to install it | datetime Optional | 
| last_seen_at | This is the last date and time a personhas visited your App. This info is sent by default to ConvertLoop if you have installed your tracking code.Learn how to install it. | datetime Optional | 
| resubscribe | This attribute allows you to automatically resubscribe a personthat have previously unsubscribe from your contacts by passing the attributeresubscribe: true | boolean Optional | 
Checkout the sections Identifying a person and Adding people to a segment to see examples using different programming languages.
To track an event you need to do an HTTP POST to the following URL:
https://api.convertloop.co/v1/event_logsYou can use the following keys in the JSON you send to the URL:
| Attribute | Description | Data type | 
| name | This is the attribute to assign a name to a custom event_log | string required | 
| occured_at | This is the date and time at which the event_loghas occurred. If you don't
        specify theocurred_atkey, the current time will be used | datetime optional | 
| person | You can use the personkey to add custom attributes to any specificpersonor to 
        add or remove people from segments, by passing{key:value}pairs to thepersonkey.
      Learn how | hash optional if not creating or updating a contact | 
| metadata | You can use the metadatakey to add  attributes related to the event you 
        are logging, by passing{key:value}pairs to themetadatakey.
      Learn how | hash optional | 
Checkout the section Tracking an event to see an example using different programming languages.