> 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/managing-channel-and-category-preferences.md).

# Managing Channel Permissions and Category Preferences

This recipe shows how to record a user's consent from your own preference center: opt the user in to the channels they accepted, set which message categories they want per channel, and read the stored preferences back. Netmera applies these preferences when a message that belongs to a category is sent, so users receive only what they agreed to.

## When to Use

This recipe fits any screen or backend flow where users choose what they receive, such as a notification settings page, a sign-up form with consent checkboxes, or a migration of consent data from another system.

## Prerequisites

* REST API key of the application
* Message categories created in the panel under **Settings > Message Categories**
* The external ID (`extId`) of the user

## Step 1: List the Message Categories

Read the categories of the application with `getPushCategories`. Use the returned names in the next steps.

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

The response contains one object per category; each object maps the category ID to the category name.

**Expected result:** The list of category IDs and names, for example `Shopping` and `Promotion`.

## Step 2: Grant Channel Permissions

Opt the user in to each channel they accepted. Push uses `extId`; email and SMS use `extIds` arrays.

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

curl https://restapi.netmera.com/rest/3.0/enableMail \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{ "extIds": ["user_1001"] }'

curl https://restapi.netmera.com/rest/3.0/enableSms \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{ "extIds": ["user_1001"] }'
```

The matching `disablePush`, `disableMail` and `disableSms` endpoints take the same bodies and revoke the permission.

**Expected result:** Each request returns HTTP 200 with no response body.

## Step 3: Set the Category Preferences

Send one entry per category to `setCategoryPreferences`. Add `channel` to change a single category and channel pair; omit it to apply the change to every channel of the category. `enable` is `true` to opt in and `false` to opt out.

```bash
curl https://restapi.netmera.com/rest/3.0/setCategoryPreferences \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '[
  { "extId": "user_1001", "category": "Shopping", "enable": true },
  { "extId": "user_1001", "category": "Promotion", "channel": "EMAIL", "enable": false }
]'
```

{% hint style="info" %}
An entry that names a category that does not exist is skipped. Use the exact names returned in Step 1.
{% endhint %}

**Expected result:** HTTP 200 with no response body.

## Step 4: Read the Preferences Back

Verify the stored state with `getCategoryPreferences`.

```bash
curl 'https://restapi.netmera.com/rest/3.0/getCategoryPreferences?externalId=user_1001' \
  --header 'X-netmera-api-key: <API_KEY>'
```

The response contains two maps. `categoryPreferences` gives the opt-in state per category name. `categoryChannelPreferences` gives the state per category and then per channel. Use the optional `categoryIds` and `channels` query parameters to narrow the result.

**Expected result:** `Shopping` is `true`; `Promotion` is `false` on the `EMAIL` channel.

## Verification Checklist

* Category names in `setCategoryPreferences` match the names in the panel exactly
* Channel permissions are granted before category preferences are relied on
* `channel` is set when only one channel of a category should change
* `getCategoryPreferences` returns the state that the user selected

## Related Pages

For the full list of supported channel values, see the Set category preferences page in the REST API documentation.


---

# 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/managing-channel-and-category-preferences.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.
