> 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/handling-user-deletion.md).

# Handling User Deletion Requests

Choose between standard and permanent deletion, and clear a single contact field without deleting the user.

This recipe shows how to remove a user from Netmera when the user asks for deletion, and how to choose between the two deletion endpoints. It also shows how to clear a single contact field, such as an email address, while keeping the user.

## When to Use

This recipe fits data deletion requests that reach your backend, for example a GDPR request, an account closure in your app, or a clean-up of test users.

## Prerequisites

* REST API key of the application
* The external IDs (`extId`) of the users to delete
* For permanent deletion: access activated for the application in the Netmera panel

## Step 1: Choose the Deletion Type

Both endpoints take the same request body but differ in effect.

| Endpoint                 | Effect                                                                                                                                        |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `deleteUsers`            | Deletes the users from your application. The users stop being tracked and are no longer targeted by campaigns.                                |
| `deleteUsersPermanently` | Additionally erases all data stored about the users, including devices, profile attributes, and event history. The operation is irreversible. |

{% hint style="warning" %}
`deleteUsersPermanently` requires prior activation through the Netmera panel. If permanent deletion has not been activated for your application, the endpoint behaves like `deleteUsers`.
{% endhint %}

**Expected result:** You know which endpoint matches the request you received.

## Step 2: Delete the Users

Send the external IDs to `deleteUsers`.

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

A single request accepts a maximum of 1000 unique external IDs; split larger lists across multiple requests.

**Expected result:** The users are removed from your application and are no longer targeted by campaigns.

## Step 3: Delete the Users Permanently

When all data of the users must be erased, send the same body to `deleteUsersPermanently`.

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

**Expected result:** HTTP 200 with no response body. The deletion request is accepted.

## Step 4: Clear a Single Contact Field Instead

When only a contact field must be removed, use the matching remove endpoint. The user, the external ID, devices, profile attributes, and permission states are kept.

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

`removeMsisdn` and `removeWhatsApp` take the same body and clear the phone number and the WhatsApp number. Each request returns `200` with an empty body when it is queued, and `400` with the message `Please provide an external id.` when `extId` is missing. The change is applied within seconds.

{% hint style="warning" %}
Sending an empty value to `updateEmail`, `updateMsisdn`, or `updateWhatsApp` does not remove the stored value. Use the remove endpoints to clear a contact field.
{% endhint %}

**Expected result:** The contact field of the user is cleared and the user remains in the application.

## Verification Checklist

* The endpoint matches the request: `deleteUsers` for removal from the application, `deleteUsersPermanently` for erasure of all data
* Permanent deletion is activated for the application in the Netmera panel
* Each request contains at most 1000 unique external IDs
* `extId` is present in every `removeEmail`, `removeMsisdn`, and `removeWhatsApp` request
* Permanent deletion is confirmed with the requester only after the request returns HTTP 200, because the operation cannot be undone

## Related Pages

For the request format of all deletion and contact management endpoints, see [User & Device Management](/netmera-developer-guide/api-documentation/rest-api/user-and-device-management.md) and [GDPR](/netmera-developer-guide/api-documentation/rest-api/gdpr.md) in the REST API documentation. To record consent instead of deleting data, 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/handling-user-deletion.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.
