> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leavo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Organize your team and control conversation visibility with departments

## What are Departments?

Departments allow you to organize your team into groups (e.g., Sales, Support, Finance) and control which conversations each group can view.

<CardGroup cols={2}>
  <Card title="Organization" icon="sitemap">
    Group users by function or area of expertise
  </Card>

  <Card title="Visibility" icon="eye">
    Operators only see conversations from their department
  </Card>
</CardGroup>

## Visibility Rules

| Role                            | Visible Conversations                                       |
| ------------------------------- | ----------------------------------------------------------- |
| **Owner / Admin**               | All conversations (with optional department filter)         |
| **Operator with department**    | Their department's conversations + unassigned conversations |
| **Operator without department** | Only unassigned conversations                               |

## Department Model

```json theme={null}
{
  "id": "uuid",
  "tenant_id": "uuid",
  "name": "Sales",
  "description": "Sales team",
  "member_count": 5,
  "created_at": "2024-01-15T10:00:00Z",
  "updated_at": "2024-01-15T10:00:00Z"
}
```

## Endpoints

| Method   | Endpoint                                     | Description       |
| -------- | -------------------------------------------- | ----------------- |
| `GET`    | `/backend/departments`                       | List departments  |
| `GET`    | `/backend/departments/my`                    | My departments    |
| `POST`   | `/backend/departments`                       | Create department |
| `GET`    | `/backend/departments/{id}`                  | Get department    |
| `PUT`    | `/backend/departments/{id}`                  | Update department |
| `DELETE` | `/backend/departments/{id}`                  | Delete department |
| `GET`    | `/backend/departments/{id}/members`          | List members      |
| `POST`   | `/backend/departments/{id}/members`          | Add member        |
| `DELETE` | `/backend/departments/{id}/members/{userId}` | Remove member     |

## Permissions (RBAC)

* **Admin/Owner**: Full access (department and member CRUD)
* **Operator**: Only `GET /departments/my` (view their own departments)
