
## Create node

`POST /v1/humanresources/nodes`

Creates a node in the org structure of a Bitrix24 account: a department or a team in the department tree. The node type is set by the `type` field; fields are passed flat at the JSON root without a `fields` wrapper.

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `type` | string | yes | Node type: `DEPARTMENT` (department) or `TEAM` (team) |
| `name` | string | yes | Node name |
| `parentId` | number | no | Parent node identifier in the tree. List: `GET /v1/humanresources/nodes` |
| `description` | string | no | Node description |
| `colorName` | string | no | Node color code, for example `blue` or `AZURE` |
| `userIds` | object | no | Members by role, assigned at creation: `{ "MEMBER_HEAD": [1], "MEMBER_EMPLOYEE": [2, 3] }`. The key is the role, the value is an array of identifiers (not a flat array, unlike [adding members](/docs/humanresources/members/add)) |
| `moveUsersToNode` | boolean | no | Move the employees in `userIds` to the new node, removing them from their previous ones. Defaults to `false` |
| `createChat` | boolean | no | Create a group chat for the node. Defaults to `false` |
| `bindingChatIds` | number[] | no | Identifiers of existing chats to bind to the node |
| `createChannel` | boolean | no | Create a channel for the node. Defaults to `false` |
| `bindingChannelIds` | number[] | no | Identifiers of existing channels to bind |
| `createCollab` | boolean | no | Create a collab for the node. Defaults to `false` |
| `bindingCollabIds` | number[] | no | Identifiers of existing collabs to bind |

Fields filled in by the system (`id`, `structureId`, `accessCode`, `userCount`, `xmlId`, `createdAt`, `updatedAt`) must not be passed in the body: a request with any of them is rejected with the `READONLY_FIELD` error. These fields are returned in the response.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/humanresources/nodes" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "DEPARTMENT",
    "name": "Sales department",
    "parentId": 1,
    "description": "Active sales managers",
    "colorName": "blue"
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/humanresources/nodes" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "DEPARTMENT",
    "name": "Sales department",
    "parentId": 1,
    "description": "Active sales managers",
    "colorName": "blue"
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/humanresources/nodes', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    type: 'DEPARTMENT',
    name: 'Sales department',
    parentId: 1,
    description: 'Active sales managers',
    colorName: 'blue',
  }),
})

const { success, data } = await res.json()
console.log('Node ID:', data.id)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/humanresources/nodes', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    type: 'DEPARTMENT',
    name: 'Sales department',
    parentId: 1,
    description: 'Active sales managers',
    colorName: 'blue',
  }),
})

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

## Response fields

Returns the full record of the created node.

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | object | The created node. Field schema — [Node fields](/docs/humanresources/nodes/fields) |
| `data.id` | number | Identifier of the created node |
| `data.name` | string | Node name |
| `data.type` | string | Node type: `DEPARTMENT` or `TEAM` |
| `data.structureId` | number | Identifier of the structure the node belongs to |
| `data.parentId` | number | Parent node identifier |
| `data.description` | string | Node description |
| `data.accessCode` | string | Node access code generated by the system |
| `data.userCount` | number | Number of employees in the node. `0` for a new node |
| `data.colorName` | string | Node color |
| `data.xmlId` | string | External identifier of the node |
| `data.createdAt` | datetime | Creation date |
| `data.updatedAt` | datetime | Last update date |
| `data.members` | array | List of node members. An empty array for a new node |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 39,
    "name": "Sales department",
    "type": "DEPARTMENT",
    "structureId": 1,
    "parentId": 1,
    "description": "Active sales managers",
    "accessCode": "SN39",
    "userCount": 0,
    "colorName": "blue",
    "xmlId": null,
    "createdAt": "2026-06-03T13:06:45.000Z",
    "updatedAt": "2026-06-03T13:06:45.000Z",
    "members": []
  }
}
```

## Error response example

400 — required field `name` not provided:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Request object validation failed",
    "validation": [
      {
        "field": "MISSING_NAME",
        "message": "Parameter \"name\" is required."
      }
    ]
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | A required field was not provided. `error.validation` contains the marker `MISSING_NAME` (`name` missing) or `MISSING_TYPE` (`type` missing) |
| 400 | `READONLY_FIELD` | The body contains a field filled in by the system, such as `id` or `accessCode`. The field name is given in `message` |
| 403 | `SCOPE_DENIED` | The key lacks the `humanresources` scope |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

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

## Known specifics

**Initial node setup in a single request.** Besides the base fields, you can set the member roster by role (`userIds`) and communication tools right at creation: create a chat, channel or collab (`createChat` / `createChannel` / `createCollab`) or bind existing ones by identifiers (`bindingChatIds` / `bindingChannelIds` / `bindingCollabIds`). These fields are optional — without them an empty node is created.

## Batch creation

`POST /v1/humanresources/nodes/batch` accepts `action: "create"` and an `items` array containing the node fields described above. For example: `{"action":"create","items":[{"type":"DEPARTMENT","name":"Sales","parentId":1},{"type":"DEPARTMENT","name":"Support","parentId":1}]}`.

The response is HTTP 200 with `data.results` and `data.summary`. A successful item contains `index` (its zero-based position in the original array), `success: true` and `id`. A failed item contains the same `index`, `success: false`, `error` and `message`. `summary` contains `total`, `succeeded` and `failed`; check each item even with HTTP 200. One failed item does not undo the successful writes of the other items. Each item requires a separate Bitrix24 call. Items are created sequentially to avoid conflicting changes to the shared structure.

| HTTP | Item code | Condition |
|------|-----------|-----------|
| 200 | `WRITE_OUTCOME_UNKNOWN` | Bitrix24 responded without a valid created node ID. The item contains `details.outcome: "unknown"` and `details.retryable: false` |

Timeouts and other errors with an uncertain outcome also contain `details.outcome: "unknown"` and `details.retryable: false`, preserving their own error code. The node may already exist in the Bitrix24 account: check the [node list](/docs/humanresources/nodes/list) before trying again. Do not automatically retry such an item.

## See also

- [List nodes](/docs/humanresources/nodes/list)
- [Get node](/docs/humanresources/nodes/get)
- [Update node](/docs/humanresources/nodes/update)
- [Search nodes](/docs/humanresources/nodes/search)
- [Org structure nodes](/docs/humanresources/nodes)
