Skip to content
Markdown

Section ​

INFO

Har bir javob umumiy konvertda qaytadi — code, message, messages, status_code, time — foydali yuk esa data ichida. Quyidagi jadvallar faqat data ichini tavsiflaydi.

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

Get section using its _id

Kerakli ruxsat: section · ruxsatlar qanday ishlaydi

So‘rov namunasi

bash
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/section/get-by-id/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY"
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/section/get-by-id/6712f0a9c4d1e87b3a0f9911', {
  method: 'GET',
  headers: { 'api-key': process.env.BITO_API_KEY },
})
const { code, data } = await res.json()
python
import os
import requests

res = requests.request(
    "GET",
    "https://api.bito.uz/integration-api/integration/api/v2/section/get-by-id/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
)
print(res.json())
php
<?php
$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/section/get-by-id/6712f0a9c4d1e87b3a0f9911');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY')],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);

Yo‘l parametrlari

ParametrTurMajburiyTavsif
idstringHa

So‘rov tanasi

So‘rov tanasi talab qilinmaydi.

Javob

MaydonTurTavsif
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

Kerakli ruxsat: section · ruxsatlar qanday ishlaydi

So‘rov namunasi

bash
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/section/get-paging' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "page": 1,
  "limit": 20
}'
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/section/get-paging', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "page": 1,
    "limit": 20
  }),
})
const { code, data } = await res.json()
python
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/section/get-paging",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "page": 1,
        "limit": 20,
    },
)
print(res.json())
php
<?php
$body = <<<'JSON'
{
  "page": 1,
  "limit": 20
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/section/get-paging');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);

So‘rov tanasi

MaydonTurMajburiyTavsif
pagenumberHaStandart: 1
limitnumberHaStandart: 20
searchstringYo‘q
parent_idstringYo‘q
organization_idstringYo‘q
topbooleanYo‘qStandart: false
updated_atstring (date-time)Yo‘q
_idstringYo‘q
json
{
  "page": 1,
  "limit": 20,
  "search": "string",
  "parent_id": "63f8b0c4e4b0d3a2f8e4b0c4",
  "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
  "top": false,
  "updated_at": "2024-07-20T10:30:00Z",
  "_id": "64b7f4d9e2b3b6a0b7c5d7ff"
}

Javob

data.total — jami yozuvlar soni, data.data[] — joriy sahifadagi yozuvlar. Quyidagi jadval bitta yozuvni tavsiflaydi.

MaydonTurTavsif
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.

Kerakli ruxsat: section_create · ruxsatlar qanday ishlaydi

So‘rov namunasi

bash
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/section/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Sales department",
  "organizations": [
    {
      "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
      "is_available": false,
      "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4"
    }
  ]
}'
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/section/create', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "name": "Sales department",
    "organizations": [
      {
        "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
        "is_available": false,
        "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4"
      }
    ]
  }),
})
const { code, data } = await res.json()
python
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/section/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "name": "Sales department",
        "organizations": [
            {
                "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
                "is_available": False,
                "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4",
            },
        ],
    },
)
print(res.json())
php
<?php
$body = <<<'JSON'
{
  "name": "Sales department",
  "organizations": [
    {
      "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
      "is_available": false,
      "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4"
    }
  ]
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/section/create');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);

So‘rov tanasi

MaydonTurMajburiyTavsif
namestringHaSection name (required, 3-100 characters).
organizationsobject[]HaPer-organization presence of the section (required, at least one).
organizations[].organization_idstringHaOrganization the section exists in (required). Must exist.
organizations[].is_availablebooleanHaWhether 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_idstringYo‘qUser who heads the section in this organization. Must reference an existing user.
parent_idstringYo‘qParent 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"
}

Javob

Javob tuzilishi quyidagi bilan bir xil: 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.

Kerakli ruxsat: section_update · ruxsatlar qanday ishlaydi

So‘rov namunasi

bash
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/section/update/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Sales department",
  "organizations": [
    {
      "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
      "is_available": false,
      "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4"
    }
  ]
}'
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/section/update/6712f0a9c4d1e87b3a0f9911', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "name": "Sales department",
    "organizations": [
      {
        "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
        "is_available": false,
        "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4"
      }
    ]
  }),
})
const { code, data } = await res.json()
python
import os
import requests

res = requests.request(
    "PUT",
    "https://api.bito.uz/integration-api/integration/api/v2/section/update/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "name": "Sales department",
        "organizations": [
            {
                "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
                "is_available": False,
                "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4",
            },
        ],
    },
)
print(res.json())
php
<?php
$body = <<<'JSON'
{
  "name": "Sales department",
  "organizations": [
    {
      "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
      "is_available": false,
      "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4"
    }
  ]
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/section/update/6712f0a9c4d1e87b3a0f9911');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);

Yo‘l parametrlari

ParametrTurMajburiyTavsif
idstringHaSection ObjectId to update

So‘rov tanasi

MaydonTurMajburiyTavsif
namestringHaUpdated section name (required, 3-100 characters).
organizationsobject[]HaFull 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_idstringHaOrganization the section exists in (required). Must exist.
organizations[].is_availablebooleanHaWhether 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_idstringYo‘qUser who heads the section in this organization. Must reference an existing user.
parent_idstringYo‘qUpdated parent section. Must reference an existing section.
json
{
  "name": "Sales department",
  "organizations": [
    {
      "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
      "is_available": false,
      "chief_id": "63f8b0c4e4b0d3a2f8e4b0c4"
    }
  ],
  "parent_id": "63f8b0c4e4b0d3a2f8e4b0c4"
}

Javob

Javob tuzilishi quyidagi bilan bir xil: 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.

Kerakli ruxsat: section_delete · ruxsatlar qanday ishlaydi

So‘rov namunasi

bash
curl -X DELETE 'https://api.bito.uz/integration-api/integration/api/v2/section/delete/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY"
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/section/delete/6712f0a9c4d1e87b3a0f9911', {
  method: 'DELETE',
  headers: { 'api-key': process.env.BITO_API_KEY },
})
const { code, data } = await res.json()
python
import os
import requests

res = requests.request(
    "DELETE",
    "https://api.bito.uz/integration-api/integration/api/v2/section/delete/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
)
print(res.json())
php
<?php
$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/section/delete/6712f0a9c4d1e87b3a0f9911');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY')],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);

Yo‘l parametrlari

ParametrTurMajburiyTavsif
idstringHaSection ObjectId to delete

So‘rov tanasi

So‘rov tanasi talab qilinmaydi.

Javob

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

Bu sahifa OpenAPI spetsifikatsiyasidan yaratilgan.

Bito 2.0 Integration API