Audience API makes it easy to complete tasks within Audience Studio and to automate repetitive marketing activities such as segment creation and campaign activations. Using Audience API, you can analyze the parent segment either as a group or on an individual profile level, and create targeted segments and journeys within that parent segment.
This functionality includes:
- Create parent segment and/or segments
- Create or schedule activations for your segments
- Create predictive segments and get your customers scored
- Additional Audience Studio features
By leveraging Audience API endpoints you can create an external application, tool, or CLI to automate common tasks. For example, you may want to integrate Audience API with your continuous deployment service to run tests or set up complex automations.
Regarding API Keys, please refer to this document
Get a list of segments In this case, you want to return a list of segments. This example issues a call to the API to return a list of your segments.
curl -i -X GET \
https://api-cdp.treasuredata.com/audiences/:audienceId/segments \
-H 'Authorization: TD1 YOUR_API_KEY_HERE'[
{
"audienceId": 0,
"id": 0,
"name": "string",
"realtime": true,
"kind": 0,
"description": "string",
"segmentFolderId": 0,
"population": 0,
"createdAt": "2019-08-24T14:15:22Z",
"updatedAt": "2019-08-24T14:15:22Z",
"createdBy": {
"id": "string",
"name": "string"
},
"updatedBy": {
"id": "string",
"name": "string"
},
"rule": {
"type": "And",
"conditions": [
{}
]
}
}
]You might want to create many new segments automatically. URI: https://api-cdp.treasuredata.com/audiences/{audienceId}/segments
curl -i -X POST \
https://api-cdp.treasuredata.com/audiences/:audienceId/segments \
-H 'Authorization: TD1 YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"audienceId": 0,
"name": "string",
"kind": 0,
"funnel_stage": {
"funnel_id": 0,
"stage_id": 0
},
"description": "string",
"segmentFolderId": 0,
"rule": {
"type": "And",
"conditions": [
{}
]
},
"countPopulation": true
}'{
"code": "string",
"message": "string"
}You might want to submit a query to fetch a list of profiles and number of profiles produced by a set of segment rules.
curl -i -X POST \
https://api-cdp.treasuredata.com/audiences/:audienceId/segments/queries \
-H 'Authorization: TD1 YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"columns": [
"string"
],
"kind": 0,
"rule": {
"type": "And",
"conditions": [
{}
]
},
"funnel_stage": {
"funnel_id": 0,
"stage_id": 0
}
}'{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"queryId": "10210520-b895-40ca-bce5-474f9643bf53",
"status": "success",
"count": 0,
"maxPage": 0,
"error": "string",
"jobid": "string",
"countJobid": "string"
}You might need to create a new activation (formerly syndication) for your segments.
curl -i -X POST \
https://api-cdp.treasuredata.com/audiences/:audienceId/segments/:segmentId/syndications \
-H 'Authorization: TD1 YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"name": "string",
"description": "string",
"allColumns": true,
"columns": [
{
"column": "campaign",
"source": {
"parameters": [
{
"string": "c0001",
"type": "String"
}
],
"string": "$1"
}
}
],
"scheduleType": "daily",
"scheduleOption": "string",
"runAt": "string",
"cron": "string",
"timezone": "string",
"connectionId": 0,
"connectorConfig": {},
"notifyOn": [
"onSuccess"
],
"emailRecipients": [
0
]
}'{
"code": "string",
"message": "string"
}