---
title: "Segments"
description: "Audiences for one app and environment."
canonical: https://docs.notifiable.sh/api/segments
source: https://docs.notifiable.sh/api/segments.md
---

# Segments

Audiences for one app and environment.

These routes are the public API. Send `Authorization: Bearer` with a workspace server API key. The key can act on every app in the workspace. A route that names an app uses that app id. `environment` is `development` or `production`.

## `GET /api/v1/public/apps/{app}/environments/{environment}/segments`

The segments were listed.

Path

- `app` — App id in this workspace.
- `environment` — `development` or `production`.

Responses

- `200` `SEGMENTS_LISTED` — The segments were listed.
- `401` `INVALID_API_KEY` — The API key is invalid.
- `404` `APP_NOT_FOUND` — The app could not be found.
- `429` `RATE_LIMIT_EXCEEDED` — Too many requests. Please try again later.
- `500` `SERVER_ERROR` — Something went wrong. Please try again.

## `POST /api/v1/public/apps/{app}/environments/{environment}/segments`

The segment was created.

Path

- `app` — App id in this workspace.
- `environment` — `development` or `production`.

Body

- `name` (string, required)

Responses

- `201` `SEGMENT_CREATED` — The segment was created.
- `401` `INVALID_API_KEY` — The API key is invalid.
- `404` `APP_NOT_FOUND` — The app could not be found.
- `422` `VALIDATION_FAILED` — The request contains invalid fields.
- `429` `RATE_LIMIT_EXCEEDED` — Too many requests. Please try again later.
- `500` `SERVER_ERROR` — Something went wrong. Please try again.

## `POST /api/v1/public/apps/{app}/environments/{environment}/segments/bulk`

The segments were deleted.

Path

- `app` — App id in this workspace.
- `environment` — `development` or `production`.

Body

- `ids` (array of string, required)

Responses

- `200` `SEGMENTS_DELETED` — The segments were deleted.
- `401` `INVALID_API_KEY` — The API key is invalid.
- `404` `APP_NOT_FOUND` — The app could not be found.
- `422` `VALIDATION_FAILED` — The request contains invalid fields.
- `429` `RATE_LIMIT_EXCEEDED` — Too many requests. Please try again later.
- `500` `SERVER_ERROR` — Something went wrong. Please try again.

## `POST /api/v1/public/apps/{app}/environments/{environment}/segments/preview`

The audience was counted.

Path

- `app` — App id in this workspace.
- `environment` — `development` or `production`.

Responses

- `200` `SEGMENT_PREVIEWED` — The audience was counted.
  - `count` (integer, required)
- `401` `INVALID_API_KEY` — The API key is invalid.
- `404` `APP_NOT_FOUND` — The app could not be found.
- `422` `VALIDATION_FAILED` — The request contains invalid fields.
- `429` `RATE_LIMIT_EXCEEDED` — Too many requests. Please try again later.
- `500` `SERVER_ERROR` — Something went wrong. Please try again.

## `DELETE /api/v1/public/apps/{app}/environments/{environment}/segments/{segment}`

The segment was deleted.

Path

- `app` — App id in this workspace.
- `environment` — `development` or `production`.
- `segment` — Segment id or automatic audience id.

Responses

- `200` `SEGMENT_DELETED` — The segment was deleted.
  - `id` (string, required)
- `401` `INVALID_API_KEY` — The API key is invalid.
- `404` `APP_NOT_FOUND` — The app could not be found.
- `429` `RATE_LIMIT_EXCEEDED` — Too many requests. Please try again later.
- `500` `SERVER_ERROR` — Something went wrong. Please try again.

## `GET /api/v1/public/apps/{app}/environments/{environment}/segments/{segment}`

The segment was found.

Path

- `app` — App id in this workspace.
- `environment` — `development` or `production`.
- `segment` — Segment id or automatic audience id.

Responses

- `200` `SEGMENT_FETCHED` — The segment was found.
- `401` `INVALID_API_KEY` — The API key is invalid.
- `404` `SEGMENT_NOT_FOUND` — The segment could not be found.
- `429` `RATE_LIMIT_EXCEEDED` — Too many requests. Please try again later.
- `500` `SERVER_ERROR` — Something went wrong. Please try again.

## `PATCH /api/v1/public/apps/{app}/environments/{environment}/segments/{segment}`

The segment was updated.

Path

- `app` — App id in this workspace.
- `environment` — `development` or `production`.
- `segment` — Custom segment id.

Body

- `name` (string, required)

Responses

- `200` `SEGMENT_UPDATED` — The segment was updated.
- `401` `INVALID_API_KEY` — The API key is invalid.
- `404` `SEGMENT_NOT_FOUND` — The segment could not be found.
- `422` `VALIDATION_FAILED` — The request contains invalid fields.
- `429` `RATE_LIMIT_EXCEEDED` — Too many requests. Please try again later.
- `500` `SERVER_ERROR` — Something went wrong. Please try again.
