Audiences play a key role in gaining a deeper understanding of your users. Audiences allow you to group users or profiles based on shared characteristics, behaviors, and attributes. Using events passed into Segment, traits, and computed traits you can create Audiences which can help unlock more relevant engagement and communication.
Note: The Audience API is currently in a Private Beta. If you are interested in joining the Private Beta, then please reach out to your customer success manager.
Creates Audience.
• This endpoint is in Alpha testing. Please submit any feedback by sending an email to friends@segment.com.
• In order to successfully call this endpoint, the specified Workspace needs to have the Audience feature enabled. Please reach out to your customer success manager for more information.
• When called, this endpoint may generate the Audience Created
event in the audit trail.
Note: The definition for an Audience created using the API is not editable through the Segment App.
The rate limit for this endpoint is 10 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.
OK
Resource not found
Validation failure
Too many requests
{- "name": "name",
- "description": "description",
- "enabled": false,
- "definition": {
- "query": "event('Shoes Bought').count() >= 1",
- "type": "USERS"
}, - "options": {
- "includeAnonymousUsers": true,
- "includeHistoricalData": true
}
}
{- "data": {
- "audience": {
- "id": "id",
- "spaceId": "spaceId",
- "name": "name",
- "description": "description",
- "definition": {
- "query": "event('Shoes Bought').count() >= 1",
- "type": "USERS"
}, - "status": "Live",
- "key": "key",
- "enabled": false,
- "createdBy": "createdBy",
- "updatedBy": "updatedBy",
- "createdAt": "2006-01-02T15:04:05.000Z",
- "updatedAt": "2006-01-02T15:04:05.000Z"
}
}
}
Returns Audiences by spaceId.
• This endpoint is in Alpha testing. Please submit any feedback by sending an email to friends@segment.com.
• In order to successfully call this endpoint, the specified Workspace needs to have the Audience feature enabled. Please reach out to your customer success manager for more information.
The rate limit for this endpoint is 25 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.
object (PaginationInput) Information about the pagination of this response. See pagination for more info. This parameter exists in alpha. Example: pagination=pagination.count=1 |
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.audiences.listAudiences('spaceId')) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "audiences": [
- {
- "id": "id",
- "spaceId": "spaceId",
- "name": "name",
- "description": "description",
- "definition": {
- "query": "event('Shoes Bought').count() >= 1",
- "type": "USERS"
}, - "status": "Live",
- "key": "key",
- "enabled": false,
- "createdBy": "createdBy",
- "updatedBy": "updatedBy",
- "createdAt": "2006-01-02T15:04:05.000Z",
- "updatedAt": "2006-01-02T15:04:05.000Z"
}
], - "pagination": {
- "current": "MA==",
- "totalEntries": 2
}
}
}
Returns the Audience by id and spaceId.
• This endpoint is in Alpha testing. Please submit any feedback by sending an email to friends@segment.com.
• In order to successfully call this endpoint, the specified Workspace needs to have the Audience feature enabled. Please reach out to your customer success manager for more information.
The rate limit for this endpoint is 100 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.audiences.getAudience('spaceId', 'id')) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "audience": {
- "id": "id",
- "spaceId": "spaceId",
- "name": "name",
- "description": "description",
- "definition": {
- "query": "event('Shoes Bought').count() >= 1",
- "type": "USERS"
}, - "status": "Live",
- "key": "key",
- "enabled": false,
- "createdBy": "createdBy",
- "updatedBy": "updatedBy",
- "createdAt": "2006-01-02T15:04:05.000Z",
- "updatedAt": "2006-01-02T15:04:05.000Z"
}
}
}
Deletes an Audience by id and spaceId.
• This endpoint is in Alpha testing. Please submit any feedback by sending an email to friends@segment.com.
• In order to successfully call this endpoint, the specified Workspace needs to have the Audience feature enabled. Please reach out to your customer success manager for more information.
• When called, this endpoint may generate the Audience Deleted
event in the audit trail.
The rate limit for this endpoint is 20 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.audiences.removeAudienceFromSpace('spaceId', 'id')) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "status": "SUCCESS"
}
}
Updates the Audience.
• This endpoint is in Alpha testing. Please submit any feedback by sending an email to friends@segment.com.
• In order to successfully call this endpoint, the specified Workspace needs to have the Audience feature enabled. Please reach out to your customer success manager for more information.
• When called, this endpoint may generate the Audience Modified
event in the audit trail.
• Note that when an Audience is updated, the Audience will be locked from future edits until the changes have been incorporated. You can find more information in the Segment docs. Note: The definition for an Audience updated using the API is not editable through the Segment App.
The rate limit for this endpoint is 10 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.
OK
Resource not found
Validation failure
Too many requests
{- "enabled": false
}
{- "data": {
- "audience": {
- "id": "id",
- "spaceId": "spaceId",
- "name": "name",
- "description": "description",
- "definition": {
- "query": "event('Shoes Bought').count() >= 1",
- "type": "USERS"
}, - "status": "Live",
- "key": "key",
- "enabled": false,
- "createdBy": "createdBy",
- "updatedBy": "updatedBy",
- "createdAt": "2006-01-02T15:04:05.000Z",
- "updatedAt": "2006-01-02T15:04:05.000Z"
}
}
}