Contact activities (events) API – Cordial Knowledge Base

How can we help?

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

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
* a string 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"
ats string Action timestamp. If undefined, the current date and time will be used. Date format is ISO 8601 standard. 2025-01-09 17:47:43
properties object 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}

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
- Retrieves contact activities from the Cordial database.
- It's possible to retrieve contact activity records for all contacts or a specific contact.
- It's also possible to filter based on the date and time the contact activity occurred and by action names, such as opens, clicks or any user-defined action. Options for time values include: lt, gt, lte, gte, between.start, between.end.
- When retrieving a large number of contact activities, it is possible to apply per_page and page query string parameters to limit the count returned and page position.

* Required

Parameter Type Description Example
time string The action timestamp for the action. can be searched with modifiers (lt, gt, lte, gte, between.start, between.end). 2025-01-09 17:47:43
action string Can be click, open, message-sent, or any user-defined actions. alarmTriggered
contact identifier string Unique contact identifier value to look up and reference the contact. Possible values: email, customer ID, contact ID. email@example.com, ID1234, 16198880000
sort_by string Column to sort by. ats
sort_dir string Direction to sort by. Works in conjunction with sort_by.
Possible values:
asc, desc
desc
page number Specify the page number. 2
per_page number Number of results per page. The default is 25. 20
return_count boolean 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.com is the contact identifier.

httpss://<path>/v2/contactactivities?email=msmith@example.com

The following URL will retrieve all contact activities where the action is browse.

httpss://<path>/contactactivities?action=browse

The following URL will retrieve all contact activities where the action is browse and email address mrsmith@example.com is 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 open 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&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_page value 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

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.