> For the complete documentation index, see [llms.txt](https://user.netmera.com/netmera-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/reading-segments-and-members.md).

# Reading Segments and Segment Members

List the segments of the application, read the members of a segment, and count the users who can receive push.

This recipe shows how to list the segments defined in the Netmera panel, read the members of a segment, and read the number of users who can receive push. You can use the data to keep an external system in sync with your audiences.

## When to Use

This recipe fits integrations that need the audience of a segment outside Netmera, such as a CRM sync or a report that compares segment sizes.

## Prerequisites

* REST API key of the application
* Segments created in the Netmera panel
* The platform of the application, `IOS` or `ANDROID`, for the `X-netmera-os` header

## Step 1: List the Segments

Read the segments with `getSegments`. The `X-netmera-os` header is required.

```bash
curl https://restapi.netmera.com/rest/3.0/getSegments \
  --header 'X-netmera-api-key: <API_KEY>' \
  --header 'X-netmera-os: IOS'
```

Each entry in `list` contains the `id`, the `name`, the `userCount`, and the `type` of a segment.

**Expected result:** The segments of the application with their IDs and user counts.

## Step 2: Read the Members of a Segment

Pass the segment `id` to `getSegmentUsers`. The `X-netmera-os` header is required here as well.

```bash
curl 'https://restapi.netmera.com/rest/3.0/getSegmentUsers?id=<SEGMENT_ID>' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --header 'X-netmera-os: IOS'
```

The response contains the `name` of the segment and a `list` of users. Each user entry has the `externalId`, the `msisdn`, and the `email` of the user.

**Expected result:** The users of the segment.

## Step 3: Read the Number of Push-Permitted Users

`count-user` returns the number of users in the application who currently have push permission. It takes no parameters.

```bash
curl https://restapi.netmera.com/rest/3.0/count-user \
  --header 'X-netmera-api-key: <API_KEY>'
```

The response contains a `count` field.

**Expected result:** A `count` with the number of users who have push permission.

## Verification Checklist

* The `X-netmera-os` header is set to `IOS` or `ANDROID` in `getSegments` and `getSegmentUsers`
* The `id` in `getSegmentUsers` is the `id` returned by `getSegments`
* The data of segment members is stored and shared according to your privacy rules, because the response includes `msisdn` and `email`

## Related Pages

For the full format of the endpoints, see the Segments and User Count sections of the [User & Device Management](/netmera-developer-guide/api-documentation/rest-api/user-and-device-management.md) page in the REST API documentation. To send a push to a segment, see [Targeting a Push Campaign by Segment or Profile Attribute](/netmera-developer-guide/api-documentation/recipes/targeting-by-segment-or-profile.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/reading-segments-and-members.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
