
## Get a department

`GET /v1/departments/:id`

Returns a single department by identifier with all its fields.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Department ID |

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/departments/47" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/departments/47" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/departments/47', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
console.log('Department:', data.name, '— head ID', data.headId)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/departments/47', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | object | The department. Field descriptions — [Department fields](/docs/entities/departments/fields) |
| `data.id` | number | Department ID |
| `data.name` | string | Department name |
| `data.parentId` | number | Parent department ID. Source: [`GET /v1/departments`](./list.md) |
| `data.headId` | number | Department head ID. Source: [`GET /v1/users`](/docs/entities/users). If no head is assigned, the value is `0` or the field is absent |
| `data.sort` | number | Department order among siblings |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 47,
    "name": "Sales department",
    "sort": 500,
    "parentId": 1,
    "headId": 99
  }
}
```

## Error response example

404 — department not found:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "department 9999 not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 404 | `ENTITY_NOT_FOUND` | No department with this ID was found |
| 403 | `SCOPE_DENIED` | The API key does not have the `department` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

Full list of common API errors — [Errors](/docs/errors).

## See also

- [Department fields](/docs/entities/departments/fields)
- [Update a department](/docs/entities/departments/update)
- [List departments](/docs/entities/departments/list)
- [Employees](/docs/entities/users)
