# changePersonRole

Source: /openapi/thomas-federated.openapi.json

## Operation

| Method | URL |
|---|---|
| PATCH | https://api.thomas.co/v1/company-individuals/{id}/role |

| Field | Value |
|---|---|
| operationId | changePersonRole |
| method | PATCH |
| server | https://api.thomas.co/v1 |
| path | /company-individuals/{id}/role |
| tags | `Roles & Permissions` |
| summary | Change colleague role |
| badges | `{"name":"Admin"}`, `{"name":"Owner"}` |

## Request Parameters

| Name | In | Required | Schema | Description |
|---|---|---|---|---|
| id | path | true | string | Company-individual ID of the colleague to update |

## Request Body

| Content type | Schema refs |
|---|---|
| application/json | #/components/schemas/ChangeRoleDto |

## Responses

| Status | Description | Schema refs |
|---|---|---|
| 200 | Role updated successfully | #/components/schemas/ChangeRoleResponseDto |
| 400 | Invalid UUID format | #/components/schemas/ApiErrorResponseDto |
| 401 | Invalid or missing authentication token (AUTH_TOKEN_INVALID) | #/components/schemas/ApiErrorResponseDto |
| 403 | Insufficient role or admin attempting to set owner | #/components/schemas/ApiErrorResponseDto |
| 404 | Company-individual not found | #/components/schemas/ApiErrorResponseDto |
| 422 | Cannot change own role or owner's role via this endpoint | #/components/schemas/ApiErrorResponseDto |
| 500 | Keycloak sync failed — role update rolled back |  |

## Artifact Examples

### Response 400 example

```json
{
  "statusCode": 400,
  "message": "Validation failed (uuid is expected)",
  "error": "HTTP_BAD_REQUEST"
}
```

### Response 401 example

```json
{
  "statusCode": 401,
  "message": "Invalid or missing authentication token",
  "error": "AUTH_TOKEN_INVALID"
}
```

### Response 403 example

```json
{
  "statusCode": 403,
  "message": "Insufficient role privileges",
  "error": "AUTH_INSUFFICIENT_ROLE"
}
```

### Response 404 example

```json
{
  "statusCode": 404,
  "message": "Company-individual not found",
  "error": "IDENTITY_COMPANY_INDIVIDUAL_NOT_FOUND"
}
```

### Response 422 example

```json
{
  "statusCode": 422,
  "message": "Cannot change your own role or an owner's role via this endpoint",
  "error": "IDENTITY_ROLE_CANNOT_CHANGE_OWN"
}
```
