> 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-devices-and-tokens.md).

# Reading Devices and Device Tokens

Read the devices of a user, list all device tokens with pagination, and change the push permission of a single device.

This recipe shows how to read the devices of a single user, how to list all device tokens page by page, and how to change the push permission of one device.

## When to Use

This recipe fits support checks, such as finding out which devices of a user can receive push, and data jobs that need an inventory of the registered device tokens.

## Prerequisites

* REST API key of the application
* The external ID (`extId`) of the user, for the single user checks

## Step 1: Read the Devices of a User

Read the devices of a user with `getDevices`. Set `pushPermitted` to `true` to return only the devices that are opted in. Set it to `false` to return all devices.

```bash
curl 'https://restapi.netmera.com/rest/3.0/getDevices?extId=user_1001&pushPermitted=true' \
  --header 'X-netmera-api-key: <API_KEY>'
```

The response contains the `extId` and a `devices` array. Each device has the `platform`, the `token`, the `deviceModel`, and the `pushPermitted` flag.

**Expected result:** The devices of the user with their push permission.

## Step 2: List All Device Tokens

Read the device tokens of the application with `getDeviceTokens`. `max` sets the page size and defaults to 10. `offset` sets the starting position and defaults to 0.

```bash
curl 'https://restapi.netmera.com/rest/3.0/getDeviceTokens?max=10&offset=0' \
  --header 'X-netmera-api-key: <API_KEY>'
```

The response contains the `total` number of devices, a `devices` array with the same fields as in Step 1, and a `nextPage` URL. To read the next batch, send a request to the `nextPage` value with the same header.

**Expected result:** One page of device tokens and the URL of the next page.

## Step 3: Change the Push Permission of One Device

To opt a single device out of push, send its token to `disablePush`. To opt it back in, use `enablePush` with the same body.

```bash
curl https://restapi.netmera.com/rest/3.0/disablePush \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{ "deviceToken": "<DEVICE_TOKEN>" }'
```

To change all devices of a user at once, send `"extId"` instead of `"deviceToken"`.

**Expected result:** The device shows the new `pushPermitted` value in `getDevices`.

## Verification Checklist

* `pushPermitted` is set according to the question: `true` for opted-in devices, `false` for all devices
* Pagination follows the `nextPage` URL until it is no longer returned
* Device tokens are handled as sensitive data in your logs and exports
* Permission changes are checked with a new `getDevices` request

## Related Pages

For the full format of the endpoints, see the Device Management and Push Notification Permission Management 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 manage permissions for all channels, see [Managing Channel Permissions and Category Preferences](/netmera-developer-guide/api-documentation/recipes/managing-channel-and-category-preferences.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-devices-and-tokens.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.
