# Recipe: catalog sync

Products, prices and stock flow from Bito to your storefront. You need two modes: a frequent
**incremental** sync and a **full** reconcile once a day.

**Permissions needed:** `product`, `price`, `product_stock`.

## 1. Pick the organization and price list

```http
GET /organization/get-all
GET /price/get-all
```

For a storefront, pick a sale-type price list. Keep both ids.

## 2. First full load

```json
POST /product/get-paging

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

Page until `page * limit >= data.total`. When **both** `organization_id` and `price_id` are sent, each
row's `prices` is filled: `amount`, `currency`, `min_price`, `max_price`. Without either, `prices` comes
back empty.

The main row fields: `name`, `sku`, `barcode`/`barcodes`, `measure`, `category`, `image`,
`organizations[]` (a stock summary per organization) and `custom_fields`.

**Variants.** Each variant of a variant product is its own row (`is_variant: true`, `parent_id`).
Parent records (`is_parent`) are left out of the list. For plain products without variants only, send
`"is_main": true`.

## 3. Incremental updates

Store the time of your last successful sync and send it next time:

```json
POST /product/get-paging

{ "page": 1, "limit": 200, "organization_id": "…", "price_id": "…", "updated_at": "2026-11-05T09:00:00Z" }
```

The response holds the products changed since then.

## 4. Deletes

Deleted products drop out of `get-paging`:

```http
GET /product/get-deleted?deleted_at=2026-11-05T09:00:00Z
```

The response is a list of ids of products deleted since then. Remove them from your storefront.

## 5. Stock per warehouse

```json
POST /product-warehouse/get-paging

{ "page": 1, "limit": 200, "organization_id": "…", "updated_at": "2026-11-05T09:00:00Z" }
```

Each row is a product × warehouse: `amount`, `booked`, `in_transit`, `in_trash`.
**`amount` is the quantity available to sell**: reserved goods and goods in transit are not in it. If
your storefront sells from several warehouses, add up `amount`. For specific products, send
`product_ids` (up to 500). There is no warehouse filter — pick the warehouses on your side.

Use `product-warehouse`, not `product-stock`: `product-stock` holds batch-level rows
([glossary](https://docs.bito.uz/en/guide/glossary.md#confusions)).

## 6. Webhooks and the full reconcile

Subscribe to the `products.*` and `productPrices.*` webhooks and re-read the product when one arrives.
But bulk operations emit no webhooks and delivery is not guaranteed ([webhooks](https://docs.bito.uz/en/guide/webhooks.md)), so:

| Mode | When | What |
|---|---|---|
| Incremental | Every 5–60 minutes | Steps 3–5 with `updated_at` |
| Full | Once a day | Steps 2 and 5 without a filter, compared with your storefront |

## Methods

| Step | Method |
|---|---|
| Organization | [`GET /organization/get-all`](https://docs.bito.uz/en/api/organization.md) |
| Price lists | [`GET /price/get-all`](https://docs.bito.uz/en/api/price.md) |
| Products and prices | [`POST /product/get-paging`](https://docs.bito.uz/en/api/product.md#post-product-get-paging) |
| Deletes | [`GET /product/get-deleted`](https://docs.bito.uz/en/api/product.md#get-product-get-deleted) |
| Stock | [`POST /product-warehouse/get-paging`](https://docs.bito.uz/en/api/product-warehouse.md#post-product-warehouse-get-paging) |
| Prices only | [`POST /price/items/get-paging`](https://docs.bito.uz/en/api/price.md#post-price-items-get-paging) — no currency; it is on the price list |
