How to retrieve activities summary
Use the /reports/contact_reports/{contact_id}/activity_summary
endpoint to retrieve a list of recent email campaigns sent to a specific contact and a summary of the email campaign activities the contact had with that email campaign. Activity types include:
em_sends
em_opens
em_clicks
em_bounces
em_optouts
em_forwards
The endpoint requires two query parameters, start
and end
, that define a date range for the report. The start
and end
query parameters must be provided in ISO 8601 format. For example, 2018-08-16T12:30:00Z
. The response will include the most recent 200 email campaigns with a pagination link to the next 200 emails.
Example GET Request
GET https://api.cc.email/v3/reports/contact_reports/{contact_id}/activity_summary
Endpoint Requirements
User privileges: ui:campaign:metrics
Authorization scopes: contact_data
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cc.email/v3/reports/contact_reports/{contact_id}/activity_summary');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'start' => '2018-01-01T00:00:00.000Z',
'end' => '2018-08-09T00:00:00.000Z'
));
$request->setHeaders(array(
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Bearer {access_token}',
'Cache-Control' => 'no-cache'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
curl -X GET \
'https://api.cc.email/v3/reports/contact_reports/{contact_id}/activity_summary?start=2018-01-01T00:00:00.000Z&end=2018-08-09T00:00:00.000Z' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {access_token}' \
-H 'Cache-Control: no-cache'
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cc.email/v3/reports/contact_reports/{contact_id}/activity_summary?start=2018-01-01T00:00:00.000Z&end=2018-08-09T00:00:00.000Z")
.get()
.addHeader("Accept", "application/json")
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer {access_token}")
.addHeader("Cache-Control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Example GET Response
{
"contact_id": "71600990-908b-11e6-907f-00166bff25",
"campaign_activities": [
{
"campaign_activity_id": "string",
"start_on": "2018-08-06T15:10:22.269Z",
"em_bounces": 0,
"em_clicks": 0,
"em_forwards": 0,
"em_opens": 0,
"em_sends": 0,
"em_unsubscribes": 0
}
],
"_links": {
"next": {
"href": "/v3/activities/{actvity_id}"
}
}
}