Skip to content
View as Markdown

Recipe: online order ​

A website, bot or courier app takes an order, and it has to show up in Bito under CRM › Orders. In Bito that is a sale-order — a customer's order, not yet a sale (glossary).

Permissions needed: customer, customer_create, price, sale_order_create. organization/get-all is always allowed.

1. Find your organization ​

An order belongs to one organization. Fetch its id once and keep it.

http
GET /organization/get-all

2. Find the customer ​

http
GET /customer/get-by-phone-number?phone_number=901234567

The number is normalised: 9 digits get +998, anything else gets a leading +. When no customer matches, data is null.

3. Not found — create the customer ​

json
POST /customer/create

{
    "type": "natural",
    "name": "Aziz Karimov",
    "phone_number": "+998901234567",
    "organization_ids": ["6712f0a9c4d1e87b3a0f9911"]
}

type is natural (a person) or legal (a company). Send the phone, or step 2 will not find the customer next time. Keep the _id from the response.

4. Get the price ​

Bito does not look up the price of an order line — you send price. Take it from a price list:

json
POST /price/items/get-paging

{ "page": 1, "limit": 200, "organization_id": "…", "price_id": "…" }

Each row has the product's amount. The row carries no currency: it is the price list's currency_id (price/get-by-id). Syncing prices with the catalog: catalog recipe.

5. Create the order ​

The smallest valid body:

json
POST /sale-order/create

{
    "organization_id": "6712f0a9c4d1e87b3a0f9911",
    "customer_id": "6712f0a9c4d1e87b3a0f9922",
    "products": [
        { "product_id": "6712f0a9c4d1e87b3a0f9933", "amount": 2, "price": 45000 }
    ],
    "delivery_address": "Tashkent, Chilanzar 9",
    "note": "Web #10482"
}

The server fills in the rest:

FieldWhen you leave it out
state, state_idin_progress, in the pipeline's first regular column
responsible_idThe user the call runs as — usually the account owner
currency_idThe organization's currency
dateNow
Line price_idThe main sale price list
Line warehouse_idThe organization's main warehouse

To pick another column, send state and state_id together — a lone state_id is overwritten. If the organization has no pipeline columns, create returns an error.

Store the response's _id next to your own order; uuid (like A123) is the order number in Bito.

Retries

create is not idempotent: a repeated call creates a second order. If no response came back, first read to check whether the order exists (for example by your own order number in note).

6. Is stock reserved? ​

Only when Bito's sale setting to reserve goods in orders (booking_product_in_order) is on and the order is new, accepted or in_progress. Then the warehouse amount goes down and booked goes up. The setting is off by default, so an order does not touch stock.

7. Follow the status ​

Subscribe to the saleOrders.status_change and saleOrders.update webhooks (webhooks) and re-read the order with GET /sale-order/get-by-id/{id} when one arrives. A webhook is a signal, not the data: reconcile with sale-order/get-paging from time to time.

8. Turn it into a sale (optional) ​

Usually Bito staff sell the order. If your system records the sale too, send order_id to POST /trade/create, and each line's order_item_id from the order. The reservation is released, the sold quantities are written to the order lines, and a fully sold order becomes done. Full body: Trade. order_item_id is the line's item_id in the order response (the line's _id is the product id).

Errors ​

ResponseCause
400 validationA required field is missing or an id is wrong — read message
403, code: 10003One of the permissions was not approved; data names it
404Wrong method: create is POST, get-by-phone-number is GET

Methods ​

StepMethod
OrganizationGET /organization/get-all
Find customerGET /customer/get-by-phone-number
Create customerPOST /customer/create
PricePOST /price/items/get-paging
OrderPOST /sale-order/create
CheckPOST /sale-order/get-paging
SalePOST /trade/create

Bito 2.0 Integration API