is there a way to get the user information from a cohort on an api call?
Hi Emanuel F., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> ๐
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
Yes, you can retrieve user information from a Mixpanel cohort using the Engage API. Here's how to do it:
You'll need to use the /engage endpoint with the filter_by_cohort parameter to query profiles that belong to a specific cohort.
First, you can find your cohort ID either in the UI next to your cohort or by using the cohorts-list API which returns all cohorts in your project along with their IDs.
Then, make a request to the Engage API like this:
```
curl --request POST --url 'https://mixpanel.com/api/query/engage?project_id=YOUR_PROJECT_ID' --header 'accept: application/json' --header 'authorization: Basic YOUR_TOKEN' --header 'content-type: application/x-www-form-urlencoded' --data 'filter_by_cohort={"id":YOUR_COHORT_ID}'
LBKSThe response will contain user profiles in the results key, with each profile as an object containing the distinct_id and properties:
LBKS```
{
"page": 0,
"page_size": 1000,
"results": [
{
"$distinct_id": "user1",
"$properties": {
"$email": "example@โ[mixpanel.com](http://mixpanel.com)",
"$first_name": "Example",
"$last_name": "User",
// other properties
}
},
// more user profiles
],
"session_id": "session-id",
"status": "ok",
"total": 100
}
You can also specify which profile properties to return using the output_properties parameter to reduce the amount of data returned:
```
output_properties=["$last_name", "$email", "Total Spent"]
LBKSThe API has a rate limit of 60 queries per hour and a maximum of 5 concurrent queries, so plan your requests accordingly.
[Query API - Engage](https://github.com/mixpanel/docs/blob/main/openapi/src/query.openapi.yaml) [Cohorts List](https://github.com/mixpanel/docs/blob/main/reference/Query%20API/cohorts/cohorts-list.md) [Engage Query](https://github.com/mixpanel/docs/blob/main/reference/Query%20API/engage/engage-query.md)
kapa.ai is still learning and improving, please let me know how I did by reacting below.
โน๏ธย Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
