For AI agents: markdown of this page — /docs-content-en/humanresources/members/set.md documentation index — /llms.txt

Replace membership

POST /v1/humanresources/nodes/:id/members/set

Fully replaces the node membership with a new set grouped by role. Previous members that are absent from the request are removed from the node.

Parameters

Parameter Type Required Description
id (path) number yes Identifier of the node whose membership is being replaced

Request body fields

Field Type Required Description
userIds object yes The new node membership. The key is a role, the value is an array of employee identifiers for that role. Available roles — Node members. Employee identifiers: POST /v1/humanresources/employees/search

Examples

curl — personal key

Terminal
curl -X POST -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"userIds": {"MEMBER_HEAD": [42], "MEMBER_EMPLOYEE": [108, 256]}}' \
  https://vibecode.bitrix24.com/v1/humanresources/nodes/23/members/set

curl — OAuth application

Terminal
curl -X POST -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"userIds": {"MEMBER_HEAD": [42], "MEMBER_EMPLOYEE": [108, 256]}}' \
  https://vibecode.bitrix24.com/v1/humanresources/nodes/23/members/set

JavaScript — personal key

javascript
const res = await fetch(
  'https://vibecode.bitrix24.com/v1/humanresources/nodes/23/members/set',
  {
    method: 'POST',
    headers: {
      'X-Api-Key': 'YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      userIds: { MEMBER_HEAD: [42], MEMBER_EMPLOYEE: [108, 256] },
    }),
  }
)
const body = await res.json()

JavaScript — OAuth application

javascript
const res = await fetch(
  'https://vibecode.bitrix24.com/v1/humanresources/nodes/23/members/set',
  {
    method: 'POST',
    headers: {
      'X-Api-Key': 'YOUR_APP_KEY',
      'Authorization': 'Bearer USER_SESSION_TOKEN',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      userIds: { MEMBER_HEAD: [42], MEMBER_EMPLOYEE: [108, 256] },
    }),
  }
)
const body = await res.json()

Response fields

Field Type Description
success boolean true on successful execution
data.success boolean true if the node membership was replaced

Response example

JSON
{
  "success": true,
  "data": {
    "success": true
  }
}

Error response example

404 — unknown operation in the path:

JSON
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Unknown member verb: frobnicate. Allowed: move, remove, add, set"
  }
}

Errors

HTTP Code Description
400 INVALID_PARAMS :id is not a positive integer, or the request body structure is invalid
404 NOT_FOUND Unknown operation in the path after members
403 SCOPE_DENIED The key is missing the humanresources scope
401 TOKEN_MISSING The API key has no Bitrix24 tokens configured

Full list of common API errors — Errors.

Known specifics

  • The request defines the entire node membership at once. Unlike Add members and Move members, which change individual roles, this operation replaces the node membership with the one passed in userIds. Employees absent from the request do not remain in the node.
  • userIds is an object grouped by role. Here userIds is an object where the key sets the role and the value is an array of employee identifiers for that role. In the add, remove, and move operations, userIds is an array of identifiers with a separate role field.

See also