---
title: Set a member's primary department
---

# Set a member's primary department

Make one of a member's departments their primary one. A person in several departments has exactly one primary department per organisation; the [Auto model](../../../documentation/core-concepts/auto-model.md) rules of that department, and of every department above it, apply to them. Setting the current primary department changes nothing. Returns the member's departments, primary first.

{% api-container %}
{% api-content %}

{% endpoint method="PUT" path="https://api.aitronos.com/v1/organizations/{organization_id}/members/{user_id}/primary-department" /%}

## Authentication

Requires authentication (Bearer token or `x-api-key`) and the `manage_users` capability in the organisation. Requires the Auto model to be switched on for the organisation (`404 AUTO_MODEL_NOT_ENABLED` otherwise).

#### Path Parameters

**`organization_id`** string <em style="color: #ef4444 !important; font-weight: 600 !important; font-style: normal !important;">required</em>

The organisation (`org_` prefix).

**`user_id`** string <em style="color: #ef4444 !important; font-weight: 600 !important; font-style: normal !important;">required</em>

The member (`usr_` prefix).

#### Request Body

**`department_id`** string <em style="color: #ef4444 !important; font-weight: 600 !important; font-style: normal !important;">required</em>

A department the member belongs to (`dept_` prefix). Any other department is `422 AUTO_MODEL_PRIMARY_DEPARTMENT_INVALID`.

---

## Returns

Returns `200 OK` with:

**`user_id`** string — The member.

**`primary_department_id`** string — The primary department after the change.

**`departments`** array — The member's departments: the primary one first, then the rest by the date they joined. Each: `id`, `name`, `is_primary`.

{% /api-content %}
{% api-examples %}
{% tabs %}
{% tab label="Request" %}

{% code-group mode="dropdown" %}

```bash {% title="cURL" %}
curl -X PUT https://api.aitronos.com/v1/organizations/org_7d2c9e41a5b84f0e/members/usr_b7b24ad7e5fb401b/primary-department \
  -H "X-API-Key: $FREDDY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"department_id": "dept_98758e4d90e74fd8"}'
```

```python {% title="Python SDK" %}
from aitronos import Aitronos

client = Aitronos(api_key="your-api-key")

member = client.auto_model.put_primary_department(
    organization_id="org_7d2c9e41a5b84f0e",
    user_id="usr_b7b24ad7e5fb401b",
    department_id="dept_98758e4d90e74fd8",
)
print(member["primary_department_id"])
```

```python {% title="Python" %}
import os
import requests

response = requests.put(
    "https://api.aitronos.com/v1/organizations/org_7d2c9e41a5b84f0e/members/usr_b7b24ad7e5fb401b/primary-department",
    headers={"X-API-Key": os.environ["FREDDY_API_KEY"]},
    json={"department_id": "dept_98758e4d90e74fd8"},
)
print(response.json())
```

```javascript {% title="JavaScript" %}
const response = await fetch(
  'https://api.aitronos.com/v1/organizations/org_7d2c9e41a5b84f0e/members/usr_b7b24ad7e5fb401b/primary-department',
  {
    method: 'PUT',
    headers: { 'X-API-Key': process.env.FREDDY_API_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({ department_id: 'dept_98758e4d90e74fd8' }),
  },
);
console.log(await response.json());
```

{% /code-group %}

{% /tab %}
{% tab label="200 OK" %}

```json
{
  "user_id": "usr_b7b24ad7e5fb401b",
  "primary_department_id": "dept_98758e4d90e74fd8",
  "departments": [
    {"id": "dept_98758e4d90e74fd8", "name": "Sales EMEA", "is_primary": true},
    {"id": "dept_3b36cb84857c4fc4", "name": "Support", "is_primary": false}
  ]
}
```

{% /tab %}
{% tab label="Errors" %}

```json {% title="422 Unprocessable Entity" %}
{
  "success": false,
  "error": {
    "code": "AUTO_MODEL_PRIMARY_DEPARTMENT_INVALID",
    "message": "That person isn't a member of this department.",
    "type": "validation_error",
    "status": 422,
    "details": {"field": "department_id"},
    "trace_id": "2af68546-e8e2-4c2c-832c-8a742b9e50ac",
    "timestamp": "2026-10-27T04:52:06Z"
  }
}
```

```json {% title="403 Forbidden" %}
{
  "success": false,
  "error": {
    "code": "INSUFFICIENT_PERMISSIONS",
    "message": "You don't have permission to perform this action.",
    "type": "authorization_error",
    "status": 403,
    "details": {"required_capability": "manage_users"},
    "trace_id": "f508a930-bff5-4e71-b8d0-d20214958d25",
    "timestamp": "2026-10-27T04:52:06Z"
  }
}
```

```json {% title="404 Not Found" %}
{
  "success": false,
  "error": {
    "code": "AUTO_MODEL_NOT_ENABLED",
    "message": "Auto isn't available for this organisation.",
    "type": "client_error",
    "status": 404,
    "details": {"feature": "auto_model"},
    "trace_id": "5c1d2e3f-4a5b-4c6d-8e9f-0a1b2c3d4e5f",
    "timestamp": "2026-10-27T04:51:33Z"
  }
}
```

{% /tab %}
{% /tabs %}
{% /api-examples %}
{% /api-container %}

---

## Related Resources

- [Auto Model concept](../../../documentation/core-concepts/auto-model.md)
- [List members](./list.md)
- [Retrieve member](./retrieve.md)
- [Update member role](./update-role.md)
- [Remove member](./remove.md)
- [Check who gets what](../../auto-model/get-effective-settings.md)
- [List department members](../../departments/list-members.md)
