Skip to content
Markdown

Reason ​

Configurable reasons used across business flows

INFO

Каждый ответ приходит в общем конверте — code, message, messages, status_code, time — а полезная нагрузка лежит в data. Таблицы ниже описывают содержимое data.

POST /reason/create ​

Create a new reason. Reasons are configurable reference data used in business flows such as supplier returns, customer returns, purchase requests, order cancellations, transfers, write-offs, and more. name is required; type should be provided (model requires it — omitting type produces a validation error). is_active defaults to false.

Нужное разрешение: нет — закрыто для приложения, объявившего разрешения · как работают разрешения

Пример запроса

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

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/reason/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "name": "string",
    },
)
print(res.json())
php
<?php
$body = <<<'JSON'
{
  "name": "string"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/reason/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);

Тело запроса

ПолеТипОбязательноОписание
namestringДаReason display name (required)
typestringНетReason type — determines which business flow this reason applies to. Note: the model requires a type; omitting it will produce a Mongoose validation error.. Допустимые значения: supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task
descriptionstringНетOptional description
is_activebooleanНетWhether this reason is active. Defaults to false.
is_trashbooleanНетWhether this reason is for trash/disposal flows.
codestringНетOptional short code identifier for the reason.
order_numbernumberНетSort order (ascending). Used to control display order.
colorstringНетHex color code, format #RRGGBB (e.g. #FF5733)
json
{
  "name": "string",
  "type": "supplier_return",
  "description": "string",
  "is_active": false,
  "is_trash": false,
  "code": "string",
  "order_number": 0,
  "color": "string"
}

Ответ

ПолеТипОписание
_idstringReason ObjectId
namestringReason display name
typestringReason type — determines which business flow this reason applies to. Допустимые значения: supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task
descriptionstringOptional description
is_activebooleanWhether this reason is active
is_trashbooleanWhether this reason is for trash/disposal flows
codestringShort code identifier
order_numbernumberSort order (ascending)
colorstringHex color code, format #RRGGBB
created_atstring (date-time)Creation timestamp
updated_atstring (date-time)Last update timestamp
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "name": "string",
    "type": "supplier_return",
    "description": "string",
    "is_active": false,
    "is_trash": false,
    "code": "string",
    "order_number": 0,
    "color": "string",
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z"
  },
  "time": "2025-05-01T12:00:00Z"
}

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

Fetch a single reason by its ObjectId.

Нужное разрешение: нет — закрыто для приложения, объявившего разрешения · как работают разрешения

Пример запроса

bash
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/reason/get-by-id/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY"
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/reason/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/reason/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/reason/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);

Параметры пути

ПараметрТипОбязательноОписание
idstringДаReason ObjectId

Тело запроса

Тело запроса не требуется.

Ответ

Структура ответа совпадает с POST /reason/create.

POST /reason/get-paging ​

Paginated list of reasons. Filter by type (supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task) and/or is_active. Results sorted by order_number asc, _id desc (or sort_by override).

Нужное разрешение: нет — закрыто для приложения, объявившего разрешения · как работают разрешения

Пример запроса

bash
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/reason/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/reason/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/reason/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/reason/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);

Тело запроса

ПолеТипОбязательноОписание
pagenumberДаПо умолчанию: 1
limitnumberДаПо умолчанию: 20
typestringНетFilter by reason type. Omit to return reasons of all types.. Допустимые значения: supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task
is_activebooleanНетFilter by active state. Omit to return both active and inactive reasons.
searchstringНетFree-text search.
updated_atstring (date-time)НетOnly records updated at or after this time.
organization_idstringНетOrganization ObjectId.
sort_bystringНетField name to sort by.
ascintegerНетSort direction: 1 ascending, -1 descending.. Допустимые значения: -1, 1
json
{
  "page": 1,
  "limit": 20,
  "type": "supplier_return",
  "is_active": false,
  "search": "string",
  "updated_at": "2025-05-01T12:00:00Z",
  "organization_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "sort_by": "string",
  "asc": -1
}

Ответ

ПолеТипОписание
totalnumber
listobject[]
list[]._idstringReason ObjectId
list[].namestringReason display name
list[].typestringReason type — determines which business flow this reason applies to. Допустимые значения: supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task
list[].descriptionstringOptional description
list[].is_activebooleanWhether this reason is active
list[].is_trashbooleanWhether this reason is for trash/disposal flows
list[].codestringShort code identifier
list[].order_numbernumberSort order (ascending)
list[].colorstringHex color code, format #RRGGBB
list[].created_atstring (date-time)Creation timestamp
list[].updated_atstring (date-time)Last update timestamp
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "list": [
      {
        "_id": "string",
        "name": "string",
        "type": "supplier_return",
        "description": "string",
        "is_active": false,
        "is_trash": false,
        "code": "string",
        "order_number": 0,
        "color": "string",
        "created_at": "2025-05-01T12:00:00Z",
        "updated_at": "2025-05-01T12:00:00Z"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}

PUT /reason/update/{id} ​

Update an existing reason by ObjectId. All fields are optional; only provided fields are updated. name must be non-empty if provided.

Нужное разрешение: нет — закрыто для приложения, объявившего разрешения · как работают разрешения

Пример запроса

bash
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/reason/update/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string"
}'
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/reason/update/6712f0a9c4d1e87b3a0f9911', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "name": "string"
  }),
})
const { code, data } = await res.json()
python
import os
import requests

res = requests.request(
    "PUT",
    "https://api.bito.uz/integration-api/integration/api/v2/reason/update/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "name": "string",
    },
)
print(res.json())
php
<?php
$body = <<<'JSON'
{
  "name": "string"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/reason/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);

Параметры пути

ПараметрТипОбязательноОписание
idstringДаReason ObjectId to update

Тело запроса

ПолеТипОбязательноОписание
namestringДаUpdated reason display name
typestringНетUpdated reason type. Допустимые значения: supplier_return, customer_return, purchase_request, contract_cancel, order_cancel, transfer, transfer_cancel, write_off, visit_reject, delivery_order_cancel, task
descriptionstringНетUpdated description
is_activebooleanНетToggle active state
is_trashbooleanНетToggle trash/disposal flag
codestringНетUpdated short code identifier
order_numbernumberНетUpdated sort order
colorstringНетUpdated hex color code, format #RRGGBB
json
{
  "name": "string",
  "type": "supplier_return",
  "description": "string",
  "is_active": false,
  "is_trash": false,
  "code": "string",
  "order_number": 0,
  "color": "string"
}

Ответ

Структура ответа совпадает с POST /reason/create.

DELETE /reason/delete/{id} ​

Soft-delete a reason by ObjectId (sets is_deleted=true). Returns 400 if the reason is not found.

Нужное разрешение: нет — закрыто для приложения, объявившего разрешения · как работают разрешения

Пример запроса

bash
curl -X DELETE 'https://api.bito.uz/integration-api/integration/api/v2/reason/delete/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY"
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/reason/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/reason/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/reason/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);

Параметры пути

ПараметрТипОбязательноОписание
idstringДаReason ObjectId to delete

Тело запроса

Тело запроса не требуется.

Ответ

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

Эта страница сгенерирована из спецификации OpenAPI.

Bito 2.0 Integration API