Introduction
Organization APIs
- Users
- Invitations
- Workspaces
Workspace APIs
- Syncs
- Sync Management Links
- Sync Runs
- Destination Types
- Destinations
- Destination Connect Links
- Source Types
- Sources
- Source Connect Links
- Segment Management Links
- Webhooks
Fetch segment
This endpoint lists information for a given segment, including information on its molecules (our data structure for recursive constraints).
curl --request GET \
--url https://app.getcensus.com/api/v1/sources/{source_id}/filter_segments/{segment_id} \
--header 'Authorization: Bearer <token>'
{
"status": "success",
"data": {
"type": "segment",
"id": 18,
"name": "priority accounts",
"model_id": 9,
"dataset_id": 12,
"query": "SELECT * FROM (\n SELECT 1 AS id, 'Planet Express'::text AS company_name\n) AS census_1d19740e93f711b22efaea201fcf3f8f\nWHERE (\"id\" IS NOT NULL )\n",
"record_count": 12540,
"created_at": "2021-10-20T02:43:07.120Z",
"updated_at": "2021-10-20T02:50:35.477Z",
"resource_identifier": "segment:priority-accounts",
"molecules": [
{
"attribute": "last_seen_at",
"attribute_type": "property",
"operator": "isnotnull",
"value": "id"
}
],
"filter_segment_source_object_id": 32,
"cohorts": [
{
"id": 18,
"name": "Treatment A",
"percentage": 50,
"is_control": true,
"created_at": "2021-10-20T02:43:07.120Z",
"resource_identifier": "cohort:treatment-a"
}
]
}
}
Authorizations
Bearer token for the current workspace. Can be retrieved from the Workspace's settings page.
Response
Outcome of the operation.
success
, updated
, created
, not_found
, error
"success"
The type of this source object, will always be segment
.
segment
"segment"
The id of this segment.
18
The name of this segment.
"priority accounts"
The id of the model that this filter segment is related to (either directly from legacy segments or indirectly via the dataset)
9
The dataset ID that this segment is associated with.
12
The SQL query associated with this segment.
"SELECT * FROM (\n SELECT 1 AS id, 'Planet Express'::text AS company_name\n) AS census_1d19740e93f711b22efaea201fcf3f8f\nWHERE (\"id\" IS NOT NULL )\n"
The cached size of the segment at that particular moment in time.
12540
When this segment was created.
"2021-10-20T02:43:07.120Z"
When this segment was last updated.
"2021-10-20T02:50:35.477Z"
The unique identifier for this filter segment.
"segment:priority-accounts"
A list of Atomic Molecules, Related Segment Molecules, Relationship Molecules, Molecule Groups and at most one Operation Molecule.
A condition on an property of an entity. The property or column will belong to the entity described in the parent relationship molecule. If the basic molecule is top level, the condition is on the entity on which the segment is based on.
Represents the property name when attribute_type
is property and the column name when attribute_type
is column.
"last_seen_at"
The type of the attribute for this condition. Options are:
property
for entity propertiessql
for sql conditionscolumn
for legacy segments
property
, sql
, column
"property"
The operator for this molecule. Only certain operators will be valid for a given property type. For example, the greaterthan
operator can only be applied to numeric values.
isnull
, isnotnull
, between
, in
, exactly
, isnot
, starts
, ends
, contains
, nocontains
, isblank
, isnotblank
, equals
, notexactly
, lessthan
, greaterthan
, intop
, inbottom
, true
, false
, morethandays
, lessthandays
, exactlydays
, after
, on
, before
"isnotnull"
If the attribute_type
is sql
, then this is a SQL string. Otherwise the value being filtered on.
- a number for numerical operators
- a string for string operators
- a boolean for boolean operators
- an array for array operators
- for datetime operators, this could either be a datetime value, a number (for “morethandays” type operators), or a “between” value which is represented as a hash with the following structure
{ bound_one: X, bound_two: Y }
. X and Y are either datetime values, blank (in which case they become the current datetime on the backend), or a string with the following structure "days_ago: Z" where Z is a number (can be decimal).
"id"
[Deprecated] The source object id for this segment. You can typically ignore this.
32
A list of cohorts (experiments) that are active for this segment
The id of this cohort.
18
The name of this cohort.
"Treatment A"
The percentage of users included in this cohort.
0 <= x <= 100
50
Will be true if this is the control cohort, false if it is a treatment.
When this cohort was created.
"2021-10-20T02:43:07.120Z"
The unique identifier for this cohort.
"cohort:treatment-a"
Was this page helpful?
curl --request GET \
--url https://app.getcensus.com/api/v1/sources/{source_id}/filter_segments/{segment_id} \
--header 'Authorization: Bearer <token>'
{
"status": "success",
"data": {
"type": "segment",
"id": 18,
"name": "priority accounts",
"model_id": 9,
"dataset_id": 12,
"query": "SELECT * FROM (\n SELECT 1 AS id, 'Planet Express'::text AS company_name\n) AS census_1d19740e93f711b22efaea201fcf3f8f\nWHERE (\"id\" IS NOT NULL )\n",
"record_count": 12540,
"created_at": "2021-10-20T02:43:07.120Z",
"updated_at": "2021-10-20T02:50:35.477Z",
"resource_identifier": "segment:priority-accounts",
"molecules": [
{
"attribute": "last_seen_at",
"attribute_type": "property",
"operator": "isnotnull",
"value": "id"
}
],
"filter_segment_source_object_id": 32,
"cohorts": [
{
"id": 18,
"name": "Treatment A",
"percentage": 50,
"is_control": true,
"created_at": "2021-10-20T02:43:07.120Z",
"resource_identifier": "cohort:treatment-a"
}
]
}
}