How can we help?

Contact Activities (Events) API

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 the client's 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-sent
    • open
    • click
    • optout
    • bounce
    • complaint
    • pageview
    • message-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.

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).

POST /contactactivities

Method URI Path
POST /contactactivities
Creates a new contact activity in the Cordial database using the appropriate JSON body.

Parameters

* 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. email@example.com, ID1234, 16198880000
ats string Action timestamp. If undefined, the current date and time will be used. Date format is ISO 8601 standard.

2018-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 that property keys consisting of numeric-only values (e.g. 57) or keys containing a "dot" (e.g. shoes.color) will be stripped.

{"propertyOne": 1,
"propertyTwo": 2}

Warning: 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 is to be changed.

Example JSON request

The following will create a new contact activity record for a user-defined "browse" event.

{
    "a": "browse",
    "email": "msmith@example.com",
    "ats": "2018-01-09 17:47:43",
    "properties": {
        "category": "Shirts",
        "url": "http://example.com/shirts",
        "description": "A really cool khaki shirt.",
        "price": 9.99,
        "title": "Khaki Shirt"
    }
}

Example request URI

The following URI in conjunction with the JSON will perform the POST.

http://<path>/contactactivities

GET /contactactivities

Method URI Path
GET /contactactivities
Retrieves contact activities from the Cordial database.

It is possible to retrieve contact activity records for all contacts or a specific contact.

It is 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.

Parameters

* 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). 2018-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. 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

Paging and retrieval limits

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 URI with the paging token to query the next batch. The paging URI will appear as the first JSON object in your results when there are more records to show.

"paging": {
    "token": "5bbbbb56c4605038b4567",
    "next": "http://<path>/v2/contactactivities?per_page=10000&return_count=false&__paging_token=5bbbbb56c4605038b4567"
  }
Note: The paging token is not compatible with GET /v1/contactactivities endpoint. To page through more than 10,000 records using GET /v1/contactactivities, multiple queries must be made with manually adjusted parameters for each.
Tip: We recommend using POST /v2/contactactivityexport for exporting larger batches of contact activities.

Example request URIs

The following URI will retrieve all contact activities.

http://<path>/contactactivities

The following URI will retrieve all contact activities where the email address "msmith@example.com" is the contact identifier.

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

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

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

The following URI will retrieve all contact activities where the action is "browse" and email address "msmith@example.com" is the contact identifier.

http://<path>/contactactivities?action=browse&email=msmith@example.com

The following URI will retrieve all contacts but only include the contact activities that have occurred between the specified start date and end date.

http://<path>/contactactivities?time[between][start]=2018-01-01&time[between][end]=2018-01-03

The following URI will retrieve all contacts but only include the "open" contact activities that have occurred between the specified start date and end date.

http://<path>/contactactivities?time[between][start]=2018-01-01&time[between][end]=2018-01-03&action=open

The following URI will retrieve all contact activities starting from the 3rd 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.

http://<path>/contactactivities?page=3&per_page=10

The following URI will return a count of all contact activities in the request:

http://<path>/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 params Six is the maximum number of parameters allowed for the payload.

Comments

1 comment

  • Comment author
    Judith Lebzelter

    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.

    0

Article is closed for comments.