Sifr Wahid Developers

Architecture (HLD)

Product and stock sync

The flow from your system to the store: the SKU links the two, products are upserted, and stock moves by delta.

Your ERP Public API Your receiver 1. First load GET /products?per_page=100 200: data + meta.next_cursor repeat with cursor until next_cursor is null; keep id against SKU 2. Upsert each item by SKU GET /products/sku/{sku} 404: a new item / 200: found POST /products (new) PATCH /products/sku/{sku} (found) 201 / 200: links listed in images_pending never a quantity on a product: any quantity key is answered 422 3. Pictures, in the background product.updated sent when the copied pictures join images 4. Stock by delta POST /inventory/adjustments Idempotency-Key: odoo-move-48213 increment or decrement, up to 100 lines 200: quantity_after per item 5. When the API says wait 429 rate_limited + Retry-After after Retry-After seconds: the same call, with the same Idempotency-Key 409 insufficient_stock: a decrement below zero; nothing in the batch applies
Solid arrows are your calls, dashed arrows the answers. The SKU links your items to the store's variants, pictures are copied in the background, and every stock movement is one idempotent call.

The steps

  1. First load

    Read GET /products?per_page=100 page by page, passing meta.next_cursor as cursor until it is null, and keep each product and variant id against its SKU.

  2. Upsert each item

    GET /products/sku/{sku}. A 404 means a new item: POST /products with the name and the variants (each with sku and price in halalas), weight_grams when it ships, and status: active to show it. When found: PATCH /products/sku/{sku} with only the fields that changed (keys you do not send stay).

  3. Pictures

    Send public links in images. They are copied in the background: the answer lists the link in images_pending with status pending, then it joins images and product.updated is sent. A store has at most 50 links waiting at once (beyond that, 429 images_queue_full with Retry-After).

  4. Stock by delta

    Each movement in your system: POST /inventory/adjustments with increment or decrement, up to 100 lines a call, applied all or nothing, with an Idempotency-Key from the movement number. mode: set is for a stock count only, because it erases what the store sold between your read and your write.

  5. When the API says wait

    On a 429, wait the seconds in Retry-After, then send the same call again with the same Idempotency-Key. A decrement below zero is 409 insufficient_stock with available, and nothing is applied.

The step-by-step guide, with every rule for pictures and variants: Sync products and stock. The operations: Products and Inventory.