Get segment membership counts

Use this endpoint to get count of users in the segment.

API at a glance

Description: This API retrieves user counts for a specific segment across different channels. Supports asynchronous count refresh for real-time updates.

Authentication & testing

Testing the API on this page

How to try it here

  • Use your User API Key as the Username (leave Password blank).
  • User API Key Location
  • Select the appropriate API endpoint based on your Blueshift region.
  • API - Select Region
  • Enter the necessary parameters and click Try It to run the request.
Authentication using Base64 encoding

Note for developers

API requests require authentication using HTTP Basic Authentication with an API key. The API key serves as the username, while the password field should be left empty. The format to encode is: your_api_key: (note the trailing colon).

This string must be Base64-encoded and included in the request's Authorization header as follows:

Authorization: Basic encoded_value

You can generate the encoded value using a trusted Base64 encoder.


Postman collection

Try it with Postman: Explore the API using Blueshift's Postman collection.


Things to know before you start

  • Asynchronous refresh: Use refresh=true to trigger a background count update. Poll with refresh=false to retrieve updated counts.
  • Refresh status: Response includes refresh_status which is refreshing (counts updating) or ready (counts available).
  • Channel counts: Returns counts for total users, email users, SMS users, push users, and in-app users.
  • Global inclusion: Use bypass_global=true to get counts without global inclusion segment filters.
  • Use case: Best for monitoring segment size, checking audience reach before campaigns, and tracking segment growth over time.

Request parameters

Check out the request parameters

Path parameters

ParameterTypeRequiredDescription
segment_uuidstring✅ YesUUID of the segment.

Query parameters

ParameterTypeRequiredDescription
refreshboolean❌ Notrue to trigger count update, false to retrieve counts. Updates happen asynchronously.
channelsstring❌ NoChannel to refresh counts for: users, email, push, sms, or inApp.
bypass_globalboolean❌ Notrue to return counts bypassing global inclusion segments.

Example requests & responses

Get segment counts
GET /api/v1/segments/{segment_uuid}/matching_users.json
{
  "refresh_status": "ready",
  "approxusers": 15000,
  "email_users": 12000,
  "sms_users": 8000,
  "push_users": 5000,
  "in_app_users": 3000,
  "approxusers_updated_at": "2021-08-25T06:06:59.412Z"
}
Trigger count refresh
GET /api/v1/segments/{segment_uuid}/matching_users.json?refresh=true&channels=email
{
  "refresh_status": "refreshing",
  "approxusers": 15000,
  "email_users": 12000,
  "sms_users": 8000,
  "push_users": 5000,
  "in_app_users": 3000,
  "approxusers_updated_at": "2021-08-25T06:06:59.412Z"
}
API error responses

Note
The following error codes are commonly returned by Blueshift APIs. Depending on the specific endpoint, not all may apply.

Status code

Description

Example responses

400 Bad Request

The request is invalid due to missing or incorrect parameters. This includes missing fields, invalid values, formatting issues, or conflicts such as duplicate data.

{ "errors": { "name": ["can't be blank"] } }

{ "errors": { "startdate": ["can't be blank"] } }

401 Unauthorized

API authentication failed due to an invalid or missing API key.

{ "message": "Not authorized" }

403 Forbidden

The API key does not have sufficient permissions to perform this action.

{ "message": "Permission denied" }

404 Not Found

The specified campaign was not found. Verify the campaign UUID.

{ "message": "Campaign not found" }

422 Unprocessable Entity

  • The campaign cannot be paused due to its current status (e.g., already completed or archived).
  • One or more scheduling parameters may be invalid (if applicable).

{ "message": "Campaign cannot be paused in its current status." }

{ "message": "Invalid schedule values" }

429 Too Many Requests

The request limit has been exceeded. Reduce request frequency.

{ "message": "Rate limit exceeded" }

500 Internal Server Error

An unexpected server error occurred. Contact support if the issue persists.

{ "message": "Internal Server Error - Please contact support for more information." }

502 Bad Gateway

The server received an invalid response. Retry the request.

{ "message": "Bad Gateway - Please retry the request." }

503 Service Unavailable

The service is temporarily unavailable. Try again later.

{ "message": "Service Unavailable - The service is temporarily unavailable. Try again later." }

504 Gateway Timeout

The server took too long to respond. Retry the request with exponential backoff.

{ "message": "Gateway Timeout - The server took too long to respond. Retry with exponential backoff." }

Language
Credentials
Basic
base64
:
URL
Click Try It! to start a request and see the response here!