Skip to content

Section ​

INFO

Every response arrives in the shared envelope — code, message, messages, status_code, time — with the payload in data. The tables below describe what is inside data.

GET /section/get-by-id/{id} ​

Get section using its _id

Path parameters

ParameterTypeRequiredDescription
idstringYes

Request body

No request body.

Response

FieldTypeDescription
namestring
created_atstring
updated_atstring
is_deletedboolean
parent_idstring
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "name": "string",
    "created_at": "string",
    "updated_at": "string",
    "is_deleted": false,
    "parent_id": "string"
  },
  "time": "2025-05-01T12:00:00Z"
}

POST /section/get-paging ​

Get sections by paging

Request body

FieldTypeRequiredDescription
pagenumberYesDefault: 1
limitnumberYesDefault: 20
searchstringNo
parent_idstringNo
organization_idstringNo
topbooleanNoDefault: false
updated_atstring (date-time)No
json
{
  "page": 1,
  "limit": 20,
  "search": "string",
  "parent_id": "63f8b0c4e4b0d3a2f8e4b0c4",
  "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
  "top": false,
  "updated_at": "2024-07-20T10:30:00Z"
}

Response

data.total is the total number of records and data.data[] holds the current page. The table below describes one record.

FieldTypeDescription
namestring
created_atstring
updated_atstring
is_deletedboolean
parentobject
parent._idstring
parent.is_deletedboolean
parent.namestring
chiefobject
chief._idstring
chief.full_namestring
chief.is_deletedboolean
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "data": [
      {
        "name": "string",
        "created_at": "string",
        "updated_at": "string",
        "is_deleted": false,
        "parent": {
          "_id": "string",
          "is_deleted": false,
          "name": "string"
        },
        "chief": {
          "_id": "string",
          "full_name": "string",
          "is_deleted": false
        }
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}

POST /section/create ​

Create a section (HR department). name and organizations (at least one entry) are required; parent_id nests the section under an existing one. Returns the created section with its parent expanded. Fails with 400 if a referenced organization, chief user or parent section does not exist.

Request body

FieldTypeRequiredDescription
namestringYesSection name (required, 3-100 characters).
organizationsobject[]YesPer-organization presence of the section (required, at least one).
organizations[].organization_idstringYesOrganization the section exists in (required). Must exist.
organizations[].is_availablebooleanYesWhether the section is active in this organization (required). A section whose every organization entry is is_available=false is auto soft-deleted by the backend.
organizations[].chief_idstringNoUser who heads the section in this organization. Must reference an existing user.
parent_idstringNoParent section, for a nested department tree. Must reference an existing section. Omit for a top-level section.
json
{
  "name": "Sales department",
  "organizations": [
    {
      "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
      "is_available": false,
      "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4"
    }
  ],
  "parent_id": "63f8b0c4e4b0d3a2f8e4b0c4"
}

Response

Same response shape as GET /section/get-by-id/{id}.

PUT /section/update/{id} ​

Update a section by ObjectId. name and organizations are both required — this is a full replacement of those fields, not a patch. The organizations named in the payload are pulled and re-pushed; organizations not named keep their existing entry. Returns the updated section with its parent expanded.

Path parameters

ParameterTypeRequiredDescription
idstringYesSection ObjectId to update

Request body

FieldTypeRequiredDescription
namestringYesUpdated section name (required, 3-100 characters).
organizationsobject[]YesFull replacement set of per-organization entries (required, at least one). The entries for the organizations named here are removed and re-added, so send every organization the section should remain active in — an organization left out keeps its previous entry.
organizations[].organization_idstringYesOrganization the section exists in (required). Must exist.
organizations[].is_availablebooleanYesWhether the section is active in this organization (required). A section whose every organization entry is is_available=false is auto soft-deleted by the backend.
organizations[].chief_idstringNoUser who heads the section in this organization. Must reference an existing user.
parent_idstringNoUpdated parent section. Must reference an existing section.
json
{
  "name": "Sales department",
  "organizations": [
    {
      "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
      "is_available": false,
      "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4"
    }
  ],
  "parent_id": "63f8b0c4e4b0d3a2f8e4b0c4"
}

Response

Same response shape as GET /section/get-by-id/{id}.

DELETE /section/delete/{id} ​

Soft-delete a section by ObjectId (sets is_deleted=true). Refuses with 400 when another section still names this one as its parent, or when any position still belongs to it — that error payload lists the blocking positions. Delete the child sections and re-home the positions first. Deleting an already-deleted section is a no-op.

Path parameters

ParameterTypeRequiredDescription
idstringYesSection ObjectId to delete

Request body

No request body.

Response

json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": "63f8b0c4e4b0d3a2f8e4b0c4",
  "time": "2025-05-01T12:00:00Z"
}

This page is generated from the OpenAPI spec.

Bito 2.0 Integration API