Skip to content

Purchase order ​

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

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

Path parameters

ParameterTypeRequiredDescription
idstringYes

Request body

No request body.

Response

FieldTypeDescription
_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)
statestringOne of: 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.

Request body

FieldTypeRequiredDescription
pagenumberYesDefault: 1
limitnumberYesDefault: 20
statesstring[]No
organization_idstringNo
supplier_idstringNo
responsible_idstringNo
currency_idstringNo
is_fully_purchasedbooleanNo
json
{
  "page": 1,
  "limit": 20,
  "states": [
    "new"
  ],
  "organization_id": "string",
  "supplier_id": "string",
  "responsible_id": "string",
  "currency_id": "string",
  "is_fully_purchased": false
}

Response

FieldTypeDescription
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[].statestringOne of: 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.

Request body

FieldTypeRequiredDescription
organization_idstringYesOrganization placing the order (required). Must exist.
ordered_atstring (date-time)YesWhen the order was placed (required, ISO 8601).
purchase_datestring (date-time)NoExpected purchase/delivery date.
responsible_idstringYesResponsible user ObjectId (required).
supplier_idstringYesSupplier ObjectId (required).
supplier_assistant_idstringNoSupplier-side contact person ObjectId.
currency_idstringYesCurrency the costs are quoted in (required).
price_idstringNoPrice list the costs were quoted from.
statestringYesInitial state (required). Only "new" is accepted on create — anything else is rejected.. One of: new, accepted, in_progress, done, canceled, draft
state_idstringNoBoard column ObjectId. When omitted the default column for the state is resolved.
codestringNoCaller-supplied external code.
notestringNoFree-text note.
requestsobject[]YesOrder lines grouped by source purchase request (required, at least one group).
requests[].request_idstringNoSource purchase-request ObjectId. Omit for an order raised without a request.
requests[].productsobject[]YesLines in this group (required, at least one).
requests[].products[].product_idstringYesProduct ObjectId (required).
requests[].products[].amountnumberYesOrdered quantity (required, > 0). Validated against the product measure.
requests[].products[].box_countnumberNoWhole boxes ordered. Defaults to 0.
requests[].products[].costnumberNoUnit cost in the order currency.
requests[].products[].total_costnumberNoLine total. Derived when omitted.
requests[].products[].request_item_idstringNoSource purchase-request line this order line fulfils.
requests[].products[].used_measureobjectNoAlternative unit of measure: { _id, ratio, amount }.
attachmentsobject[]NoAttached 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": [
    {}
  ]
}

Response

Same response shape as 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.

Request body

FieldTypeRequiredDescription
_idstringYesPurchase order ObjectId (required).
statestringYesTarget state (required). Allowed transitions: new → in_progress | accepted | canceled; in_progress → done | in_progress; accepted → done. An unsupported transition is rejected.. One of: new, accepted, in_progress, done, canceled, draft
state_idstringNoBoard column ObjectId to move the order into.
json
{
  "_id": "64b7f4d9e2b3b6a0b7c5d80a",
  "state": "new",
  "state_id": "string"
}

Response

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


This page is generated from the OpenAPI spec.

Bito 2.0 Integration API