# Warehouse operations

The warehouse API lets a warehouse business (a 3PL or a merchant running its own warehouse) and its goods owners work with the warehouse system from their own software: read stock and locations, announce inbound goods, send outbound orders, plan the floor work and read the bills. The same calls exist on REST, on GraphQL and as MCP tools for AI agents. Staff calls run as the warehouse business or one of its employees; goods-owner calls run as the goods owner's customer account and see only its own goods.

## 1. What you can build

The examples in this playbook follow one scenario. **Maple Fulfilment** runs the **Toronto Hub** (warehouse `7`). **Northwind Outdoor**, one of its goods owners, keeps winter gear there and sells it online.

- **Stock sync.** Northwind's store reads its stock per SKU every few minutes and offers only what is on hand.
- **Inbound announcements.** Northwind's ERP announces each supplier delivery as an inbound order before the truck arrives, so the dock knows what to expect.
- **Order fulfilment.** Each web order becomes an outbound request; the warehouse picks, packs and ships it, and the store reads the tracking number back.
- **Floor planning.** Maple's own planning tool groups ready orders into pick waves, creates task orders and plans cycle counts. The work itself is done by scanning on the handhelds.
- **AI agents.** An operations agent answers questions such as "what is late at the dock today" and prepares waves for a supervisor to approve.

## 2. What this playbook covers

The flow is: get a token → list warehouses and locations → read stock → announce an inbound order → follow receiving → quote and create an outbound request → follow shipping → plan waves, task orders and counts → read billing → connect an AI agent.

Receiving, putaway, picking, counting and moving stock are done by scanning on the warehouse handhelds. The API creates and plans the work and reads the results; it never moves stock by itself.

## 3. Before you start

- **Warehouse system.** The business has the warehouse system switched on, and the goods owner (if you call as one) is switched on for it.
- **Accounts.** Staff calls use a business or employee account with API access; an employee sees only the warehouses and actions its staff roles allow. Goods-owner calls use the goods owner's customer account with API access.
- **Test data.** A warehouse `id` (step 5), at least one SKU of the goods owner, and a shipping method available from the warehouse for outbound requests.
- **Placeholders.** Replace `YOUR_HOST` with your platform host and `ACCESS_TOKEN` with the token from step 4.

## 4. Get a token

**REST:** `POST /api/v1/user/login` — [REST handbook](/api/documentation#/paths/v1-user-login/post)

```bash
curl -X POST https://YOUR_HOST/api/v1/user/login \
  -H "Content-Type: application/json" \
  -d '{"email":"ops@maple-fulfilment.example","password":"your_password"}'
```

Send the `access_token` of the answer on every later call as `Authorization: Bearer ACCESS_TOKEN`. Keep it on your server.

## 5. List warehouses and locations

**REST:** `GET /api/v1/wms-core/warehouses` — [REST handbook](/api/documentation#/paths/v1-wms-core-warehouses/get)

```bash
curl https://YOUR_HOST/api/v1/wms-core/warehouses \
  -H "Authorization: Bearer ACCESS_TOKEN"
```

Staff see the warehouses they work in; a goods owner sees the warehouses that store its goods. Locations of one warehouse:

**REST:** `GET /api/v1/wms-core/locations` — [REST handbook](/api/documentation#/paths/v1-wms-core-locations/get)

```bash
curl "https://YOUR_HOST/api/v1/wms-core/locations?warehouse_id=7&search=A-01&per_page=50" \
  -H "Authorization: Bearer ACCESS_TOKEN"
```

## 6. Read stock

**REST:** `GET /api/v1/wms-core/inventory-query` — [REST handbook](/api/documentation#/paths/v1-wms-core-inventory-query/get) · **GraphQL:** [wmsCoreInventoryQuery](/api/graphql/documentation#/warehouse/wmsCoreInventoryQuery)

```bash
curl "https://YOUR_HOST/api/v1/wms-core/inventory-query?warehouse_id=7&group=sku&in_stock=1&per_page=100" \
  -H "Authorization: Bearer ACCESS_TOKEN"
```

`group` is `sku`, `location`, `lot` or `owner`. Each row has the quantity on hand, reserved, frozen and available. A goods owner can also call `GET /api/v1/wms-core/my-stock` ([REST handbook](/api/documentation#/paths/v1-wms-core-my-stock/get)) for its own stock per SKU.

## 7. Announce an inbound order

**REST:** `POST /api/v1/wms-core/inbound-orders` — [REST handbook](/api/documentation#/paths/v1-wms-core-inbound-orders/post) · **GraphQL:** [wmsCoreInboundOrderSave](/api/graphql/documentation#/warehouse/wmsCoreInboundOrderSave)

```bash
curl -X POST https://YOUR_HOST/api/v1/wms-core/inbound-orders \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: asn-NW-20261123-01" \
  -d '{"warehouse_id":7,"external_ref":"PO-88123","expected_at":"2026-11-25","release":true,"lines":[{"sku":"JACKET-INS-M","quantity":120},{"sku":"JACKET-INS-L","quantity":80}]}'
```

`release: true` sends the order to the warehouse at once; without it the order stays a draft you can still change. Send the same `Idempotency-Key` when you retry, so a timeout never creates the order twice.

## 8. Follow receiving

**REST:** `GET /api/v1/wms-core/inbound-orders/{id}` — [REST handbook](/api/documentation#/paths/v1-wms-core-inbound-orders-id/get)

```bash
curl https://YOUR_HOST/api/v1/wms-core/inbound-orders/318 \
  -H "Authorization: Bearer ACCESS_TOKEN"
```

The answer has each line's expected and received quantity, the differences the dock recorded and the photos taken on arrival. A photo is read in base64 with GraphQL:

```graphql
query { wmsCorePhoto(kind: "inbound_order", id: 318, photo_id: "9b2f6a52-4f0e-4c1e-9d7a-1f3c2b8e6d10") }
```

[wmsCorePhoto](/api/graphql/documentation#/warehouse/wmsCorePhoto) answers `filename`, `content_type`, `size` and `content` (base64).

## 9. Quote and create an outbound request

**REST:** `POST /api/v1/wms-core/outbound-requests/quote` — [REST handbook](/api/documentation#/paths/v1-wms-core-outbound-requests-quote/post)

```bash
curl -X POST https://YOUR_HOST/api/v1/wms-core/outbound-requests/quote \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"warehouse_id":7,"recipient":{"name":"Ana Silva","address_1":"200 Elgin St","city":"Ottawa","province":"ON","postcode":"K2P 1L5","country":"CA"},"lines":[{"sku":"JACKET-INS-M","quantity":1}]}'
```

**REST:** `POST /api/v1/wms-core/outbound-requests` — [REST handbook](/api/documentation#/paths/v1-wms-core-outbound-requests/post)

```bash
curl -X POST https://YOUR_HOST/api/v1/wms-core/outbound-requests \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: web-order-100245" \
  -d '{"warehouse_id":7,"external_ref":"WEB-100245","recipient":{"name":"Ana Silva","phone":"+16135550100","address_1":"200 Elgin St","city":"Ottawa","province":"ON","postcode":"K2P 1L5","country":"CA"},"lines":[{"sku":"JACKET-INS-M","quantity":1}]}'
```

The warehouse reserves the stock, picks, packs and ships. A request that has not shipped can be cancelled with `POST /api/v1/wms-core/outbound-requests/{id}/cancel` ([REST handbook](/api/documentation#/paths/v1-wms-core-outbound-requests-id--cancel/post)).

## 10. Follow shipping

**REST:** `GET /api/v1/wms-core/outbound-requests/{id}` — [REST handbook](/api/documentation#/paths/v1-wms-core-outbound-requests-id/get)

```bash
curl https://YOUR_HOST/api/v1/wms-core/outbound-requests/903 \
  -H "Authorization: Bearer ACCESS_TOKEN"
```

Staff read the shipping state of the outbound order behind it with `GET /api/v1/wms-core/outbound-orders/{id}/delivery` ([REST handbook](/api/documentation#/paths/v1-wms-core-outbound-orders-id--delivery/get)): carrier, tracking numbers, shipped and handed over. The shipping label is read in base64 with [wmsCoreOutboundRequestLabel](/api/graphql/documentation#/warehouse/wmsCoreOutboundRequestLabel).

## 11. Plan the floor

Orders ready to be picked, then a pick wave from them:

**REST:** `GET /api/v1/picking/candidates` — [REST handbook](/api/documentation#/paths/v1-picking-candidates/get)

```bash
curl "https://YOUR_HOST/api/v1/picking/candidates?warehouse_id=7" \
  -H "Authorization: Bearer ACCESS_TOKEN"
```

**REST:** `POST /api/v1/picking/waves` — [REST handbook](/api/documentation#/paths/v1-picking-waves/post)

```bash
curl -X POST https://YOUR_HOST/api/v1/picking/waves \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"warehouse_id":7,"profile_id":3,"outbound_order_ids":[5521,5522,5530]}'
```

Releasing the wave makes its batches pickable on the handhelds. Task orders (`GET /api/v1/wms-core/task-orders`, [REST handbook](/api/documentation#/paths/v1-wms-core-task-orders/get)) and cycle counts (`POST /api/v1/wms-core/cycle-counts`, [REST handbook](/api/documentation#/paths/v1-wms-core-cycle-counts/post)) are planned the same way; counting happens on the handheld and differences are approved on the web.

## 12. Read billing

**REST:** `GET /api/v1/wms-core/billing-statements` — [REST handbook](/api/documentation#/paths/v1-wms-core-billing-statements/get) · **GraphQL:** [wmsCoreBillingStatementFile](/api/graphql/documentation#/warehouse/wmsCoreBillingStatementFile)

```bash
curl "https://YOUR_HOST/api/v1/wms-core/billing-statements?from=2026-11-01&to=2026-11-30" \
  -H "Authorization: Bearer ACCESS_TOKEN"
```

Billing staff see every statement of the business; a goods owner sees its own. The statement as a PDF or CSV comes in base64 from `wmsCoreBillingStatementFile`.

## 13. Connect an AI agent (MCP)

The warehouse MCP server lists only the warehouse tools:

```
https://YOUR_HOST/api/mcp/topics/warehouse
```

Each `wms_*` tool calls one of the REST endpoints above as the token's user, so the agent sees and changes exactly what that user may on the web. Choose the token's profile with the `X-MCP-Profile` header:

| Profile | What the agent can do |
|---------|------------------------|
| `wms-readonly` | Read stock, orders, tasks, reports (no money) |
| `wms-ops` | Also create, release and cancel inbound orders, outbound requests, waves, task orders, counts and holds (no money) |
| `wms-owner` | A goods owner's agent: its stock, orders and bills |

- Send `X-MCP-Dry-Run: 1` to preview a write without doing it.
- Cancels, freezes, lot holds and recalls need `confirm=true`, or go to human review with `X-MCP-Require-Approval: 1`.
- Every write takes `idempotency_key`; a retry with the same key never acts twice.
- No tool receives, picks, counts or moves stock, and no tool changes bills.

## 14. Handling errors

| Answer | Meaning | What to do |
|--------|---------|------------|
| `401` | No or expired token | Get a new token (step 4) |
| `403` `warehouse_denied` | The user does not work in this warehouse | Use a warehouse from step 5 |
| `403` `permission_denied` | The user's staff roles do not allow the action | Ask an administrator to grant the role |
| `404` `…_not_found` | The record does not exist or is not visible to this user | Check the id and the account |
| `422` `invalid` | A field is missing or wrong; `errors` names it | Fix the field and send again |

## Test checklist

- [ ] The token lists the expected warehouses (step 5).
- [ ] Stock of a test SKU matches the web page (step 6).
- [ ] A retried inbound order with the same `Idempotency-Key` is created once (step 7).
- [ ] An outbound request ships and its tracking number is read back (steps 9–10).
- [ ] A goods-owner token sees only its own goods.
- [ ] An MCP agent with `wms-readonly` lists no write tools.
