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:
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
- 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.
- Production base URL:
https://app.warehance.com/api/v1/fulfillment-api/api. Use the base URL your customer gives you. - Every path is
{base_url}/stores/{store_id}/…..jsonon the path is optional. - Authenticate every request with HTTP Basic: username and API key.
- Send and expect JSON (
Content-Type: application/json). A401has an empty body. - There are no webhooks. Your platform pushes orders and polls for shipments.
Creating orders
- Create with
POST /orders/new.json, body{"order": {...}}. Required:order_number,ship_name,address1,city,country. Sendstateandpostal_codewherever the country uses them. - Optional order fields:
address2,phone,email,order_date(RFC 3339),requested_shipping_service,currency(ISO 4217, defaultUSD),subtotal,shipping_amount,tax_amount,discount_amount,total_amount,invoice_number,invoice_date. - Lines:
items: [{"sku", "quantity" (≥ 1), "price" (unit price, optional)}]. - Only send orders that are final (paid, approved). The warehouse may start within minutes.
- A new order returns
201. Storeorder.idand everyorder.items[].idagainst your order and lines. - Create is idempotent on
order_number: an existing number returns200with the existing order, unchanged. Retry timeouts with the same request. - Create validation errors return
404{"errors": [...]}. So does an order rejected by the store's import filter. Don't retry those unchanged. - Unknown SKUs are accepted.
sku_idisnulluntil your customer maps the SKU. order_numberis text:10001and"10001"are the same order. It can never be reused in the store, even after a cancel.
Changing orders
- Edits and cancels work only while
order.status == "unverified". Otherwise they return403{"errors": ["Order can no longer be modified"]}: don't retry, tell your customer. - Update:
PUT /orders/{id}/update.json. Only sent fields change;""clears a text field.order_numberandcurrencycan't change. - Cancel:
DELETE /orders/{id}.json. Cancelling an already-cancelled order returns403. - Lines: add
POST /orders/{id}/items/add.json, changePUT /orders/{id}/items/{item_id}.json(quantity and price only), deleteDELETE /orders/{id}/items/{item_id}.json. A SKU can't change on a line: delete and add. - Any
/orders/{id}endpoint accepts?order_number=…, which takes priority over{id}(use/orders/0.json?order_number=…). - Send changes to one order one at a time. A
409means another change is in progress: retry after 1–2 seconds.
Status
fulfillment_status:unfulfilled→in_progress→partially_fulfilled→fulfilled, orcancelled. States can be skipped (unfulfilledstraight tofulfilled).- Use
fulfillment_statusfor progress and closing orders. Usestatus == "unverified"only to decide whether an edit is allowed. - Holds (address, unmapped SKU, unmapped shipping service, stock, manual) keep an order
unfulfilledwith no error.order.not_ready_to_ship_typeshas a boolean per reason (address_hold,has_unallocated_products,has_unmapped_products,shipping_method_not_mapped,fraud_holdand so on); a change to it bumps the order'supdated_at.has_unallocated_productscan betruefor a few seconds after create. - An order can be
fulfilledwith an emptyshipmentslist (shipped without a label). Close it without tracking. - The warehouse can cancel an order before it ships.
Shipments and tracking
- Poll
GET /shipments.json?updated_at_start={since}&limit=500every 15–60 minutes per store. since= start time of the last fully successful poll minus 5 minutes. Save the new start time only after every page succeeded.- Page with cursors: while
has_next_pageistrue, request again withcursor={next_cursor}and the same filters andlimit. Cursors are opaque. - Skip shipment
ids you have already processed. - A shipment can ship several orders (merges). Write its tracking to every entry in
shipment.orders. - A shipment can have several parcels. Every
shipment_parcels[].tracking_numberis a tracking number; the shipment-leveltracking_numberis only the first. - An order can have several shipments (splits, partial and replacement shipments).
- 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. GET /shipments/{id}.jsonreturns200{"shipment": null}for an unknown or voided shipment.carrier_codeandservice_codeare Warehance's lowercase codes (usps,ups_groundand so on).
Errors and retries
- Error bodies come in three shapes:
{"errors": [...]},{"error": "..."}(unknown order;500withrequest_id) and{"errors": "..."}(badupdated_at). Handle all three, and the empty401. - Retry timeouts,
409and5xxwith exponential backoff. Never retry400,401,403or404unchanged. - On
401, pause that store's sync and alert your customer. - Log
request_idfrom500s.
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
fulfilledwith no shipments. - An order cancelled by the warehouse.
- Key rotation (
401with empty body). - A poll that fails halfway through, then succeeds.
Updated 1 day ago
Did this page help you?
