> ## Documentation Index
> Fetch the complete documentation index at: https://docs.userpilot.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Users and Companies

> Delete users and companies from Userpilot to comply with data privacy regulations.

Userpilot supports data deletion to comply with the [right to be forgotten](https://gdpr.eu/article-17-right-to-be-forgotten/) under [GDPR](https://gdpr-info.eu/). Under this right, a user can request to delete all their data. Userpilot supports this right for all users, not just those in Europe. You can use the Deletion APIs to schedule a job to delete user or company data.

***

## Authorization

Userpilot API uses API tokens to authenticate requests. You can view your API key in the Environment Page.

**Authentication Method:**

Include your API key in the `Authorization` header:

```http theme={null}
-H 'Authorization: Token {{API_KEY}}'
```

<Note>All API requests must be made over HTTPS.</Note>

<Warning>
  Your API key carries many privileges, so be sure to keep them secure! Do not
  share your secret API keys in publicly accessible areas.
</Warning>

***

## Version

You must send the API version in the headers:

```http theme={null}
-H 'X-API-Version: 2020-09-22'
```

***

## Endpoints

For most users, the HTTP API endpoint URL is `https://analytex.userpilot.io` as the examples show. If you are on Enterprise or EU hosting, refer to the Environment Page in the application to retrieve your dedicated endpoint.

***

### 1. Delete Users

**Endpoint:**

```http theme={null}
DELETE https://analytex.userpilot.io/v1/users
```

<Note>
  The endpoint URL uses the `analytex` environment. For EU data residency, use
  `analytex-eu` instead. See [Environment
  Settings](https://run.userpilot.io/environment) for your specific endpoint.
</Note>

{" "}

**Headers:**

| Header          | Value                  | Required |
| --------------- | ---------------------- | -------- |
| `Content-Type`  | `application/json`     | Yes      |
| `Authorization` | `Token {YOUR_API_KEY}` | Yes      |
| `X-API-Version` | `2020-09-22`           | Yes      |

**Request Body:**

| Field   | Type  | Required | Description                    |
| ------- | ----- | -------- | ------------------------------ |
| `users` | array | Yes      | List of user IDs to be deleted |

**Example Request:**

```bash theme={null}
curl -X DELETE https://analytex.userpilot.io/v1/users \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Token <API_KEY>' \
  -H 'X-API-Version: 2020-09-22' \
  -d '{"users": ["user_id", "user_id2"]}'
```

***

### 2. Delete Companies

**Endpoint:**

```http theme={null}
DELETE https://analytex.userpilot.io/v1/companies
```

<Note>
  The endpoint URL uses the `analytex` environment. For EU data residency, use
  `analytex-eu` instead. See [Environment
  Settings](https://run.userpilot.io/environment) for your specific endpoint.
</Note>

{" "}

**Headers:**

| Header          | Value                  | Required |
| --------------- | ---------------------- | -------- |
| `Content-Type`  | `application/json`     | Yes      |
| `Authorization` | `Token {YOUR_API_KEY}` | Yes      |
| `X-API-Version` | `2020-09-22`           | Yes      |

**Request Body:**

| Field       | Type  | Required | Description                       |
| ----------- | ----- | -------- | --------------------------------- |
| `companies` | array | Yes      | List of company IDs to be deleted |

**Example Request:**

```bash theme={null}
curl -X DELETE https://analytex.userpilot.io/v1/companies \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Token <API_KEY>' \
  -H 'X-API-Version: 2020-09-22' \
  -d '{"companies": ["company_id", "company_id2"]}'
```

***

## Response

A successful request will schedule your delete job and return a `202 Accepted` status with a message indicating how many users or companies have been scheduled for deletion.

**Example Response:**

```json theme={null}
{
  "message": "2 users have been scheduled for deletion"
}
```

<Note>
  Deletions are scheduled to be executed every 24 hours (daily at 2:00 AM UTC).
</Note>

***

## Rate Limits

The Delete API has the following rate limit:

* **Delete Operations**: **1 request every 2 seconds** for delete operations

If you exceed the rate limit, the API will return a `429 Too Many Requests` error.

<Tip>
  **Best Practice:** Implement exponential backoff and retry logic to handle rate limit errors gracefully.
</Tip>

***

<Frame>
  [**For any questions or concerns, please reach out to
  support@userpilot.com**](mailto:support@userpilot.com)
</Frame>
