Skip to contentSkip to navigationSkip to topbar
Page tools
Useful for sharing or LLM
Accelerate development with AI

On this page
Looking for more inspiration?Visit the

Retrieving profiles


Paging through profiles

paging-through-profiles page anchor

After a snapshot operation completes, you can retrieve its matching profiles from the Snapshot Profiles endpoint.

1
curl -X GET 'https://audiences.twilio.com/preview/CohortSnapshots/cmp_cohortsnapshot_01h9d8r0vte3hz8tykdj329t7r/Profiles' \
2
-u $TWILIO_API_KEY:$TWILIO_API_SECRET

Each profile entry includes a profileId and a variables object that contains the data fields you projected when you created the snapshot. If you omitted variables during creation, only profileId is returned.

1
{
2
"profiles": [
3
{
4
"profileId": "mem_profile_01h9d8r0vte3hz8tykdj329t7r",
5
"variables": {
6
"email": "jane@example.com"
7
}
8
}
9
],
10
"meta": {
11
"key": "profiles",
12
"pageSize": 50,
13
"nextToken": "eyJvZmZzZXQiOjUwfQ"
14
}
15
}

The meta.nextToken field appears whenever additional pages remain. Pass its value back as the pageToken query parameter to fetch the next page. Continue this process until nextToken is no longer present in the response.


Large snapshots and parallel processing

large-snapshots-and-parallel-processing page anchor

For snapshots that match many profiles, Twilio splits the results across multiple partitions so that you can retrieve them with parallel worker threads.

First, request the snapshot resource to determine its partitionCount.

1
curl -X GET 'https://audiences.twilio.com/preview/CohortSnapshots/cmp_cohortsnapshot_01h9d8r0vte3hz8tykdj329t7r' \
2
-u $TWILIO_API_KEY:$TWILIO_API_SECRET

Sample response:

1
{
2
"cohortSnapshotId": "cmp_cohortsnapshot_01h9d8r0vte3hz8tykdj329t7r",
3
"partitionCount": 4,
4
"profileCount": 42000,
5
"labels": {
6
"key": "value"
7
}
8
}

Then request each partition independently by using the partition query parameter:

1
curl -X GET 'https://audiences.twilio.com/preview/CohortSnapshots/cmp_cohortsnapshot_01h9d8r0vte3hz8tykdj329t7r/Profiles?partition=0' \
2
-u $TWILIO_API_KEY:$TWILIO_API_SECRET

By default, Cohorts calculates the optimal partitionCount based on the snapshot's total profile volume.

(information)

Info

If your downstream processing architecture requires a specific thread count or chunk size, you can pass partitionCountOverride (up to 500) when you call Create Snapshot. You can also pass profileLimit if you want to retrieve only a capped sample of matching profiles.

Partitioning rules

partitioning-rules page anchor
  • Zero-based indexing: Partition indices are zero-based, ranging from 0 through partitionCount - 1. Passing an index outside this range returns HTTP 400 Bad Request.
  • Independent pagination: Each partition paginates independently by using pageToken until its own nextToken field is absent.
  • No duplicate profiles: Retrieving partitions in parallel is thread-safe and ensures that no profile appears in more than one partition.
  • Empty partitions: When you set the partitionCountOverride parameter, some partitions might not contain any profiles. This happens when you request more partitions than there are matching profiles to distribute. For example, if you set partitionCountOverride to 500 and the snapshot contains 10 profiles, most partitions are empty. If you request one of these partitions, the response includes an empty profiles array ("profiles": []). Consider the partition complete and proceed to the next partition.