Inventory
User inventory, atomic virtual-currency purchases, consumable consumption.
All mutations run inside a transaction with SELECT ... FOR UPDATE on user_balances so concurrent purchases cannot double-spend.
Source: apps/api/src/routes/client/inventory.ts.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /client/inventory | User's inventory with catalog-item info; quantity > 0. |
| POST | /client/inventory/purchase | Purchase with virtual currency (atomic, idempotent per concurrency). |
| POST | /client/inventory/:itemId/consume | Decrement quantity on a consumable. |
GET /client/inventory
Response 200
Errors
500 FETCH_FAILED.
Try it:
GET
client auth/client/inventorycurl -X GET 'https://api.amba.dev/client/inventory'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl:
POST /client/inventory/purchase
Atomic: price resolution → balance check → deduction → ledger insert → inventory grant. Bundles are expanded — each bundle content item is granted separately.
Request (PurchaseItemInput)
| Field | Type | Required | Description |
|---|---|---|---|
catalog_item_id | uuid | yes | Item to buy. |
currency_code | string | yes | Currency to spend. |
store_id | uuid | no | If present, the store's override_prices and max_purchases_per_user are applied. |
Response 200
Errors
400 NO_PRICE— no price set for the (item, currency) pair.400 MAX_PURCHASES_REACHED— store listing's per-user cap reached.400 INSUFFICIENT_BALANCE— user's currency balance is less than the price.404 NOT_FOUND— item not listed in the suppliedstore_id.503 TENANT_UNAVAILABLE— tenant DB unavailable.500 PURCHASE_FAILED.
Try it:
POST
client auth/client/inventory/purchasecurl -X POST 'https://api.amba.dev/client/inventory/purchase'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl:
POST /client/inventory/:itemId/consume
Decrement quantity on a consumable. itemId is the catalog item id.
Request
Defaults to quantity = 1 if body is empty or missing the field.
Response 200
Errors
400 NOT_CONSUMABLE— the catalog item is notitem_type = 'consumable'.400 INSUFFICIENT_QUANTITY— user doesn't own enough to consume.500 CONSUME_FAILED.
Try it:
POST
client auth/client/inventory/%7B%7BitemId%7D%7D/consumecurl -X POST 'https://api.amba.dev/client/inventory/%7B%7BitemId%7D%7D/consume' \
-H 'Content-Type: application/json' \
-d '{
"quantity": 1
}'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl: