---
updatedAt: 2026-11-24T14:52:55.000Z
agentTools:
  projectIndex: https://developer.warehance.com/llms.txt
---

# Order Intake API: Building With an AI Agent

The whole Order Intake API integration as one compact, rule-by-rule spec, plus machine-readable sources and a prompt to hand a coding agent.

If you're building this integration with a coding agent (Claude Code, Cursor, Copilot and so on), point it at this page. It's the complete integration in one place, written as rules. The other guides explain the same rules in more detail.

## Machine-readable sources

| What                                                | Where                                                                                                                               |
| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Index of every guide and reference page             | <https://developer.warehance.com/llms.txt>                                                                                          |
| Any page as Markdown                                | Add `.md` to its URL, for example <https://developer.warehance.com/docs/order-intake-ai-agents.md>                                  |
| Endpoint reference with the full OpenAPI definition | <https://developer.warehance.com/reference/createorder.md> (every Order Intake reference page embeds the same OpenAPI 3.0 document) |

## Prompt for your agent

Copy this into your agent, filling in where your platform's code lives:

```text
Build an integration between our order platform and the Warehance Order Intake API.

Read these first, completely:
- https://developer.warehance.com/docs/order-intake-ai-agents.md (the rules)
- https://developer.warehance.com/reference/createorder.md (the OpenAPI definition)
Follow every rule on the first page exactly. Where our code disagrees with a rule, follow the rule
and tell me.

Scope:
1. Per-store credentials (base URL, username, API key, store ID), editable without a deploy.
2. Push each final order with POST /orders/new.json, storing the returned order id and item ids.
3. Edits and cancels while status is "unverified".
4. A scheduled tracking poll of GET /shipments.json as specified, writing tracking to our orders.
5. Error handling and retries as specified, with alerts on 401 and repeated 5xx.
6. Tests for every edge case in the "Edge cases" list.
```

## The rules

### Connection

1. One connection per store. Each has four values: base URL, username, API key, store ID. Store the key as a secret; your customer can rotate it at any time.
2. Production base URL: `https://app.warehance.com/api/v1/fulfillment-api/api`. Use the base URL your customer gives you.
3. Every path is `{base_url}/stores/{store_id}/…`. `.json` on the path is optional.
4. Authenticate every request with HTTP Basic: username and API key.
5. Send and expect JSON (`Content-Type: application/json`). A `401` has an empty body.
6. There are no webhooks. Your platform pushes orders and polls for shipments.

### Creating orders

7. Create with `POST /orders/new.json`, body `{"order": {...}}`. Required: `order_number`, `ship_name`, `address1`, `city`, `country`. Send `state` and `postal_code` wherever the country uses them.
8. Optional order fields: `address2`, `phone`, `email`, `order_date` (RFC 3339), `requested_shipping_service`, `currency` (ISO 4217, default `USD`), `subtotal`, `shipping_amount`, `tax_amount`, `discount_amount`, `total_amount`, `invoice_number`, `invoice_date`.
9. Lines: `items: [{"sku", "quantity" (≥ 1), "price" (unit price, optional)}]`.
10. Only send orders that are final (paid, approved). The warehouse may start within minutes.
11. A new order returns `201`. Store `order.id` and every `order.items[].id` against your order and lines.
12. Create is idempotent on `order_number`: an existing number returns `200` with the existing order, unchanged. Retry timeouts with the same request.
13. Create validation errors return `404` `{"errors": [...]}`. So does an order rejected by the store's import filter. Don't retry those unchanged.
14. Unknown SKUs are accepted. `sku_id` is `null` until your customer maps the SKU.
15. `order_number` is text: `10001` and `"10001"` are the same order. It can never be reused in the store, even after a cancel.

### Changing orders

16. Edits and cancels work only while `order.status == "unverified"`. Otherwise they return `403` `{"errors": ["Order can no longer be modified"]}`: don't retry, tell your customer.
17. Update: `PUT /orders/{id}/update.json`. Only sent fields change; `""` clears a text field. `order_number` and `currency` can't change.
18. Cancel: `DELETE /orders/{id}.json`. Cancelling an already-cancelled order returns `403`.
19. Lines: add `POST /orders/{id}/items/add.json`, change `PUT /orders/{id}/items/{item_id}.json` (quantity and price only), delete `DELETE /orders/{id}/items/{item_id}.json`. A SKU can't change on a line: delete and add.
20. Any `/orders/{id}` endpoint accepts `?order_number=…`, which takes priority over `{id}` (use `/orders/0.json?order_number=…`).
21. Send changes to one order one at a time. A `409` means another change is in progress: retry after 1–2 seconds.

### Status

22. `fulfillment_status`: `unfulfilled` → `in_progress` → `partially_fulfilled` → `fulfilled`, or `cancelled`. States can be skipped (`unfulfilled` straight to `fulfilled`).
23. Use `fulfillment_status` for progress and closing orders. Use `status == "unverified"` only to decide whether an edit is allowed.
24. Holds (address, unmapped SKU, unmapped shipping service, stock, manual) keep an order `unfulfilled` with no error. `order.not_ready_to_ship_types` has a boolean per reason (`address_hold`, `has_unallocated_products`, `has_unmapped_products`, `shipping_method_not_mapped`, `fraud_hold` and so on); a change to it bumps the order's `updated_at`. `has_unallocated_products` can be `true` for a few seconds after create.
25. An order can be `fulfilled` with an empty `shipments` list (shipped without a label). Close it without tracking.
26. The warehouse can cancel an order before it ships.

### Shipments and tracking

27. Poll `GET /shipments.json?updated_at_start={since}&limit=500` every 15–60 minutes per store.
28. `since` = start time of the last fully successful poll minus 5 minutes. Save the new start time only after every page succeeded.
29. Page with cursors: while `has_next_page` is `true`, request again with `cursor={next_cursor}` and the same filters and `limit`. Cursors are opaque.
30. Skip shipment `id`s you have already processed.
31. A shipment can ship several orders (merges). Write its tracking to every entry in `shipment.orders`.
32. A shipment can have several parcels. Every `shipment_parcels[].tracking_number` is a tracking number; the shipment-level `tracking_number` is only the first.
33. An order can have several shipments (splits, partial and replacement shipments).
34. A voided label's shipment disappears; its replacement is a new shipment with a new `id`. On a new shipment for an order that already has tracking, re-read the order's shipments and replace what you stored.
35. `GET /shipments/{id}.json` returns `200` `{"shipment": null}` for an unknown or voided shipment.
36. `carrier_code` and `service_code` are Warehance's lowercase codes (`usps`, `ups_ground` and so on).

### Errors and retries

37. Error bodies come in three shapes: `{"errors": [...]}`, `{"error": "..."}` (unknown order; `500` with `request_id`) and `{"errors": "..."}` (bad `updated_at`). Handle all three, and the empty `401`.
38. Retry timeouts, `409` and `5xx` with exponential backoff. Never retry `400`, `401`, `403` or `404` unchanged.
39. On `401`, pause that store's sync and alert your customer.
40. Log `request_id` from `500`s.

## Edge cases to test

* Re-sending an existing order number (also after it's cancelled).
* Unknown SKU (`sku_id: null`).
* A changed address coming back standardized (`1600 SW 4TH AVE`).
* Edit after the warehouse started (`403`).
* Two boxes in one shipment; two shipments on one order; one shipment for two orders.
* A voided label followed by a replacement shipment.
* An order `fulfilled` with no shipments.
* An order cancelled by the warehouse.
* Key rotation (`401` with empty body).
* A poll that fails halfway through, then succeeds.