---
title: "allocate sales order"
method: POST
path: "/api/v1/sales/orders/{order_id}/allocate"
tags: ["orders"]
---

# allocate sales order

`POST /api/v1/sales/orders/{order_id}/allocate`

## Request

- Base URL: `https://api.app.tightly.io`
- URL: `https://api.app.tightly.io/api/v1/sales/orders/{order_id}/allocate`
- Auth: HTTP bearer

Holds stock for one open order. Turning reservations on does not reach back over the orders that were open before it, so this is the act that allocates one of them. An order already allocated, sent, fulfilled or cancelled is refused with the state it is in; an organisation that does not hold stock for orders is refused with where to turn it on; and an order whose channel has no warehouse linked is refused with what to link.

Scope: `orders:write`, which includes `orders:read`.

## Path parameters

- `order_id` string, required

## Headers

- `Tightly-Version` string
- `Idempotency-Key` string

## Response `200`

The order, allocated.

## Other responses

- `401`: No usable key: malformed, unknown, revoked, expired or stopped.
- `403`: The key does not hold Orders (`scope_missing`), or is issued to one account and the record is not that account's (`account_mismatch`).
- `404`: No order with that id is on file.
- `409`: `order_not_open`, `order_reservations_off`, `no_serving_location`.
- `429`: The key has spent its allowance for this minute. 600 reads and 120 writes a minute, counted per key, refused calls included. `Retry-After` says how long to wait.
- `503`: The database is briefly out of reach, which is what a failover or a full connection pool looks like from outside. Wait the seconds `Retry-After` names and send the request again. A read is safe to repeat. A write is not, because the connection was lost in the middle of it, so read the object back before sending it a second time. Branch on the status rather than on `code`, which is `POSTGRES_UNAVAILABLE` from one of the two seams that raise this and `SERVICE_UNAVAILABLE` from the other.

---

[API](https://skmtc.dev/tightly/apis/tightly-api.md) · [All operations](https://skmtc.dev/tightly/apis/tightly-api/llms.txt) · [OpenAPI document](https://skmtc.dev/tightly/apis/tightly-api/revisions/199f7eb35afb?raw)
