Create cohort
https://api.faraday.ai/v1/cohortsAdd a new cohort (defined as people who have made qualifying emissions of certain events)
Authentication
Provide your API key in the Authorization header. You can find your API key in the Settings page of the dashboard.
Authorization: Bearer YOUR_TOKENBody
The definition of the new cohort
explorebooleanWhether to show the Cohort in Explore, the map view on https://app.faraday.ai.
This will slow down Cohort builds.
falseHuman-readable label for this cohort.
"Customers"^(?!\s*$).+place_conditionsarray[object]List of places to use to spatially filter Cohort membership.
recencyobject(Parameters used to POST a new value of the Recency type.)
Basing cohort on recency of event
stream_conditionsarray[object]List of stream properties to filter cohort membership on. The stream properties must be for the same stream set as the cohort stream_name.
Nulls are excluded unless explicitly requested with _null: true.
traitsarray[object]List of traits to filter cohort membership
Responses
201The new cohort
archived_atstring<date-time>If not null, this resource will no longer receive updates, but will still be visable.
classicbooleanA Managed Cohort.
When this resource was created.
explorebooleanWhether to show the Cohort in Explore, the map view on https://app.faraday.ai.
This will slow down Cohort builds.
falseA unique ID for this resource.
"5bf9aa70-7bf1-4ef1-a131-8c84441be231"last_read_input_atstring<date-time>The last time this resource's input was read.
last_updated_config_atstring<date-time>The last time this resource's configuration was updated. If this is more recent than last_updated_output_at, the resource will be rebuilt.
last_updated_output_atstring<date-time>The last time this resource successfully built.
Human-readable label for this cohort.
"Customers"^(?!\s*$).+place_conditionsarray[object]List of places to use to spatially filter Cohort membership.
population_countintegerCount of unique individuals.
recencyobjectBasing cohort on recency of event
residence_countintegerCount of unique residences.
The current state of this resource and any updates.
"pending"new, starting, running, ready, errorstatus_changed_atstring<date-time>When the status of this resource was last updated.
status_errorstringIf this resource has status == "error", this will contain an error message.
stream_conditionsarray[object]List of stream properties to filter cohort membership on. The stream properties must be for the same stream set as the cohort stream_name.
Nulls are excluded unless explicitly requested with _null: true.
traitsarray[object]List of traits to filter cohort membership
When this resource was last updated.
400The request was invalid.
A Faraday error code.
Some possible values include:
Generic HTTP Errors
- BAD_REQUEST: The request could not be validated.
- FORBIDDEN: You do not have permission to access the specified resour...
"ERROR_TYPE"BAD_REQUEST, FORBIDDEN, MAX_RESOURCES_REACHED, INTERNAL_SERVER_ERROR, INVALID_AUTHORIZATION, NOT_FOUND, MALFORMED_API_KEY, MISSING_API_KEY, EXPIRED_API_KEY, VALIDATION_FAILED, CONFLICTA unique ID for this error. Please include this in bug reports.
"082f9513-901c-4308-8081-902a8fe22d7e"validationErrorsarray[object]JSON Schema validation errors, if any.
401No API key was supplied.
A Faraday error code.
Some possible values include:
Generic HTTP Errors
- BAD_REQUEST: The request could not be validated.
- FORBIDDEN: You do not have permission to access the specified resour...
"ERROR_TYPE"BAD_REQUEST, FORBIDDEN, MAX_RESOURCES_REACHED, INTERNAL_SERVER_ERROR, INVALID_AUTHORIZATION, NOT_FOUND, MALFORMED_API_KEY, MISSING_API_KEY, EXPIRED_API_KEY, VALIDATION_FAILED, CONFLICTA unique ID for this error. Please include this in bug reports.
"082f9513-901c-4308-8081-902a8fe22d7e"validationErrorsarray[object]JSON Schema validation errors, if any.
403Access to this resource was forbidden.
A Faraday error code.
Some possible values include:
Generic HTTP Errors
- BAD_REQUEST: The request could not be validated.
- FORBIDDEN: You do not have permission to access the specified resour...
"ERROR_TYPE"BAD_REQUEST, FORBIDDEN, MAX_RESOURCES_REACHED, INTERNAL_SERVER_ERROR, INVALID_AUTHORIZATION, NOT_FOUND, MALFORMED_API_KEY, MISSING_API_KEY, EXPIRED_API_KEY, VALIDATION_FAILED, CONFLICTA unique ID for this error. Please include this in bug reports.
"082f9513-901c-4308-8081-902a8fe22d7e"validationErrorsarray[object]JSON Schema validation errors, if any.
404The requested resource ID was not found.
A Faraday error code.
Some possible values include:
Generic HTTP Errors
- BAD_REQUEST: The request could not be validated.
- FORBIDDEN: You do not have permission to access the specified resour...
"ERROR_TYPE"BAD_REQUEST, FORBIDDEN, MAX_RESOURCES_REACHED, INTERNAL_SERVER_ERROR, INVALID_AUTHORIZATION, NOT_FOUND, MALFORMED_API_KEY, MISSING_API_KEY, EXPIRED_API_KEY, VALIDATION_FAILED, CONFLICTA unique ID for this error. Please include this in bug reports.
"082f9513-901c-4308-8081-902a8fe22d7e"validationErrorsarray[object]JSON Schema validation errors, if any.
500An internal server error occurred.
A Faraday error code.
Some possible values include:
Generic HTTP Errors
- BAD_REQUEST: The request could not be validated.
- FORBIDDEN: You do not have permission to access the specified resour...
"ERROR_TYPE"BAD_REQUEST, FORBIDDEN, MAX_RESOURCES_REACHED, INTERNAL_SERVER_ERROR, INVALID_AUTHORIZATION, NOT_FOUND, MALFORMED_API_KEY, MISSING_API_KEY, EXPIRED_API_KEY, VALIDATION_FAILED, CONFLICTA unique ID for this error. Please include this in bug reports.
"082f9513-901c-4308-8081-902a8fe22d7e"validationErrorsarray[object]JSON Schema validation errors, if any.
Tags
Test request
Request snippet
curl -X POST 'https://api.faraday.ai/v1/cohorts' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"explore": false,
"max_count": 100,
"max_value": 100,
"min_count": 10,
"min_value": 100,
"name": "Customers",
"place_conditions": [
{
"distance": 0,
"invert": false,
"place_id": "123e4567-e89b-12d3-a456-426614174000"
}
],
"recency": {
"max_days": 0,
"min_days": 0,
"occurrence": "first"
},
"stream_conditions": [
{
"_eq": "string",
"_gt": 0,
"_gte": 0,
"_in": [
"string"
],
"_lt": 0,
"_lte": 0,
"_matches": "string",
"_nin": [
"string"
],
"_nnull": true,
"_null": true,
"optional": true,
"property": "string"
}
],
"stream_name": "orders",
"traits": [
{
"_eq": "string",
"_gt": 0,
"_gte": 0,
"_in": [
"string"
],
"_lt": 0,
"_lte": 0,
"_matches": "string",
"_nin": [
"string"
],
"_nnull": true,
"_null": true,
"name": "string",
"optional": true
}
]
}'Example response
{
"archived_at": "2024-01-01T12:00:00Z",
"classic": true,
"created_at": "2024-01-01T12:00:00Z",
"explore": false,
"id": "5bf9aa70-7bf1-4ef1-a131-8c84441be231",
"last_read_input_at": "2024-01-01T12:00:00Z",
"last_updated_config_at": "2024-01-01T12:00:00Z",
"last_updated_output_at": "2024-01-01T12:00:00Z",
"max_count": 100,
"max_value": 100,
"min_count": 10,
"min_value": 100,
"name": "Customers",
"place_conditions": [
{
"distance": 0,
"invert": false,
"place_id": "123e4567-e89b-12d3-a456-426614174000"
}
],
"population_count": 0,
"recency": {
"max_days": 0,
"min_days": 0,
"occurrence": "first"
},
"residence_count": 0,
"resource_type": "cohorts",
"status": "pending",
"status_changed_at": "2024-01-01T12:00:00Z",
"status_error": "string",
"stream_conditions": [
{
"_eq": "string",
"_gt": 0,
"_gte": 0,
"_in": [
"string"
],
"_lt": 0,
"_lte": 0,
"_matches": "string",
"_nin": [
"string"
],
"_nnull": true,
"_null": true,
"optional": true,
"property": "string"
}
],
"stream_name": "orders",
"traits": [
{
"_eq": "string",
"_gt": 0,
"_gte": 0,
"_in": [
"string"
],
"_lt": 0,
"_lte": 0,
"_matches": "string",
"_nin": [
"string"
],
"_nnull": true,
"_null": true,
"name": "string",
"optional": true
}
],
"updated_at": "2024-01-01T12:00:00Z"
}