---
title: "Delete a custom role"
url: https://docs.corefinity.com/api/reference/organisation/delete-custom-role
type: endpoint
last_updated: 2026-11-13
feature: team
related:
  - https://docs.corefinity.com/guides/organisation/people/users-and-invitations.md
  - https://docs.corefinity.com/mcp/tools/corestack_team_role_delete.md
---
# Delete a custom role

Deletes a custom role of your company. A role somebody still holds is refused: give those people another role
first.

```http
DELETE /api/roles/{id}/delete
```

- Scope: `write`
- Rate limit: 60 a minute
- Try it in the console: off. It deletes data that cannot be brought back. Copy the request and run it yourself when you are sure.

## Path parameters

- `id` (integer, required): The id of a custom role of your company, as `GET /team/roles` lists it. Digits only; anything else answers `404`.

## Request

### curl

```bash
curl -X DELETE https://manage.corefinity.com/api/roles/3107/delete \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json"
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->delete('https://manage.corefinity.com/api/roles/3107/delete');

$data = $response->json();
```

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/roles/3107/delete', {
  method: 'DELETE',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
  },
});

// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);
```

### Python

```python
import os
import requests

res = requests.delete(
    "https://manage.corefinity.com/api/roles/3107/delete",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
)

data = res.json() if res.content else None
```

## Responses

### 200 The role was deleted.

```json
{
  "message": "Role deleted.",
  "status": "success"
}
```

### 401 No token, or a token that is not valid.

```json
{
  "message": "Unauthenticated."
}
```

### 403 The token lacks the `write` scope (`scope_required`), or you may not delete roles (`forbidden`).

```json
{
  "code": "forbidden",
  "message": "You are not allowed to delete roles.",
  "reason": "forbidden",
  "status": "error"
}
```

### 404 No custom role of your company has this id. A standard role and another company's role answer the same.

```json
{
  "message": "Not found."
}
```

### 409 Somebody still holds the role (`in_use`).

```json
{
  "code": "in_use",
  "message": "This custom role has users assigned to it. Please reassign them before deleting the role.",
  "reason": "in_use",
  "status": "error"
}
```

### 429 Too many requests (`rate_limited`). Wait for the number of seconds in `Retry-After`, which `retry_after_seconds` repeats.

```json
{
  "code": "rate_limited",
  "message": "Too many requests. Try again in 60 seconds.",
  "reason": "rate_limited",
  "retry_after_seconds": 60
}
```

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `forbidden` | The person is not allowed to do this. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 404 |  | Check the id. You see only what your account can reach. |
| 409 | `in_use` | It is still in use, still being removed, or managed somewhere else. Read the message: wait for the removal, remove what uses it first, or remove it where the message says. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |

## The same task elsewhere

- Guide: [Users and invitations](https://docs.corefinity.com/guides/organisation/people/users-and-invitations.md)
- MCP tool: [`corestack_team_role_delete`](https://docs.corefinity.com/mcp/tools/corestack_team_role_delete.md)
