# Delete Role

Delete a custom role that no member holds any more. Global roles can't be deleted.

`DELETE https://connect.mindcloud.co/v2/roles/:roleId`

Permissions: `role:manage`.

## Parameters

### Path

- `roleId` (string, required): The role's id, from List Roles.

### Headers

- `X-Company-Id` (string): Optional. The id of the organization to act in. Leave it out to act in the API key's own organization. A key can also act in its child organizations, and, with "Use this key across all of your organizations" on, in every organization its creator can open in the app. List them with GET /v2/companies. Every response's X-Company-Id header names the organization it acted in. See [Organizations](https://mindcloud.co/docs/api/rest/introduction/organizations).

## Example request

```bash
curl --request DELETE \
  --url 'https://connect.mindcloud.co/v2/roles/Rl5wB9cF3hJp' \
  --header 'Authorization: Bearer $MINDCLOUD_API_TOKEN'
```

## Response fields

- `id` (string): The id of the resource that was deleted.

## Example response

```json
{
  "success": true,
  "data": {
    "id": "Rl5wB9cF3hJp"
  }
}
```

## Errors

- 400 Bad request (INVALID_QUERY, ROLE_DELETE_ASSIGNED_USERS_FORBIDDEN): `VALIDATION_FAILED` / `ROLE_DELETE_ASSIGNED_USERS_FORBIDDEN` "Cannot delete role. There are 4 users assigned to this role."
- 403 Access denied (API_KEY_PERMISSION_DENIED, MEMBER_ACTOR_NOT_RESOLVED): `FORBIDDEN` / `MEMBER_ACTOR_NOT_RESOLVED` "This API key has no creating user. Create a replacement key."
- 404 Role not found: `NOT_FOUND` / `ROLE_DELETE_NOT_FOUND` "Role not found for this company."
- 500 Delete failed: `INTERNAL_ERROR` / `ROLE_DELETE_QUERY_FAILED` "Failed to delete role."
