Skip to content
Markdown

Purchase order ​

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 /purchase-order/get-by-id/{id} ​

Get a purchase order by its _id (detailed view).

Kerakli ruxsat: purchase_order · ruxsatlar qanday ishlaydi

So‘rov namunasi

bash
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/purchase-order/get-by-id/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY"
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/purchase-order/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/purchase-order/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/purchase-order/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
_idstring
numberstring
codestring
organization_idstring
supplier_idstring
supplierobject
supplier._idstring
supplier.namestring
responsible_idstring
responsibleobject
responsible._idstring
responsible.full_namestring
warehouse_idstring
currency_idstring
datestring (date-time)
delivery_datestring (date-time)
statestringMumkin qiymatlar: new, in_progress, done, canceled, draft
is_fully_purchasedboolean
totalnumber
notestring
itemsobject[]
items[]._idstring
items[].product_idstring
items[].amountnumber
items[].costnumber
items[].purchased_amountnumber
created_atstring (date-time)
updated_atstring (date-time)
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "number": "string",
    "code": "string",
    "organization_id": "string",
    "supplier_id": "string",
    "supplier": {
      "_id": "string",
      "name": "string"
    },
    "responsible_id": "string",
    "responsible": {
      "_id": "string",
      "full_name": "string"
    },
    "warehouse_id": "string",
    "currency_id": "string",
    "date": "2025-05-01T12:00:00Z",
    "delivery_date": "2025-05-01T12:00:00Z",
    "state": "new",
    "is_fully_purchased": false,
    "total": 0,
    "note": "string",
    "items": [
      {
        "_id": "string",
        "product_id": "string",
        "amount": 0,
        "cost": 0,
        "purchased_amount": 0
      }
    ],
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z"
  },
  "time": "2025-05-01T12:00:00Z"
}

POST /purchase-order/get-paging ​

Paginated list of purchase orders with optional filters.

Kerakli ruxsat: purchase_order · ruxsatlar qanday ishlaydi

So‘rov namunasi

bash
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/purchase-order/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/purchase-order/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/purchase-order/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/purchase-order/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
statesstring[]Yo‘q
organization_idstringYo‘q
supplier_idstringYo‘q
responsible_idstringYo‘q
currency_idstringYo‘q
is_fully_purchasedbooleanYo‘q
searchstringYo‘qFree-text search.
updated_atstring (date-time)Yo‘qOnly records updated at or after this time.
date_fromstring (date-time)Yo‘qStart of the date range.
date_tostring (date-time)Yo‘qEnd of the date range.
sort_bystringYo‘qField name to sort by.
ascintegerYo‘qSort direction: 1 ascending, -1 descending.. Mumkin qiymatlar: -1, 1
json
{
  "page": 1,
  "limit": 20,
  "states": [
    "new"
  ],
  "organization_id": "string",
  "supplier_id": "string",
  "responsible_id": "string",
  "currency_id": "string",
  "is_fully_purchased": false,
  "search": "string",
  "updated_at": "2025-05-01T12:00:00Z",
  "date_from": "2025-05-01T12:00:00Z",
  "date_to": "2025-05-01T12:00:00Z",
  "sort_by": "string",
  "asc": -1
}

Javob

MaydonTurTavsif
listobject[]
list[]._idstring
list[].numberstring
list[].codestring
list[].organization_idstring
list[].supplier_idstring
list[].supplierobject
list[].supplier._idstring
list[].supplier.namestring
list[].responsible_idstring
list[].responsibleobject
list[].responsible._idstring
list[].responsible.full_namestring
list[].warehouse_idstring
list[].currency_idstring
list[].datestring (date-time)
list[].delivery_datestring (date-time)
list[].statestringMumkin qiymatlar: new, in_progress, done, canceled, draft
list[].is_fully_purchasedboolean
list[].totalnumber
list[].notestring
list[].itemsobject[]
list[].items[]._idstring
list[].items[].product_idstring
list[].items[].amountnumber
list[].items[].costnumber
list[].items[].purchased_amountnumber
list[].created_atstring (date-time)
list[].updated_atstring (date-time)
totalnumber
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "list": [
      {
        "_id": "string",
        "number": "string",
        "code": "string",
        "organization_id": "string",
        "supplier_id": "string",
        "supplier": {
          "_id": null,
          "name": null
        },
        "responsible_id": "string",
        "responsible": {
          "_id": null,
          "full_name": null
        },
        "warehouse_id": "string",
        "currency_id": "string",
        "date": "2025-05-01T12:00:00Z",
        "delivery_date": "2025-05-01T12:00:00Z",
        "state": "new",
        "is_fully_purchased": false,
        "total": 0,
        "note": "string",
        "items": [],
        "created_at": "2025-05-01T12:00:00Z",
        "updated_at": "2025-05-01T12:00:00Z"
      }
    ],
    "total": 0
  },
  "time": "2025-05-01T12:00:00Z"
}

POST /purchase-order/create ​

Open a purchase order — the request stage that precedes a purchase. Ordered quantities are validated against product stock/measure rules before anything is written. state must be "new"; any other value is rejected. Returns the created order in its detailed form.

Kerakli ruxsat: purchase_order_create · ruxsatlar qanday ishlaydi

So‘rov namunasi

bash
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/purchase-order/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "organization_id": "64b7f4d9e2b3b6a0b7c5d80a",
  "ordered_at": "2025-05-01T12:00:00Z",
  "responsible_id": "string",
  "supplier_id": "string",
  "currency_id": "string",
  "requests": [
    {
      "request_id": "string",
      "products": []
    }
  ],
  "state": "new"
}'
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/purchase-order/create', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "organization_id": "64b7f4d9e2b3b6a0b7c5d80a",
    "ordered_at": "2025-05-01T12:00:00Z",
    "responsible_id": "string",
    "supplier_id": "string",
    "currency_id": "string",
    "requests": [
      {
        "request_id": "string",
        "products": []
      }
    ],
    "state": "new"
  }),
})
const { code, data } = await res.json()
python
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/purchase-order/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "organization_id": "64b7f4d9e2b3b6a0b7c5d80a",
        "ordered_at": "2025-05-01T12:00:00Z",
        "responsible_id": "string",
        "supplier_id": "string",
        "currency_id": "string",
        "requests": [
            {
                "request_id": "string",
                "products": [],
            },
        ],
        "state": "new",
    },
)
print(res.json())
php
<?php
$body = <<<'JSON'
{
  "organization_id": "64b7f4d9e2b3b6a0b7c5d80a",
  "ordered_at": "2025-05-01T12:00:00Z",
  "responsible_id": "string",
  "supplier_id": "string",
  "currency_id": "string",
  "requests": [
    {
      "request_id": "string",
      "products": []
    }
  ],
  "state": "new"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/purchase-order/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
organization_idstringHaOrganization placing the order (required). Must exist.
ordered_atstring (date-time)HaWhen the order was placed (required, ISO 8601).
purchase_datestring (date-time)Yo‘qExpected purchase/delivery date.
responsible_idstringHaResponsible user ObjectId (required).
supplier_idstringHaSupplier ObjectId (required).
supplier_assistant_idstringYo‘qSupplier-side contact person ObjectId.
currency_idstringHaCurrency the costs are quoted in (required).
price_idstringYo‘qPrice list the costs were quoted from.
statestringHaInitial state (required). Only "new" is accepted on create — anything else is rejected.. Mumkin qiymatlar: new, accepted, in_progress, done, canceled, draft
state_idstringYo‘qBoard column ObjectId. When omitted the default column for the state is resolved.
codestringYo‘qCaller-supplied external code.
notestringYo‘qFree-text note.
requestsobject[]HaOrder lines grouped by source purchase request (required, at least one group).
requests[].request_idstringYo‘qSource purchase-request ObjectId. Omit for an order raised without a request.
requests[].productsobject[]HaLines in this group (required, at least one).
requests[].products[].product_idstringHaProduct ObjectId (required).
requests[].products[].amountnumberHaOrdered quantity (required, > 0). Validated against the product measure.
requests[].products[].box_countnumberYo‘qWhole boxes ordered. Defaults to 0.
requests[].products[].costnumberYo‘qUnit cost in the order currency.
requests[].products[].total_costnumberYo‘qLine total. Derived when omitted.
requests[].products[].request_item_idstringYo‘qSource purchase-request line this order line fulfils.
requests[].products[].used_measureobjectYo‘qAlternative unit of measure: { _id, ratio, amount }.
attachmentsobject[]Yo‘qAttached files: { name, path, size, note }.
json
{
  "organization_id": "64b7f4d9e2b3b6a0b7c5d80a",
  "ordered_at": "2025-05-01T12:00:00Z",
  "purchase_date": "2025-05-01T12:00:00Z",
  "responsible_id": "string",
  "supplier_id": "string",
  "supplier_assistant_id": "string",
  "currency_id": "string",
  "price_id": "string",
  "state": "new",
  "state_id": "string",
  "code": "string",
  "note": "string",
  "requests": [
    {
      "request_id": "string",
      "products": []
    }
  ],
  "attachments": [
    {}
  ]
}

Javob

Javob tuzilishi quyidagi bilan bir xil: GET /purchase-order/get-by-id/{id}.

PUT /purchase-order/set-state ​

Move a purchase order along its lifecycle. Allowed transitions: new → in_progress | accepted | canceled; in_progress → done | in_progress; accepted → done. Returns the updated order in its detailed form.

Kerakli ruxsat: purchase_order_update · ruxsatlar qanday ishlaydi

So‘rov namunasi

bash
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/purchase-order/set-state' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "_id": "64b7f4d9e2b3b6a0b7c5d80a",
  "state": "new"
}'
js
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/purchase-order/set-state', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "_id": "64b7f4d9e2b3b6a0b7c5d80a",
    "state": "new"
  }),
})
const { code, data } = await res.json()
python
import os
import requests

res = requests.request(
    "PUT",
    "https://api.bito.uz/integration-api/integration/api/v2/purchase-order/set-state",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "_id": "64b7f4d9e2b3b6a0b7c5d80a",
        "state": "new",
    },
)
print(res.json())
php
<?php
$body = <<<'JSON'
{
  "_id": "64b7f4d9e2b3b6a0b7c5d80a",
  "state": "new"
}
JSON;

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

So‘rov tanasi

MaydonTurMajburiyTavsif
_idstringHaPurchase order ObjectId (required).
statestringHaTarget state (required). Allowed transitions: new → in_progress | accepted | canceled; in_progress → done | in_progress; accepted → done. An unsupported transition is rejected.. Mumkin qiymatlar: new, accepted, in_progress, done, canceled, draft
state_idstringYo‘qBoard column ObjectId to move the order into.
json
{
  "_id": "64b7f4d9e2b3b6a0b7c5d80a",
  "state": "new",
  "state_id": "string"
}

Javob

Javob tuzilishi quyidagi bilan bir xil: GET /purchase-order/get-by-id/{id}.


Bu sahifa OpenAPI spetsifikatsiyasidan yaratilgan.

Bito 2.0 Integration API