---
title: "Take a role from a team member"
url: https://docs.corefinity.com/api/reference/organisation/detach-role-from-user
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_member_role_detach.md
---
# Take a role from a team member

Removes one role from a member. The other roles they hold stay.

```http
POST /api/roles/detach
```

- Scope: `write`
- Rate limit: 60 a minute
- Try it in the console: off. It has not been cleared for the console. Copy the request and run it yourself when you are sure.

## Body

- `role` (string, required): The slug of the role.
- `user_id` (integer or string, required): The id of the team member.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/roles/detach \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "client-member-limited",
    "user_id": 2042
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/roles/detach', [
        'role' => 'client-member-limited',
        'user_id' => 2042,
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/roles/detach', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    role: 'client-member-limited',
    user_id: 2042,
  }),
});

// 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.post(
    "https://manage.corefinity.com/api/roles/detach",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "role": "client-member-limited",
        "user_id": 2042,
    },
)

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

## Responses

### 200 The member with their roles as they are now.

```json
{
  "data": {
    "company_id": "1204",
    "email": "tom.harbour@harbourandfinch.example.com",
    "id": "2042",
    "mobile": null,
    "name": "Tom Harbour",
    "role": [
      {
        "name": "Member (Full Access)",
        "permissions": [
          "viewWebsites",
          "viewDeployments",
          "viewTickets",
          "createTickets"
        ],
        "slug": "client-member-full"
      }
    ]
  },
  "message": "User detached from role.",
  "status": "success"
}
```

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

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

### 403 The token lacks the `write` scope (`scope_required`), you may not detach roles (`forbidden`), or the account is not yours to change (`privileged_target`).

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

### 422 A field is missing or wrong (`invalid`). `user_id` is refused for a person you cannot see as for an id that does not exist. A role you may not take from this person is refused on `role`, a role the person does not hold on `user`, and the owner role of the company's only owner on `roles`.

```json
{
  "code": "invalid",
  "errors": {
    "roles": [
      "There must be at least one owner for the company."
    ]
  },
  "field": "roles",
  "message": "There must be at least one owner for the company.",
  "reason": "invalid"
}
```

### 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 | `privileged_target` | That person's account can be changed only by Corefinity. Contact support. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 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_member_role_detach`](https://docs.corefinity.com/mcp/tools/corestack_team_member_role_detach.md)
