Omono API
Menu Guides

Raise a purchase order from another system

View as Markdown

Use this recipe when another system decides what to buy, for example a planning or reorder tool, and you want each order in Omono as a purchase order. You create the order, say when you expect the goods, and issue it. Your staff receive the goods in Omono when they arrive.

Every request in this recipe sends your API key in an Authorization: Bearer <key> header, and every POST and PATCH also sends an Idempotency-Key. Paths are relative to https://<host>/api/v1, and the examples show the full path.

Note: The purchase order write operations are in beta. Learn more about beta operations.

You need the scopes purchasing:read, purchasing:write, companies:read, stock:read and reference:read.

Before your first order#

Look up these IDs and cache them:

  • The supplier, a company with isSupplier: true, from GET /companies?isSupplier=true&accountNo=<account number>, and one of its contacts from GET /companies/{id}/contacts.
  • The delivery address, one of your own addresses from GET /organisation-addresses.
  • The buyer, a user from GET /users whose assignable is true.
  • Each product, from GET /stock-items?partNo=<part number>. Only an item with canBuy: true can go on a purchase order.
  • The exchange rate. If the supplier's currencyId is your base currency, send 1. Otherwise, take the rate for its currency from GET /currency-rates.

For each order#

  1. Create the order with its line items.

    POST /api/v1/purchase-orders
    Idempotency-Key: reorder-2026-10-03-17
    Content-Type: application/json
    
    {
      "companyId": "…",
      "contactId": "…",
      "addressId": "…",
      "buyerId": "…",
      "refNo": "Reorder 17",
      "exchangeRate": 1,
      "lineItems": [
        { "stockItemId": "…", "quantity": 500, "price": 1.85 }
      ]
    }
    

    The 201 response returns the order with the status draft, its ETag, and createdLineItems, which gives the ID of each new line item.

  2. Add the expected deliveries. As in Omono, a purchase order that isn't a call-off can be issued only when its deliveries cover all of its line items. Add one delivery for each date you expect goods:

    POST /api/v1/purchase-orders/{id}/deliveries
    Idempotency-Key: reorder-2026-10-03-17-delivery-1
    Content-Type: application/json
    
    {
      "deliveryDate": "2026-10-20",
      "lineItems": [
        { "purchaseOrderLineItemId": "…", "quantity": 250 }
      ]
    }
    

    A delivery starts as Not Received, so it doesn't change stock. The quantities on a line item's deliveries must add up to its quantity. The 201 response returns the order's new ETag. Skip this step for a call-off order (callOff: true).

  3. Issue the order. Call POST /api/v1/purchase-orders/{id}/issue with the latest ETag in If-Match and no body. The order moves to On Order, and each line item's quantity is added to its stock item's onOrder. Issuing doesn't email or print the order: send it to the supplier the way you do today.

  4. Keep the dates up to date. When the supplier confirms a new date, change it with PATCH /api/v1/purchase-orders/{id}/deliveries/{deliveryId}. You can change or delete a delivery until it's received. To delete one, send DELETE to the same path, with the order's ETag in If-Match, as Delete a record explains.

Errors to handle#

Status Code What to do
409 deliveries-incomplete On /issue, the deliveries don't cover all the line items. Each entry in errors names a line item and how much of it is on deliveries. Add a delivery for the rest, then retry with the new ETag.
409 delivery-received The delivery has been received in Omono, so it can't change through the API.
409 purchase-order-cancelled The order is cancelled.
409 quantity-exceeds-remaining On a delivery, a quantity is more than is left on its line item, and the message says how many are left. Read the order again.
409 stock-not-buyable A stock item has canBuy: false. Choose another item, or ask your staff to change it.
412 precondition-failed The order changed since you read it. Read it again and retry with the new ETag.
422 validation-failed, invalid-reference A value is wrong, and errors[].field names it.
429, 503 rate-limited, temporarily-unavailable Wait the number of seconds in Retry-After, then retry with the same Idempotency-Key. After a 503 on /issue, read the order again first and send its current ETag in If-Match: saves in Omono can give the order a new ETag in the meantime.