Overview
The contact activities collection contains all contact-related activities, such as opens, clicks, sends, and any other custom actions you create. Contact activities are also referred to as events.
API set name: contactactivities
Additional information
- Contact activities are associated to the contact via the contact's primary or secondary identifier keys. Default primary and secondary contact identifier keys can be configured uniquely for each Cordial account based on your data infrastructure.
- A contact can have multiple contact activities documenting various action types.
- Actions taken within a message (reserved actions) will automatically generate an activity record. These include:
message-sentopenclickoptoutbouncecomplaintpageviewmessage-stopped
- You can also create custom event activities such as
browse,order,cart, etc. - Custom event activities can be added and acted upon through contact activities records in the Cordial database.
- Contact activity data will be stored for 18 months, after which it will be systematically purged.
Authentication
Cordial's core APIs use https Basic Authentication (BA). From within the Cordial platform, you can generate an encoded API key for your account and use it for authorization.
Resource associations
The following resource collections are associated to this collection.
| Collection | Association |
|---|---|
| contacts | Contacts are linked to their activities by their primary or secondary identifier key(s). |
Methods, parameters, examples
POST/v2/contactactivities
| Method | URL path |
|---|---|
| POST | /v2/contactactivities |
| Creates a new contact activity in the Cordial database using the appropriate JSON body. | |
-
* Required
Parameter Type Description Example * astring Defines a custom action you wish to create, such as browse, order, cart, or any other custom action. The maximum length of the parameter is 40 characters.
Note: Reserved actions cannot be added via the POST method.
browse* contact identifier string Unique primary or secondary contact identifier key/value pair to look up and reference the contact. You must specify the identifier type in the key/value pair. "email": "email@example.com""custID": "ID1234""cID:" "16198880000"atsstring Action timestamp. If undefined, the current date and time will be used. Date format is ISO 8601 standard. 2025-01-09 17:47:43propertiesobject An object of additional event attributes. The default maximum number of properties an event can have is 1,000.
Note: Property keys consisting of numeric-only values (e.g. 57) or keys containing a period, like
shoes.color, will be stripped.{"propertyOne": 1,"propertyTwo": 2}When a property value is passed, its data type (string, integer, etc.) will be recognized and searchable in the platform UI. If a different data type is passed to an already recognized property, that new data will not be searchable in the UI. It is necessary to create a new property if the data type will be changed.
-
The following will create a new contact activity record for a user-defined "browse" event.
{ "a": "browse", "email": "msmith@example.com", "ats": "2025-01-09 17:47:43", "properties": { "category": "Shirts", "url": "https://example.com/shirts", "description": "A really cool khaki shirt.", "price": 9.99, "title": "Khaki Shirt" } } -
The following URL in conjunction with the JSON will perform the POST.
httpss://<path>/v2/contactactivities
GET/v2/contactactivities
| Method | URL path |
|---|---|
| GET | /v2/contactactivities |
|
|
-
* Required
Parameter Type Description Example timestring The action timestamp for the action. can be searched with modifiers ( lt,gt,lte,gte,between.start,between.end).2025-01-09 17:47:43actionstring Can be click,open,message-sent, or any user-defined actions.alarmTriggeredcontact identifier string Unique contact identifier value to look up and reference the contact. Possible values: email, customer ID, contact ID. email@example.com,ID1234,16198880000sort_bystring Column to sort by. atssort_dirstring Direction to sort by. Works in conjunction with sort_by.
Possible values:asc,descdescpagenumber Specify the page number. 2per_pagenumber Number of results per page. The default is 25. 20return_countboolean The number of records returned. Default is false.true -
The GET /contactactivities endpoint can retrieve up to 10,000 records at a time. You can request all 10,000 records on a single page and use the provided URL with the paging token to query the next batch. The paging URL will appear as the first JSON object in your results when there are more records to show.
"paging": { "token": "5bbbbb56c4605038b4567", "next": "https://<path>/v2/contactactivities?per_page=10000&return_count=false&__paging_token=5bbbbb56c4605038b4567" }The paging token is not compatible with GET/v2/contactactivities endpoint. To page through more than 10,000 records using GET/v2/contactactivities, multiple queries must be made with manually adjusted parameters for each.
We recommend using POST/v2/contactactivityexport for exporting larger batches of contact activities.
-
The following URL will retrieve all contact activities.
httpss://<path>/v2/contactactivities
The following URL will retrieve all contact activities where the email address
msmith@example.comis the contact identifier.httpss://<path>/v2/contactactivities?email=msmith@example.com
The following URL will retrieve all contact activities where the
actionisbrowse.httpss://<path>/contactactivities?action=browse
The following URL will retrieve all contact activities where the
actionisbrowseand email addressmrsmith@example.comis the contact identifier.httpss://<path>/v2/contactactivities?action=browse&email=msmith@example.com
The following URL will retrieve all contacts but only include the contact activities that have occurred between the specified start date and end date.
httpss://<path>/v2/contactactivities?time[between][start]=2025-01-01&time[between][end]=2025-01-03
The following URL will retrieve all contacts but only include the
opencontact activities that have occurred between the specified start date and end date.httpss://<path>/v2/contactactivities?time[between][start]=2025-01-01&time[between][end]=2025-01-03&action=open
The following URL will retrieve all contact activities starting from the third page and grouping contact activities by 10 per page. For example, page 1 would have included the first 10, page 2 the second group of 10 and so on. Note: The default
per_pagevalue is 25.httpss://<path>/v2/contactactivities?page=3&per_page=10
The following URL will return a count of all contact activities in the request:
httpss://<path>/v2/contactactivities?return_count=true
Test in Swagger
You can access and test Cordial's APIs in Swagger.
Error responses
The Cordial API will return an error object with an errorKey and message if there is a problem with an API call. Below is a list of errors specific to the Contact Activities API endpoint, along with suggested modifications to resolve each error. If you receive an error from the Jobs API endpoint that is not listed in this table, it is likely recorded within the Global API error responses page.
errorKey |
Message | Modifications |
|---|---|---|
CONTACT_ACTIVITIES_INVALID_PAYLOAD |
Invalid payload | This can happen when the payload is empty. |
CONTACT_ACTIVITIES_VALIDATION_ERROR |
Validation error | Ensure the required values are input correctly. |
CONTACT_ACTIVITIES_INCORRECT_ACTION_NAME |
Incorrect action name | Check the input action name. |
CONTACT_ACTIVITIES_TOO_MANY_PARAMS |
Too many parameters | Six is the maximum number of parameters allowed for the payload. |
Comments
1 comment
This is for version one of the API, as the example has param: page=3; In v2 that is replace with the '__paging_token=########'
It would be great if you clearly showed which version of API is documented on this page somewhere.
Article is closed for comments.