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

WhatWhere
Index of every guide and reference pagehttps://developer.warehance.com/llms.txt
Any page as MarkdownAdd .md to its URL, for example https://developer.warehance.com/docs/order-intake-ai-agents.md
Endpoint reference with the full OpenAPI definitionhttps://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

  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

  1. 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.
  2. 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.
  3. Lines: items: [{"sku", "quantity" (≥ 1), "price" (unit price, optional)}].
  4. Only send orders that are final (paid, approved). The warehouse may start within minutes.
  5. A new order returns 201. Store order.id and every order.items[].id against your order and lines.
  6. Create is idempotent on order_number: an existing number returns 200 with the existing order, unchanged. Retry timeouts with the same request.
  7. Create validation errors return 404 {"errors": [...]}. So does an order rejected by the store's import filter. Don't retry those unchanged.
  8. Unknown SKUs are accepted. sku_id is null until your customer maps the SKU.
  9. 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

  1. 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.
  2. Update: PUT /orders/{id}/update.json. Only sent fields change; "" clears a text field. order_number and currency can't change.
  3. Cancel: DELETE /orders/{id}.json. Cancelling an already-cancelled order returns 403.
  4. 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.
  5. Any /orders/{id} endpoint accepts ?order_number=…, which takes priority over {id} (use /orders/0.json?order_number=…).
  6. Send changes to one order one at a time. A 409 means another change is in progress: retry after 1–2 seconds.

Status

  1. fulfillment_status: unfulfilled → in_progress → partially_fulfilled → fulfilled, or cancelled. States can be skipped (unfulfilled straight to fulfilled).
  2. Use fulfillment_status for progress and closing orders. Use status == "unverified" only to decide whether an edit is allowed.
  3. 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.
  4. An order can be fulfilled with an empty shipments list (shipped without a label). Close it without tracking.
  5. The warehouse can cancel an order before it ships.

Shipments and tracking

  1. Poll GET /shipments.json?updated_at_start={since}&limit=500 every 15–60 minutes per store.
  2. since = start time of the last fully successful poll minus 5 minutes. Save the new start time only after every page succeeded.
  3. Page with cursors: while has_next_page is true, request again with cursor={next_cursor} and the same filters and limit. Cursors are opaque.
  4. Skip shipment ids you have already processed.
  5. A shipment can ship several orders (merges). Write its tracking to every entry in shipment.orders.
  6. A shipment can have several parcels. Every shipment_parcels[].tracking_number is a tracking number; the shipment-level tracking_number is only the first.
  7. An order can have several shipments (splits, partial and replacement shipments).
  8. 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.
  9. GET /shipments/{id}.json returns 200 {"shipment": null} for an unknown or voided shipment.
  10. carrier_code and service_code are Warehance's lowercase codes (usps, ups_ground and so on).

Errors and retries

  1. 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.
  2. Retry timeouts, 409 and 5xx with exponential backoff. Never retry 400, 401, 403 or 404 unchanged.
  3. On 401, pause that store's sync and alert your customer.
  4. Log request_id from 500s.

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.

Did this page help you?