{"openapi":"3.0.0","x-errors":[{"code":"missing_api_key","status":401,"when":"No Authorization header, or not a bearer token.","retry":"No — send the key."},{"code":"invalid_api_key","status":401,"when":"The key is unknown, malformed, or has been revoked.","retry":"No — issue a new key."},{"code":"insufficient_scope","status":403,"when":"The key is valid but was not granted the scope this call needs.","retry":"No — create a key with the scope."},{"code":"not_found","status":404,"when":"No such resource for this key. Also returned for a resource that belongs to another account, or to the other mode — telling you it exists would itself be a leak.","retry":"No."},{"code":"invalid_request","status":400,"when":"The request could not be read — a body that is not valid JSON, a bad filter, a limit above 100.","retry":"No — fix the request. `field` names the offender when there is one."},{"code":"invalid_request","status":415,"when":"A body was sent without `Content-Type: application/json`.","retry":"No — send JSON with that header."},{"code":"invalid_request","status":422,"when":"The request parsed but the values cannot be accepted — a malformed postal code, a missing colonia.","retry":"No — fix the value in `field`."},{"code":"quote_expired","status":400,"when":"The `quote_id` is unknown or older than 30 minutes.","retry":"Request a new quote, then ship that."},{"code":"quote_mismatch","status":422,"when":"The quote was for another destination postal code, weight or box than the order ships. `field` names what differs.","retry":"Quote again with the order's real destination and package, then ship that quote."},{"code":"rate_not_applicable","status":422,"when":"A COD rate was used for a prepaid order, or the reverse.","retry":"No — pick a rate whose `cod` matches the order."},{"code":"order_cancelled","status":409,"when":"The order was cancelled and cannot ship.","retry":"No."},{"code":"order_not_shippable","status":409,"when":"The order is not in a state that can produce a label.","retry":"After resolving what `issues` lists on the order."},{"code":"order_not_shippable","status":422,"when":"Something concrete blocks the label: missing package dimensions, a stock shortfall.","retry":"After fixing the cause."},{"code":"insufficient_balance","status":402,"when":"The account balance does not cover this label. The message says how much to add.","retry":"After topping up the wallet in Wepaak."},{"code":"account_under_review","status":403,"when":"National shipments for this account are paused while Wepaak reviews it.","retry":"No — contact Wepaak support."},{"code":"account_not_verified","status":403,"when":"The account must be verified before shipping with this carrier.","retry":"After completing verification in the Wepaak dashboard."},{"code":"own_label_missing","status":422,"when":"The order ships on your own label (bought elsewhere) and no label PDF is matched to it yet. No label is bought for it.","retry":"After uploading and matching the label in Wepaak (Orders > My own labels)."},{"code":"own_label_not_shippable","status":422,"when":"The order is set to ship on your own label, but it is cash on delivery or not shipped from a Wepaak warehouse, which an own label cannot do.","retry":"After turning the own label off in Wepaak, or making the order prepaid."},{"code":"own_label","status":409,"when":"A label download or a cancel for a parcel that shipped on your own label. Wepaak did not buy that label: it is the PDF you uploaded, and the carrier is yours.","retry":"Never: use your own label, and cancel with your carrier."},{"code":"order_in_warehouse","status":409,"when":"A cancel for an order the warehouse is already picking or packing: its stock may be off the shelf and its label bought.","retry":"Never through the API. Contact Wepaak support."},{"code":"label_in_progress","status":409,"when":"A cancel for an order whose label is being created at that moment (a POST /v1/shipments for it has not answered yet).","retry":"Yes, a few seconds later. By then the order has shipped (cancel its shipment) or is cancellable again."},{"code":"cod_requires_wepaak","status":422,"when":"A cash on delivery order is set to a carrier other than Wepaak, the only one that collects cash.","retry":"Ship it with a Wepaak COD rate (quote_id + rate_id), or make the order prepaid."},{"code":"carrier_no_coverage","status":422,"when":"The order ships from a Wepaak warehouse with the Wepaak courier, and the courier does not deliver to (or from) one of the route's postal codes. Nothing is picked or bought.","retry":"Quote again (POST /v1/quotes) and ship with another carrier's quote_id + rate_id."},{"code":"rate_unavailable","status":422,"when":"The carrier chosen for the order has no rate for this parcel and route right now.","retry":"Quote again (POST /v1/quotes) and ship with quote_id + rate_id."},{"code":"carrier_required","status":422,"when":"No courier is selected for this order. Happens when no automation rule assigned one, which is the normal case for a brand-new account.","retry":"Send `quote_id` and `rate_id` from POST /v1/quotes, or set up an automation rule that assigns a courier."},{"code":"warehouse_required","status":409,"when":"The order is not assigned to a warehouse, so nothing knows where it ships from. COD orders are not auto-routed, so send `warehouse_id` on POST /v1/orders for those. Checked AFTER the courier: a COD order with neither a warehouse nor a quoted rate answers `422 carrier_required` first.","retry":"After assigning one."},{"code":"order_already_dispatched","status":409,"when":"POST /v1/orders/{id}/cancel on an order that has already shipped.","retry":"No — cancel its shipment with POST /v1/shipments/{id}/cancel."},{"code":"shipment_not_cancellable","status":409,"when":"The carrier already has the parcel (collected, in transit, delivered), or the carrier service cannot be cancelled once the label exists.","retry":"No."},{"code":"shipment_finished","status":409,"when":"Test mode: simulating a step after `delivered`, `returned` or `cancelled`.","retry":"No — ship a new test order."},{"code":"carrier_unavailable","status":502,"when":"A carrier did not answer as needed. **502:** it did not confirm a cancellation; nothing was changed and nothing was refunded. **503** (next row): it could not be reached, for a cancellation, a label, or a quote that came back empty because of it.","retry":"Yes — in a few minutes."},{"code":"carrier_unavailable","status":503,"when":"A carrier could not be reached: a cancellation, a label, or a quote that came back with no rates because a carrier did not answer (not a coverage answer).","retry":"Yes — in a minute or two."},{"code":"test_mode_only","status":403,"when":"POST /v1/shipments/{id}/simulate with a live key.","retry":"No — use a test key; a live shipment moves when its carrier moves it."},{"code":"label_not_available","status":404,"when":"The carrier has not produced the label yet (it can take a few seconds after the shipment is created).","retry":"Yes — in a minute."},{"code":"shipment_cancelled","status":409,"when":"Asking for the label of a cancelled shipment.","retry":"No — the label must not be used."},{"code":"invalid_grant","status":400,"when":"On POST /v1/connect/exchange: the code is unknown, expired, already used, or the PKCE verifier did not match.","retry":"No — start the connect flow again."},{"code":"shipment_not_payable","status":422,"when":"POST /v1/cod/payouts: a shipment is not `available`, is already in a payout, or is unknown to this key. `error.details.shipments` lists each one with its status now (`not_found` for an unknown id). Nothing is created.","retry":"No — leave those shipments out, or wait until they are `available`."},{"code":"payout_fully_withheld","status":422,"when":"POST /v1/cod/payouts: the charges your account owes Wepaak take all of what these shipments collected, so nothing would be paid. `error.details` has `collected` and `owed`.","retry":"After the charges are paid, or with more shipments."},{"code":"payout_zero_amount","status":422,"when":"POST /v1/cod/payouts: the shipments add up to $0.00.","retry":"No."},{"code":"payout_conflict","status":409,"when":"POST /v1/cod/payouts: a shipment was taken by another payout while this one was being made. Nothing is created.","retry":"Yes — after reading the shipments' status again."},{"code":"payout_not_cancellable","status":409,"when":"POST /v1/cod/payouts/{id}/cancel on a payout that is no longer `requested` (Wepaak is already paying it, or it is paid, failed or cancelled), or that was not requested through the API (`error.details.reason` is `not_requested_through_api`). `error.details.status` says which status it has.","retry":"No — contact Wepaak support."},{"code":"wallet_negative","status":422,"when":"POST /v1/cod/payouts while your account's wallet is below zero: that is money your account owes Wepaak, so no payout is made until it is paid back. `error.details.wallet_balance` has the balance. Nothing is created.","retry":"After topping the wallet up to zero or more."},{"code":"idempotency_mismatch","status":409,"when":"POST /v1/cod/payouts with a `request_id` already used for a payout to another recipient (a different `recipient.clabe` or `recipient.name`). Nothing is created; the earlier payout is unchanged.","retry":"No — use a new `request_id` for a new payout."},{"code":"rate_limit_exceeded","status":429,"when":"More than 120 requests in a minute for this key.","retry":"Yes — after `Retry-After` seconds."},{"code":"internal_error","status":500,"when":"Something failed on our side.","retry":"Usually yes. The ONE exception is called out in its own message: if a label was created but recording it failed, do NOT retry — contact support with the order id, because retrying would buy a second label."},{"code":"unknown_warehouse","status":422,"when":"A warehouse id that is not one of yours.","retry":"No — use an id from GET /v1/warehouses."},{"code":"unknown_sku","status":422,"when":"A line names a SKU that is not one of your products. `field` is the line, as `items[2].sku`.","retry":"No — create the product first, or fix the SKU."},{"code":"unknown_order","status":422,"when":"A return names an order or shipment that is not yours, or is of the other mode.","retry":"No."},{"code":"unknown_shipment","status":422,"when":"A shipment id that is not one of yours.","retry":"No."},{"code":"item_not_in_order","status":422,"when":"A return line for a SKU the original order did not have.","retry":"No."},{"code":"quantity_exceeds_order","status":422,"when":"A return line for more pieces than the order had, counting its other returns that are not cancelled.","retry":"No."},{"code":"order_not_shipped","status":422,"when":"A return for an order that has not shipped.","retry":"Once it ships."},{"code":"item_not_in_inbound","status":422,"when":"Receiving a SKU the inbound does not have.","retry":"No."},{"code":"item_not_in_transfer","status":422,"when":"Receiving a SKU the transfer does not have.","retry":"No."},{"code":"live_key_required","status":403,"when":"Creating or editing a product with a test key: the catalog is real in both modes. Also editing one of your real pickup addresses with a test key.","retry":"No — use a live key."},{"code":"sku_taken","status":409,"when":"Changing a product's SKU to one another of your products has.","retry":"No."},{"code":"sku_unavailable","status":409,"when":"The SKU belongs to a product you removed, or one merged into another product.","retry":"No — restore it in Wepaak, use the product it was merged into, or pick another SKU."},{"code":"dimensions_locked","status":409,"when":"Changing the weight or dimensions of a product Wepaak holds: Wepaak measures it.","retry":"No — they change in Wepaak."},{"code":"insufficient_stock","status":422,"when":"Not enough available stock at the origin for a transfer.","retry":"After stock arrives."},{"code":"wepaak_only","status":403,"when":"Something Wepaak does at its own warehouses: receiving an inbound or approving a transfer there.","retry":"No — Wepaak does it; you get the result."},{"code":"already_received","status":409,"when":"Receiving an inbound a second time.","retry":"No — it is done; read it."},{"code":"invalid_state","status":409,"when":"An inbound, transfer or return not in a status that allows the call (for example cancelling one already received). The message says which status it is in.","retry":"No."}],"x-webhook-events":[{"event":"order.dispatched","modes":"test and live","description":"A label exists. The tracking number is available and, for a self-ship order, so is the label PDF.","data":{"order_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","source":"woocommerce","external_id":"1042","status":"dispatched","tracking_number":"794658123456","carrier":"fedex","label_url":"https://api.wepaak.com/v1/shipments/4f2a8c60-91d7-4e35-8a1b-0c5d3e9f7a22/label"}},{"event":"shipment.status_changed","modes":"live, and test via POST /v1/shipments/{id}/simulate","description":"The carrier moved the parcel. Branch on `status` — the same values as GET /v1/tracking: created, picked_up, in_transit, delivered, returned, cancelled, failed, unknown. `status_detail` is the carrier's own wording, for display only.","data":{"shipment_id":"4f2a8c60-91d7-4e35-8a1b-0c5d3e9f7a22","tracking_number":"794658123456","order_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","source":"woocommerce","external_id":"1042","carrier":"fedex","status":"in_transit","previous_status":"picked_up","status_detail":"In Transit"}},{"event":"shipment.delivered","modes":"live, and test via POST /v1/shipments/{id}/simulate","description":"Terminal. Sent alongside the status change, so a connector marking an order complete need not string-match our status vocabulary.","data":{"shipment_id":"4f2a8c60-91d7-4e35-8a1b-0c5d3e9f7a22","tracking_number":"794658123456","order_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","source":"woocommerce","external_id":"1042","carrier":"fedex","status":"delivered","previous_status":"in_transit","status_detail":"Delivered"}},{"event":"shipment.cancelled","modes":"live, and test via POST /v1/shipments/{id}/simulate","description":"Terminal. The parcel will not be delivered.","data":{"shipment_id":"4f2a8c60-91d7-4e35-8a1b-0c5d3e9f7a22","tracking_number":"794658123456","order_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","source":"woocommerce","external_id":"1042","carrier":"fedex","status":"cancelled","previous_status":"created","status_detail":"Cancelled"}},{"event":"wallet.low_balance","modes":"live only","description":"A label bought through the API took your balance below your alert threshold — the low-balance alert you set in Wepaak, or 100 MXN without one. Sent once per crossing, not on every label after it; top up before labels start answering 402.","data":{"balance":84.5,"threshold":100,"currency":"MXN"}},{"event":"pickup.created","modes":"live only (a test key books nothing)","description":"A carrier pickup was booked: through POST /v1/pickups, or by you on the Collections page.","data":{"id":"5d1e7c2a-3b4f-4a6e-9c8d-1f2e3a4b5c6d","number":"COL-2026-00042","shipment_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","carrier":"estafeta","date":"2026-11-18","time_from":"10:00","time_to":"19:00","status":"scheduled","packages":1,"weight_kg":2.5,"address":"Av. Juárez 10, Centro, Guadalajara, Jalisco 44100","instructions":null,"created_at":"2026-11-17T16:02:11.000Z"}},{"event":"pickup.updated","modes":"live only","description":"A pickup’s status, date or hours changed (rescheduled, or the carrier’s status synced). `previous_status` and `previous_date` say what it was.","data":{"id":"5d1e7c2a-3b4f-4a6e-9c8d-1f2e3a4b5c6d","number":"COL-2026-00042","shipment_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","carrier":"estafeta","date":"2026-11-19","time_from":"10:00","time_to":"19:00","status":"rescheduled","packages":1,"weight_kg":2.5,"address":"Av. Juárez 10, Centro, Guadalajara, Jalisco 44100","instructions":null,"created_at":"2026-11-17T16:02:11.000Z","previous_status":"scheduled","previous_date":"2026-11-18"}},{"event":"pickup.cancelled","modes":"live only","description":"A pickup was cancelled. It is then gone from GET /v1/pickups, so this event is how you learn of it. Book another with POST /v1/pickups if the parcel still needs collecting.","data":{"id":"5d1e7c2a-3b4f-4a6e-9c8d-1f2e3a4b5c6d","number":"COL-2026-00042","shipment_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","carrier":"estafeta","date":"2026-11-18","time_from":"10:00","time_to":"19:00","status":"cancelled","packages":1,"weight_kg":2.5,"address":"Av. Juárez 10, Centro, Guadalajara, Jalisco 44100","instructions":null,"created_at":"2026-11-17T16:02:11.000Z","previous_status":"scheduled"}},{"event":"cod.status_changed","modes":"live only (sandbox shipments create no COD records)","description":"A shipment’s cash on delivery moved: `collected` (the carrier holds it), `available` (it can be paid out), `paid_out` (included in a payout), `returned` (nothing to pay), or back to `available` when its payout was cancelled. `previous_status` says what it was. **Only sent to an endpoint that lists this event by name** (an endpoint registered for every event does not get it), and registering it needs a key with the `cod.read` scope.","data":{"id":"7a1c2e3d-4b5f-4c6d-8e9f-0a1b2c3d4e5f","shipment_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","order_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","external_id":"1042","tracking_number":"WPK-2026-16041","carrier":"wepaak","pickup_address_id":"3f2a1b0c-9d8e-4f7a-8b6c-5d4e3f2a1b0c","status":"available","currency":"MXN","amount":850,"collected":850,"fees":0,"return_cost":0,"net":850,"dispatched_at":"2026-11-14T15:00:00.000Z","delivered_at":"2026-11-15T19:20:00.000Z","available_at":"2026-11-15T19:20:00.000Z","payout":null,"previous_status":"in_transit"}},{"event":"cod.payout_updated","modes":"live only","description":"A COD payout was requested, is being processed, was paid, failed or was cancelled. Carries the shipments it covers (at most 500; `shipments_truncated` is then true and GET /v1/cod/payouts/{id} has them all) and `previous_status`. **Only sent to an endpoint that lists this event by name** (an endpoint registered for every event does not get it), and registering it needs a key with the `cod.read` scope.","data":{"id":"1e2d3c4b-5a69-4788-9a0b-1c2d3e4f5a6b","number":"PAY-000123","status":"paid","currency":"MXN","amount":850,"withheld_charges":0,"to_wallet":0,"to_bank":850,"bank_account":{"clabe_last4":"7891","holder":"Comercio Ejemplo","bank":"BBVA"},"recipient":{"type":"integrator_client","name":"Comercio Ejemplo","clabe_last4":"7891","bank":"BBVA","reference":"cliente-0042"},"bank_reference":"SPEI-123456","receipt_available":true,"shipment_count":1,"failure_reason":null,"created_at":"2026-11-16T10:00:00.000Z","paid_at":"2026-11-17T12:00:00.000Z","shipments":[{"collection_id":"7a1c2e3d-4b5f-4c6d-8e9f-0a1b2c3d4e5f","shipment_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","order_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","external_id":"1042","tracking_number":"WPK-2026-16041","amount":850}],"previous_status":"processing"}},{"event":"inbound.received","modes":"live, and test via the matching POST …/simulate (or the test document's own calls)","description":"An inbound was received and counted, by Wepaak at its warehouses or by you at your own. `status` is `validated`, or `with_discrepancy` when a line differs; per line, `received_good` entered stock and `received_damaged` did not.","data":{"id":"6d0f3b1a-2c4e-4f8a-9b7d-1e5c3a9f0b42","mode":"live","number":"ASN-2026-00012","external_id":"PO-7781","status":"with_discrepancy","destination_warehouse_id":"0b8e2f4c-6a1d-4c3e-8f5b-9d2a7c1e4f60","items":[{"sku":"MUG-01","quantity":50,"received":48,"received_good":46,"received_damaged":2}],"validated_at":"2026-11-04T16:20:00Z","previous_status":"in_transit"}},{"event":"inbound.status_changed","modes":"live, and test via the matching POST …/simulate (or the test document's own calls)","description":"Any other move of an inbound: `in_transit`, or `cancelled` (its incoming stock is released).","data":{"id":"6d0f3b1a-2c4e-4f8a-9b7d-1e5c3a9f0b42","mode":"live","number":"ASN-2026-00012","external_id":"PO-7781","status":"in_transit","destination_warehouse_id":"0b8e2f4c-6a1d-4c3e-8f5b-9d2a7c1e4f60","items":[{"sku":"MUG-01","quantity":50,"received":null}],"validated_at":null,"previous_status":"scheduled"}},{"event":"transfer.status_changed","modes":"live, and test via the matching POST …/simulate (or the test document's own calls)","description":"A transfer moved: approved by Wepaak (`requested` → `in_transit`), rejected or cancelled (`cancelled`), received (`received` or `with_discrepancy`). When it **ships** from a Wepaak warehouse it becomes `sent`, with `shipped_at` set.","data":{"id":"9a4c2e7f-1b3d-4e5a-8c6f-2d0b9e7a1c35","mode":"live","number":"TRF-2026-00007","status":"in_transit","origin_warehouse_id":"0b8e2f4c-6a1d-4c3e-8f5b-9d2a7c1e4f60","destination_warehouse_id":"3e1a7c5b-9d2f-4b6e-8a0c-5f4d2b8e1a97","items":[{"sku":"MUG-01","quantity":20,"received_quantity":null}],"approved_at":"2026-11-04T10:00:00Z","shipped_at":null,"previous_status":"requested"}},{"event":"return.created","modes":"live, and test via the matching POST …/simulate (or the test document's own calls)","description":"A return exists. Most come **automatically**: a cash-on-delivery parcel the buyer refused (`cod_rejection`), or a shipment cancelled after pickup (`cancellation`). Also sent for the ones you open (`post_delivery`).","data":{"id":"2f7b9d1c-4a6e-4c8b-9e3f-7a1d5c0b8e24","mode":"live","number":"RET-2026-00031","type":"cod_rejection","status":"in_transit","order_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","shipment_id":"4f2a8c60-91d7-4e35-8a1b-0c5d3e9f7a22","items":[{"sku":"MUG-01","quantity":1,"good":null,"damaged":null,"missing":null}],"previous_status":null}},{"event":"return.awaiting_decision","modes":"live, and test via the matching POST …/simulate (or the test document's own calls)","description":"The return was checked and some pieces arrived damaged. The good ones are back in stock; the damaged ones wait for you: POST /v1/returns/{id}/decision with `restock` or `trash`.","data":{"id":"2f7b9d1c-4a6e-4c8b-9e3f-7a1d5c0b8e24","mode":"live","number":"RET-2026-00031","type":"cod_rejection","status":"pending_approval","order_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","shipment_id":"4f2a8c60-91d7-4e35-8a1b-0c5d3e9f7a22","items":[{"sku":"MUG-01","quantity":3,"good":2,"damaged":1,"missing":0}],"previous_status":"in_transit"}},{"event":"return.status_changed","modes":"live, and test via the matching POST …/simulate (or the test document's own calls)","description":"Any other move of a return: `in_transit`, `received`, `restocked`, `written_off`, `graded` (a mix), or `cancelled`.","data":{"id":"2f7b9d1c-4a6e-4c8b-9e3f-7a1d5c0b8e24","mode":"live","number":"RET-2026-00031","type":"cod_rejection","status":"restocked","order_id":"9c1b0f2e-5a3d-4c11-9f8a-2b7e6d4a1c33","shipment_id":"4f2a8c60-91d7-4e35-8a1b-0c5d3e9f7a22","items":[{"sku":"MUG-01","quantity":1,"good":1,"damaged":0,"missing":0,"restocked":1}],"previous_status":"in_transit"}}],"info":{"title":"Wepaak API","version":"1.3.0","description":"Ship in Mexico from your own system: price a shipment, send us an order, buy a\nlabel, and follow it to the door.\n\n## Authenticating\n\nSend your key as a bearer token:\n\n    Authorization: Bearer wpk_live_…\n\nKeys are created in Wepaak under **Connections → API**, and shown once. Each\nkey carries a set of scopes; a call outside them answers `403 insufficient_scope`.\n\n## Test and live\n\nA key is either `wpk_test_` or `wpk_live_`, and the mode comes from the key\nalone — never from anything you send.\n\nTest keys create real orders you can read back, but **no carrier is called, no\nlabel is bought, nothing is charged and nobody is emailed**. The two worlds do\nnot mix: a test key cannot read, ship or track a live order, and a live key\ncannot touch a test one. Both answer `404` rather than `403`, because telling\nyou something exists but is not yours is itself a leak.\n\nEvery rule still runs in test mode — address validation, stock, coverage,\ntariff limits, your automation rules — so \"it worked in test\" means something.\nA test shipment comes back with a `TEST…` tracking number, and both\n`GET /shipments/{id}` and `GET /tracking/{tracking_number}` resolve it, so you\ncan exercise the whole flow before switching keys. Quotes are the one thing\nthat is NOT simulated: those are real carrier prices, because a sandbox that\ninvented them would be useless for testing what you charge.\n\n## Retrying safely\n\nEvery write is idempotent on something you already know, so a retry after a\ntimeout is always safe:\n\n| Call | Repeating it |\n|---|---|\n| `POST /orders` | Same `external_id` returns the same order |\n| `POST /shipments` | Same `order_id` returns the same shipment — never a second label |\n| `POST /webhooks` | Same URL returns the existing endpoint |\n\nThe one exception is called out in its own error message: if a label was\ncreated but recording it failed, **do not retry** — contact support with the\norder id, because retrying would buy a second label.\n\n## Rate limits\n\n120 requests per minute per key, and 600 per minute from any one IP address\nacross all keys. Every metered response carries\n`RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` so you can pace\nyourself rather than discover the limit by being refused. Over it, `429` with\n`Retry-After`. `/v1/ping`, `/v1/openapi.json` and `/v1/docs` are not metered, so\nthey carry no RateLimit headers.\n\n## Verifying webhooks\n\nEvery delivery carries `Wepaak-Signature: t=<unix seconds>,v1=<hex>`. The hex is the\nHMAC-SHA256 of the timestamp, a dot and the RAW request body, keyed with the\nendpoint's secret. Check it before trusting the body, compare in constant time,\nand refuse a timestamp more than five minutes away. Node:\n\n    const crypto = require('crypto');\n    function verifyWepaak(rawBody, header, secret) {\n      const p = Object.fromEntries(String(header).split(',').map((kv) => kv.split('=')));\n      if (!p.t || !p.v1 || Math.abs(Date.now() / 1000 - Number(p.t)) > 300) return false;\n      const expected = crypto.createHmac('sha256', secret).update(p.t + '.' + rawBody).digest('hex');\n      return expected.length === p.v1.length\n        && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(p.v1));\n    }\n\nPHP:\n\n    function wepaak_verify($raw_body, $header, $secret) {\n      parse_str(str_replace(',', '&', $header), $p);\n      if (empty($p['t']) || empty($p['v1']) || abs(time() - (int) $p['t']) > 300) return false;\n      return hash_equals(hash_hmac('sha256', $p['t'] . '.' . $raw_body, $secret), $p['v1']);\n    }\n\nUse the body exactly as received: parse it as JSON only after the check, because\nre-serialising changes the bytes and the signature with them.\n\n## Webhook deliveries\n\nEach delivery is a `POST` with a JSON body:\n\n    { \"event\": \"shipment.delivered\", \"mode\": \"live\",\n      \"created_at\": \"2026-11-03T18:20:00.000Z\", \"data\": { … } }\n\n`data` is per event (see Webhook events). The headers:\n\n| Header | What |\n|---|---|\n| `Wepaak-Event` | The event, as in the body |\n| `Wepaak-Delivery` | This delivery's id. A retry of the same delivery has the same id |\n| `Wepaak-Signature` | `t=<unix seconds>,v1=<hex>`, see above |\n\n**Answer with any 2xx within 10 seconds** to mark it delivered. Anything else, or\nno answer, is retried 5 minutes, 30 minutes, 2 hours and 6 hours later, then given\nup; `GET /v1/webhooks/{id}/deliveries` shows every attempt.\n\n**Deduplicate on `Wepaak-Delivery`.** A delivery is sent once when you answer 2xx,\nbut a retry after a timeout on your side reaches you again with the same id. Treat\na repeated id as already done.\n\n## Requests\n\nSend bodies as JSON with `Content-Type: application/json`; anything else is\nrefused with `415`. Fields we do not know are ignored, not rejected — except on\nproducts, inbounds, transfers and returns, which refuse an unknown field with\n`422 invalid_request` naming it, so a change you meant to make is never dropped\nsilently (`items` on PATCH /v1/transfers/{id}, for example: a transfer's lines\ncannot change once it exists). Numbers may be sent as numbers or as numeric\nstrings (`\"15\"`); both are read the same. The schemas show the number form.\n\n## Money\n\nPrices are yours — what you are quoted is what you pay. What we pay a carrier,\nand which carrier network a rate came through, are not part of this API.","contact":{"name":"Wepaak","email":"contacto@wepaak.com","url":"https://envios.wepaak.com"}},"servers":[{"url":"https://api.wepaak.com","description":"Wepaak API"}],"tags":[{"name":"Orders","description":"Send us what your customer bought."},{"name":"Quotes","description":"What a shipment will cost, before committing to one."},{"name":"Shipments","description":"Turn an order into a label."},{"name":"Pickups","description":"Have the carrier collect a shipment."},{"name":"Cash on delivery","description":"Where each COD amount is, the totals, and the payouts that paid them."},{"name":"Tracking","description":"Where a parcel is."},{"name":"Lookups","description":"Postal codes, carriers, and your balance."},{"name":"Inventory","description":"Your warehouses, products and stock."},{"name":"Inbounds","description":"Stock you send into a warehouse."},{"name":"Transfers","description":"Stock moved between your warehouses."},{"name":"Returns","description":"Goods coming back, including the automatic ones."},{"name":"Webhooks","description":"Be told when something happens, instead of asking."},{"name":"Account","description":"Who this key belongs to."}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Your API key: `Authorization: Bearer wpk_live_…`"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"invalid_api_key"},"message":{"type":"string","example":"The API key provided is not valid, or has been revoked."},"field":{"type":"string","nullable":true,"description":"The offending input, when one can be named."},"doc_url":{"type":"string","format":"uri"}},"required":["code","message"]}}},"Address":{"type":"object","required":["street1","city","state","postal_code"],"properties":{"street1":{"type":"string","example":"Av. Vallarta 1234"},"interior":{"type":"string","nullable":true,"example":"Depto 5B"},"colonia":{"type":"string","nullable":true,"example":"Americana","description":"Optional, free text: never refused. Filled from the postal code when omitted — most channels have no such field. When the text is clearly one of the colonias of the postal code (e.g. \"CD GRANJA\"), the label carries its official name (\"Ciudad Granja\")."},"city":{"type":"string","example":"Guadalajara"},"state":{"type":"string","example":"Jalisco","description":"The state. Its full name is stored, because carriers expect it; a code or common short form (`JAL`, `CDMX`, `NL`, `EDOMEX`…) is accepted and translated.\n\nAnything else: on a **quote** it is refused with `422` naming the field. On an **order** it is not, so a store's order is never lost over a typo: the state is set from the postal code, and the order's notes say what was changed. When the postal code cannot say either, the state is kept as sent and noted, to correct in Wepaak."},"postal_code":{"type":"string","pattern":"^\\d{5}$","example":"44160"},"country_code":{"type":"string","default":"MX","example":"MX"},"reference":{"type":"string","nullable":true,"example":"Portón negro, entre Chapultepec y Colonias"}}},"Rate":{"type":"object","properties":{"rate_id":{"type":"string","example":"rate_4e800a8fc898d6a8"},"carrier":{"type":"string","example":"fedex"},"carrier_name":{"type":"string","example":"FedEx"},"service":{"type":"string","nullable":true,"example":"ground","description":"The service in plain words (`ground`, `express`, `standard`, `cod`…), lowercase snake_case. Two rates of one carrier can share it; tell them apart by `rate_id`. Never the own id of a carrier network."},"service_name":{"type":"string","nullable":true,"example":"Express"},"total":{"type":"number","example":149,"description":"What this shipment will cost you."},"currency":{"type":"string","example":"MXN"},"estimated_days":{"type":"integer","nullable":true,"example":2},"cod":{"type":"boolean","description":"A COD rate can only be used for a cash-on-delivery order, and a prepaid rate only for a prepaid one."}}},"Order":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"mode":{"type":"string","enum":["test","live"]},"source":{"type":"string","example":"woocommerce"},"external_id":{"type":"string","description":"Your id for this order. Ingestion is idempotent on it."},"external_number":{"type":"string","nullable":true},"status":{"type":"string","enum":["cod_pending","ready","address_issue","stock_issue","requires_mapping","dispatched","cancelled"]},"issues":{"type":"array","items":{"type":"string"},"description":"What still stands between this order and a label. Each entry is a code, sometimes followed by `:<detail>`.\n\n| Issue | Status it puts the order in | Meaning | How to clear it |\n|---|---|---|---|\n| `address_incomplete:<fields>` | `address_issue` | Required address fields are missing. A street with only a number and no street name (`\"73\"`) counts as missing `shipping_street1`: carriers refuse it | Correct the address in Wepaak |\n| `address_mismatch:<part>:<expected>` | `address_issue` | The postal code belongs to a different state or city (the colonia is free text and never holds an order) | Correct the address |\n| `untracked_item:<sku or name>` | `requires_mapping` | The order ships from a **Wepaak warehouse**, which can only pick products registered in your Wepaak inventory, and this line matches none | Send the line with the `sku` of a product in your inventory, or link the product in Wepaak |\n| `stock_insufficient:<sku>` | `stock_issue` | Not enough units in the warehouse | Restock, or wait for an inbound |\n| `package_required` | `address_issue` | You pack this order yourself and no box was declared | Send `package` (all four measurements) with the order |\n| `warehouse_required` | — | No origin is assigned | Send `warehouse_id`, or (if you pack your own orders) add an address you operate in Wepaak |\n| `carrier_required` | — | No courier chosen yet | Ship with `quote_id` + `rate_id` from POST /v1/quotes |\n| `own_label_missing` | `ready` | The order ships on a label you bought elsewhere, and no label PDF is matched to it yet | Upload the label under Orders > My own labels in Wepaak |"},"payment_type":{"type":"string","enum":["prepaid","cod"]},"cod_amount":{"type":"number"},"currency":{"type":"string","example":"MXN"},"customer":{"type":"object","properties":{"name":{"type":"string"},"phone":{"type":"string","nullable":true},"email":{"type":"string","nullable":true}}},"shipping_address":{"$ref":"#/components/schemas/Address"},"items":{"type":"array","items":{"type":"object","properties":{"sku":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"quantity":{"type":"integer"},"unit_price":{"type":"number","nullable":true}}}},"assigned_warehouse_id":{"type":"string","format":"uuid","nullable":true},"carrier":{"type":"string","nullable":true},"carrier_service":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true,"readOnly":true,"example":"Imported via API (woocommerce) · State \"Narnia\" not recognised; set to Jalisco from postal code 44160.","description":"What Wepaak noted on the order: where it came from, and anything changed on the way in (a state set from the postal code, a box left out because no carrier takes it). Read-only."},"shipment_id":{"type":"string","format":"uuid","nullable":true},"tracking_number":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"}}},"Shipment":{"type":"object","properties":{"id":{"type":"string","format":"uuid","nullable":true,"description":"The shipment. Use it with every /v1/shipments/{id} endpoint, and wherever a `shipment_id` is asked for (inbounds, transfers, returns). It equals `order_id` when no carrier label was bought: a test shipment, and one on your own label. `null` only while `status` is `pending` (the label is bought at packing)."},"order_id":{"type":"string","format":"uuid","description":"The order it ships. Every shipment ships one order."},"external_id":{"type":"string","nullable":true,"description":"Your own order number, as you sent it on POST /v1/orders."},"mode":{"type":"string","enum":["test","live"]},"status":{"type":"string","enum":["created","pending","cancellation_requested","cancelled"],"description":"`created` means a label exists. `pending` means the parcel is queued for pick and pack in a Wepaak warehouse and the label is minted then — not a failure, and not something to retry. `cancellation_requested`: cancelled after the free window, waiting for Wepaak to review it (`202` from POST /v1/shipments/{id}/cancel); `shipment.cancelled` follows if it is approved. `cancelled` means the shipment was cancelled (POST /v1/shipments/{id}/cancel, or in Wepaak).\n\nThis is the state of the **label**, not of the parcel's journey. Pickup, transit and delivery are in `GET /v1/tracking/{tracking_number}` and the `shipment.*` webhooks: a delivered parcel's shipment stays `created` here, and its order stays `dispatched`."},"own_label":{"type":"boolean","description":"`true` when it ships on a label you bought elsewhere and uploaded to Wepaak: Wepaak bought no label, so the label and cancel endpoints answer `409 own_label`."},"carrier":{"type":"string","nullable":true},"service":{"type":"string","nullable":true},"tracking_number":{"type":"string","nullable":true},"issues":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"date-time"}}},"WebhookEndpoint":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"mode":{"type":"string","enum":["test","live"]},"active":{"type":"boolean"},"secret":{"type":"string","example":"whsec_…","description":"Only when the endpoint is registered."},"created_at":{"type":"string","format":"date-time"}}},"CodRecord":{"type":"object","description":"The cash-on-delivery record of one shipment.","properties":{"id":{"type":"string","format":"uuid"},"shipment_id":{"type":"string","format":"uuid","description":"The id GET /v1/shipments/{id} answers to."},"order_id":{"type":"string","format":"uuid","nullable":true},"external_id":{"type":"string","nullable":true,"description":"Your order id (POST /v1/orders `external_id`)."},"tracking_number":{"type":"string","nullable":true},"carrier":{"type":"string","nullable":true},"pickup_address_id":{"type":"string","format":"uuid","nullable":true,"description":"The pickup address it shipped from: one per client of yours."},"status":{"type":"string","enum":["in_transit","collected","available","paid_out","returned"],"description":"`in_transit`: on its way. `collected`: delivered, the carrier holds the cash. `available`: settled, can be paid out. `paid_out`: included in a payout (its `payout.status` says whether it is paid yet). `returned`: refused or returned, nothing to pay (a return cost may apply)."},"currency":{"type":"string","example":"MXN"},"amount":{"type":"number","description":"What the buyer was to pay."},"collected":{"type":"number","nullable":true,"description":"What was collected, once known."},"fees":{"type":"number","description":"Collection fees and withholdings."},"return_cost":{"type":"number"},"net":{"type":"number","description":"What is paid out for it: collected - fees - return cost."},"dispatched_at":{"type":"string","format":"date-time","nullable":true},"delivered_at":{"type":"string","format":"date-time","nullable":true},"available_at":{"type":"string","format":"date-time","nullable":true},"payout":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"number":{"type":"string"},"status":{"type":"string"}}}}},"CodPayout":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"number":{"type":"string","nullable":true,"example":"PAY-000123","description":"Null only on a test key's simulated payout."},"status":{"type":"string","enum":["requested","processing","paid","failed","cancelled"]},"currency":{"type":"string","example":"MXN"},"amount":{"type":"number","description":"The net of the shipments it covers, together."},"withheld_charges":{"type":"number","description":"Charges owed to Wepaak, kept back from it."},"to_wallet":{"type":"number","description":"Part credited to your shipping wallet."},"to_bank":{"type":"number","nullable":true,"description":"Part deposited to the bank account."},"bank_account":{"type":"object","nullable":true,"properties":{"clabe_last4":{"type":"string"},"holder":{"type":"string","nullable":true},"bank":{"type":"string","nullable":true}}},"recipient":{"type":"object","description":"Whom the payout pays. `merchant`: your own account's bank account (a payout asked for in Wepaak). `integrator_client`: the client of yours whose bank details came with POST /v1/cod/payouts. Never the full CLABE.","properties":{"type":{"type":"string","enum":["merchant","integrator_client"]},"name":{"type":"string","nullable":true,"description":"The account holder."},"clabe_last4":{"type":"string","nullable":true},"bank":{"type":"string","nullable":true},"reference":{"type":"string","nullable":true,"description":"Your id for that client, as you sent it."}}},"bank_reference":{"type":"string","nullable":true,"description":"The transfer reference, once paid."},"receipt_available":{"type":"boolean"},"shipment_count":{"type":"integer"},"failure_reason":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"paid_at":{"type":"string","format":"date-time","nullable":true},"shipments":{"type":"array","description":"On GET /v1/cod/payouts/{id} and on the answers of POST /v1/cod/payouts and its cancel.","items":{"type":"object","properties":{"collection_id":{"type":"string","format":"uuid"},"shipment_id":{"type":"string","format":"uuid"},"order_id":{"type":"string","format":"uuid","nullable":true},"external_id":{"type":"string","nullable":true},"tracking_number":{"type":"string","nullable":true},"amount":{"type":"number"}}}}}},"CodPayoutRequest":{"type":"object","required":["shipment_ids","recipient"],"properties":{"shipment_ids":{"type":"array","minItems":1,"maxItems":500,"uniqueItems":true,"items":{"type":"string","format":"uuid"},"description":"The shipments whose COD is paid out: the ids GET /v1/cod/collections shows as `shipment_id` (an order id works too). Every one must be `available` and in no payout."},"recipient":{"type":"object","required":["name","clabe"],"description":"The bank account the money goes to: your client's.","properties":{"name":{"type":"string","maxLength":255,"description":"The account holder, as the bank has it.","example":"Abarrotes Lupita SA de CV"},"clabe":{"type":"string","pattern":"^\\d{18}$","example":"002010077777777771","description":"The 18-digit CLABE, as a string. Its check digit is verified: a mistyped CLABE is refused."},"bank":{"type":"string","maxLength":120,"description":"Optional. When left out it is read from the CLABE's first three digits (null when the bank is not one we know)."}}},"reference":{"type":"string","maxLength":120,"description":"Your id for this client. Shown back on the payout as `recipient.reference`."},"request_id":{"type":"string","maxLength":120,"description":"Your idempotency key. The same `request_id` again from your account returns the payout it already made (200), never a second one."},"notes":{"type":"string","maxLength":500}}},"Pickup":{"type":"object","properties":{"id":{"type":"string","format":"uuid","nullable":true},"number":{"type":"string","nullable":true,"description":"Our reference for the pickup."},"shipment_id":{"type":"string","format":"uuid","nullable":true},"carrier":{"type":"string","nullable":true},"date":{"type":"string","format":"date"},"time_from":{"type":"string","example":"10:00"},"time_to":{"type":"string","example":"19:00"},"status":{"type":"string","description":"`scheduled`, `completed`, `cancelled`… (`simulated` with a test key)."},"packages":{"type":"integer","nullable":true},"weight_kg":{"type":"number","nullable":true},"address":{"type":"string","nullable":true},"instructions":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"}}},"Warehouse":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"operated_by":{"type":"string","enum":["self","wepaak"],"description":"`self`: your own warehouse. `wepaak`: a Wepaak warehouse, where Wepaak receives, stores and ships for you."},"status":{"type":"string"},"is_default":{"type":"boolean"},"test":{"type":"boolean","description":"Made with a test key: seen only by test keys, used only by test orders."},"contact":{"type":"object","properties":{"name":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"email":{"type":"string","nullable":true}},"description":"Who to ask for at the pickup."},"address":{"$ref":"#/components/schemas/Address"},"created_at":{"type":"string","format":"date-time"}}},"PickupAddressWrite":{"type":"object","required":["name","phone","street1","city","state","postal_code"],"properties":{"label":{"type":"string","maxLength":120,"description":"How it is named in your list. Default: \"<name> — <city> <postal code>\"."},"name":{"type":"string","maxLength":120,"description":"Contact at the pickup address."},"company":{"type":"string","maxLength":120},"phone":{"type":"string","maxLength":40},"email":{"type":"string","maxLength":150},"street1":{"type":"string","maxLength":255,"description":"Street and number."},"interior":{"type":"string","maxLength":50},"colonia":{"type":"string","maxLength":120,"description":"Filled from the postal code when left out."},"city":{"type":"string","maxLength":120},"state":{"type":"string","maxLength":120,"description":"Name or abbreviation; stored as the full state name."},"postal_code":{"type":"string","pattern":"^[0-9]{5}$"},"country_code":{"type":"string","enum":["MX"],"default":"MX"},"reference":{"type":"string","maxLength":255}}},"InventoryRow":{"type":"object","description":"Stock of one product in one warehouse.","properties":{"product_id":{"type":"string","format":"uuid"},"sku":{"type":"string"},"name":{"type":"string"},"warehouse_id":{"type":"string","format":"uuid"},"warehouse_name":{"type":"string"},"warehouse_operated_by":{"type":"string","enum":["self","wepaak"]},"on_hand":{"type":"integer"},"committed":{"type":"integer"},"available":{"type":"integer"},"incoming":{"type":"integer"},"low_stock_threshold":{"type":"integer","nullable":true},"updated_at":{"type":"string","format":"date-time"}}},"Product":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"sku":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"barcode":{"type":"string","nullable":true},"category":{"type":"string","nullable":true},"status":{"type":"string"},"weight_kg":{"type":"number","nullable":true},"dimensions_cm":{"type":"object","properties":{"length":{"type":"number","nullable":true},"width":{"type":"number","nullable":true},"height":{"type":"number","nullable":true}}},"declared_value":{"type":"number","nullable":true},"sat_code":{"type":"string","nullable":true},"manages_expiry":{"type":"boolean","description":"Stock is tracked by lot and expiry date."},"low_stock_threshold":{"type":"integer","nullable":true},"stock":{"type":"object","description":"Totals over every warehouse. `on_hand`: units physically in the warehouse. `committed`: reserved for orders, prep requests and transfers not yet shipped. `available`: on_hand − committed, never below 0. `incoming`: expected from inbounds, transfers and returns not yet received.","properties":{"on_hand":{"type":"integer"},"committed":{"type":"integer"},"available":{"type":"integer"},"incoming":{"type":"integer"}}},"warehouses":{"type":"array","description":"Only on `GET /v1/products/{id}`: the stock in each warehouse.","items":{"type":"object","properties":{"warehouse_id":{"type":"string","format":"uuid"},"warehouse_name":{"type":"string"},"warehouse_operated_by":{"type":"string","enum":["self","wepaak"]},"on_hand":{"type":"integer"},"committed":{"type":"integer"},"available":{"type":"integer"},"incoming":{"type":"integer"}}}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"StockMovement":{"type":"object","description":"One line of the stock ledger. Every change to on-hand stock is one.","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["stock_in","stock_out","inbound_validated","dispatch","return_restock","return_writeoff","cod_return","cancellation_restock","transfer_out","transfer_in","manual_correction"]},"quantity":{"type":"integer","description":"Signed: positive into stock, negative out of it. A write-off is 0 (recorded, nothing moves)."},"warehouse_id":{"type":"string","format":"uuid"},"warehouse_name":{"type":"string","nullable":true},"reason":{"type":"string","nullable":true},"document":{"type":"object","nullable":true,"description":"What caused it, when known.","properties":{"type":{"type":"string","enum":["inbound","transfer","return","order","shipment"]},"id":{"type":"string","format":"uuid"}}},"created_at":{"type":"string","format":"date-time"}}},"Inbound":{"type":"object","description":"An inbound (ASN): stock you send into a warehouse.","properties":{"id":{"type":"string","format":"uuid"},"mode":{"type":"string","enum":["test","live"],"description":"The mode of the key that created it."},"number":{"type":"string","example":"ASN-2026-00012"},"external_id":{"type":"string","nullable":true,"description":"Your own reference, if you sent one."},"status":{"type":"string","enum":["scheduled","in_transit","pending_validation","validated","with_discrepancy","cancelled"]},"destination_warehouse_id":{"type":"string","format":"uuid"},"destination_warehouse_name":{"type":"string","nullable":true},"logistics_method":{"type":"string","enum":["wepaak_carrier","own_means"]},"shipment_id":{"type":"string","format":"uuid","nullable":true},"tracking_number":{"type":"string","nullable":true},"scheduled_date":{"type":"string","format":"date-time","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"sku":{"type":"string"},"name":{"type":"string","nullable":true},"quantity":{"type":"integer","description":"Units you said you are sending."},"received":{"type":"integer","nullable":true,"description":"Units counted on arrival. `null` until received."},"received_good":{"type":"integer","nullable":true},"received_damaged":{"type":"integer","nullable":true,"description":"Counted but not added to stock."},"lot_code":{"type":"string","nullable":true},"expiry_date":{"type":"string","nullable":true}}}},"validated_at":{"type":"string","format":"date-time","nullable":true},"validation_comments":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"Transfer":{"type":"object","description":"Stock moved between two of your warehouses.","properties":{"id":{"type":"string","format":"uuid"},"mode":{"type":"string","enum":["test","live"],"description":"The mode of the key that created it."},"number":{"type":"string","example":"TRF-2026-00007"},"external_id":{"type":"string","nullable":true},"status":{"type":"string","enum":["requested","approved","in_transit","sent","received","with_discrepancy","cancelled"]},"origin_warehouse_id":{"type":"string","format":"uuid"},"origin_warehouse_name":{"type":"string","nullable":true},"destination_warehouse_id":{"type":"string","format":"uuid"},"destination_warehouse_name":{"type":"string","nullable":true},"requires_approval":{"type":"boolean","description":"Into a Wepaak warehouse from your own: Wepaak approves it first."},"logistics_method":{"type":"string"},"shipment_id":{"type":"string","format":"uuid","nullable":true},"tracking_number":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"sku":{"type":"string"},"name":{"type":"string","nullable":true},"quantity":{"type":"integer","description":"Units sent."},"received_quantity":{"type":"integer","nullable":true,"description":"`null` until received."}}}},"approved_at":{"type":"string","format":"date-time","nullable":true},"shipped_at":{"type":"string","format":"date-time","nullable":true,"description":"When it left a Wepaak warehouse."},"received_at":{"type":"string","format":"date-time","nullable":true},"notes":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"Return":{"type":"object","description":"Goods coming back into a warehouse. `cod_rejection` and `cancellation` returns are created automatically; `post_delivery` returns are opened by you.","properties":{"id":{"type":"string","format":"uuid"},"mode":{"type":"string","enum":["test","live"],"description":"The mode of the key that created it."},"number":{"type":"string","example":"RET-2026-00031"},"external_id":{"type":"string","nullable":true},"type":{"type":"string","enum":["cod_rejection","cancellation","post_delivery"]},"status":{"type":"string","enum":["requested","label_generated","in_transit","received","pending_approval","graded","restocked","written_off","cancelled"],"description":"`pending_approval`: damaged pieces wait for your restock-or-trash decision."},"order_id":{"type":"string","format":"uuid","nullable":true},"shipment_id":{"type":"string","format":"uuid","nullable":true},"destination_warehouse_id":{"type":"string","format":"uuid"},"destination_warehouse_name":{"type":"string","nullable":true},"logistics_method":{"type":"string","nullable":true},"return_shipment_id":{"type":"string","format":"uuid","nullable":true},"return_tracking_number":{"type":"string","nullable":true},"reason":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"sku":{"type":"string"},"name":{"type":"string","nullable":true},"quantity":{"type":"integer","description":"Units coming back."},"good":{"type":"integer","nullable":true},"damaged":{"type":"integer","nullable":true},"missing":{"type":"integer","nullable":true},"restocked":{"type":"integer","nullable":true},"written_off":{"type":"integer","nullable":true},"grade":{"type":"string","enum":["A","B","C"],"nullable":true},"note":{"type":"string","nullable":true}}}},"received_at":{"type":"string","format":"date-time","nullable":true},"graded_at":{"type":"string","format":"date-time","nullable":true},"notes":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}}},"responses":{"Unauthorized":{"description":"No key was sent, or it is not valid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"This key does not carry the scope this call requires.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"No such resource for this key — including one that belongs to another account, or to the other mode.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"TooManyRequests":{"description":"Rate limit exceeded. See `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"security":[{"bearerAuth":[]}],"paths":{"/v1/ping":{"get":{"tags":["Account"],"summary":"Liveness check","description":"Unauthenticated on purpose: it proves the connection itself works, separately from whether your key does.","security":[],"responses":{"200":{"description":"The API is reachable.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","example":true},"service":{"type":"string","example":"wepaak-public-api"},"version":{"type":"string","example":"1.3.0","description":"The contract version — the same as `info.version` in /v1/openapi.json."}}}}}}}}},"/v1/openapi.json":{"get":{"tags":["Account"],"summary":"This document","description":"The machine-readable contract, served by the same deployment that answers the calls — so it cannot describe a version that is not running. Import it into Postman or any client generator.","security":[],"responses":{"200":{"description":"An OpenAPI 3 document."}}}},"/v1/docs":{"get":{"tags":["Account"],"summary":"This reference, as a page","description":"The human-readable version of the same document.","security":[],"responses":{"200":{"description":"An HTML page."}}}},"/v1/connect/exchange":{"post":{"tags":["Account"],"summary":"Exchange a connect code for a key","description":"For connectors — a plugin, an app, an integration installed by someone else's merchants — that need a key without asking the merchant to copy one.\n\nSend the merchant to `https://envios.wepaak.com/connect/authorize` with your `client`, a `redirect_uri`, a random `state`, and a `code_challenge` (the base64url SHA-256 of a random verifier you keep). They sign in and approve; we send their browser back to your `redirect_uri` with a `code`. Your **server** then calls this endpoint with that code and the verifier, and receives the key.\n\nUnauthenticated because the caller has no key yet — that is the point. The code is single-use, expires in ten minutes, and a wrong verifier consumes it rather than allowing another attempt, so a leaked redirect URL alone is worth nothing.\n\nThere is no client secret, deliberately: a connector distributed to strangers cannot keep one.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["code","code_verifier"],"properties":{"code":{"type":"string","example":"wpkc_…"},"code_verifier":{"type":"string","description":"The random string whose SHA-256 you sent as `code_challenge`."}}}}}},"responses":{"201":{"description":"The merchant's key. Store it — it is not shown again.","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"type":"string","example":"wpk_live_…"},"mode":{"type":"string","enum":["test","live"]},"scopes":{"type":"array","items":{"type":"string"}},"account_email":{"type":"string","nullable":true,"description":"So you can show the merchant which Wepaak account they connected."}}}}}},"400":{"description":"`invalid_grant` — the code is unknown, expired, already used, or the verifier did not match. Start the flow again.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me":{"get":{"tags":["Account"],"summary":"Who this key is","description":"The first call to make: confirms your key works, which mode it is in and what it may do — before you write any real integration code.","responses":{"200":{"description":"The credential behind this request.","content":{"application/json":{"schema":{"type":"object","properties":{"mode":{"type":"string","enum":["test","live"]},"account_id":{"type":"string","format":"uuid"},"scopes":{"type":"array","items":{"type":"string"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/v1/orders":{"get":{"tags":["Orders"],"summary":"List orders","description":"**Scope:** `orders.read`\n\nNewest first. Only orders from this key's mode are listed.","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["cod_pending","ready","address_issue","stock_issue","requires_mapping","dispatched","cancelled"]}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"A page of orders.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Order"}},"has_more":{"type":"boolean"},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}},"400":{"description":"A filter was not understood. A limit above 100 is refused rather than quietly reduced, so you never page past orders without noticing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"orders.read"},"post":{"tags":["Orders"],"summary":"Create an order","description":"**Scope:** `orders.write`\n\nIdempotent on `external_id`: sending the same one again returns the order you already created, with `200` instead of `201`. No label is bought here and nothing is charged.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["external_id","customer","shipping_address","items"],"properties":{"external_id":{"type":"string","maxLength":120,"example":"1042"},"external_number":{"type":"string","maxLength":120,"example":"#1042"},"source":{"type":"string","default":"api","example":"woocommerce","pattern":"^[a-z][a-z0-9_]*$","maxLength":30,"description":"Where this order came from: lowercase letters, digits and underscores, starting with a letter (`qa_agent`, not `qa-agent`)."},"payment_type":{"type":"string","enum":["prepaid","cod"],"default":"prepaid"},"cod_amount":{"type":"number","minimum":0.01,"description":"Required for a COD order. A COD shipment with no amount is one nobody can settle."},"currency":{"type":"string","default":"MXN"},"customer":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"phone":{"type":"string","nullable":true,"description":"The phone of the person receiving the parcel; carriers need it. Without it the order is still created, held as `address_issue` with `address_incomplete:customer_phone` in `issues`, until it is added in Wepaak."},"email":{"type":"string","nullable":true}}},"shipping_address":{"$ref":"#/components/schemas/Address"},"items":{"type":"array","minItems":1,"description":"At least one line. Each needs a `sku` or a `name`. To ship from a Wepaak warehouse, every line must be the `sku` of a product in your Wepaak inventory — otherwise the order is held as `requires_mapping` (see `issues` on the Order).\n\n**If you pack your own orders** (your account has no Wepaak warehouse) and none of the lines are products in your Wepaak inventory, the order ships from your own default address, and needs `package` with all four measurements. Send `warehouse_id` to choose a different origin.","items":{"type":"object","properties":{"sku":{"type":"string"},"name":{"type":"string"},"quantity":{"type":"integer","minimum":1},"unit_price":{"type":"number"}}}},"package":{"type":"object","nullable":true,"description":"All four measurements or none. Required later if you pack and ship yourself, since nothing else measures the box. A box over 300 cm a side or 1000 kg is not a parcel: the order is still created, without that box, and is held with the issue `package_required` until it has a real one.","properties":{"length_cm":{"type":"number","minimum":0.1},"width_cm":{"type":"number","minimum":0.1},"height_cm":{"type":"number","minimum":0.1},"weight_kg":{"type":"number","minimum":0.001}}},"placed_at":{"type":"string","format":"date-time"},"warehouse_id":{"type":"string","format":"uuid","nullable":true,"description":"Which of your warehouses this ships FROM: an id from `GET /v1/warehouses`. Leave it out and we route the order automatically, closest warehouse with stock first. An order with any item that is not one of your products ships from one of your own warehouses, never a Wepaak one (Wepaak picks by SKU). Send it when you want to choose, and for COD orders, which are not auto-routed. Not together with `address_from`."},"address_from":{"type":"object","nullable":true,"description":"Where the parcel is picked up, as an address, instead of `warehouse_id`. For platforms whose users each ship from their own place. The address is saved as one of your pickup addresses (it appears in `GET /v1/warehouses`) and reused when the same street, interior and postal code come again, so sending it on every order is fine. The order then ships from it like any order from your own warehouse: send `package` with all four measurements. Not together with `warehouse_id`.","required":["name","phone","street1","city","state","postal_code"],"properties":{"name":{"type":"string","maxLength":120,"description":"Contact at the pickup address."},"company":{"type":"string","maxLength":120},"phone":{"type":"string","maxLength":40},"email":{"type":"string","maxLength":150},"street1":{"type":"string","maxLength":255,"description":"Street and number."},"interior":{"type":"string","maxLength":50},"colonia":{"type":"string","maxLength":120,"description":"Free text, never refused; filled from the postal code when left out."},"city":{"type":"string","maxLength":120},"state":{"type":"string","maxLength":120,"description":"Name or abbreviation; stored as the full state name."},"postal_code":{"type":"string","pattern":"^[0-9]{5}$"},"country_code":{"type":"string","enum":["MX"],"default":"MX"},"reference":{"type":"string","maxLength":255}}}}}}}},"responses":{"200":{"description":"This `external_id` already existed — here it is again.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Something in the order could not be accepted. `field` names it.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"orders.write"}},"/v1/orders/{id}":{"get":{"tags":["Orders"],"summary":"Fetch one order","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The order.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"orders.read","description":"**Scope:** `orders.read`"}},"/v1/orders/{id}/cancel":{"post":{"tags":["Orders"],"summary":"Cancel an order that has not shipped","description":"**Scope:** `orders.write`\n\nThe same cancellation as in Wepaak: the order is cancelled and the stock it was holding is released. An order that has already shipped answers `409 order_already_dispatched` — cancel its shipment instead.\n\n**Idempotent.** Cancelling an order that is already cancelled returns it again with `200`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","maxLength":255}}}}}},"responses":{"200":{"description":"Cancelled (or already was).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`order_already_dispatched`: it has shipped. `order_in_warehouse`: the warehouse is picking or packing it. `label_in_progress`: its label is being created right now; try again in a few seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`: `reason` is longer than 255 characters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"orders.write"}},"/v1/quotes":{"post":{"tags":["Quotes"],"summary":"Price a shipment","description":"**Scope:** `catalog.read`\n\nReturns every rate available to your account for this route and parcel, along with a `quote_id`.\n\nPass that `quote_id` and a `rate_id` to `POST /v1/shipments` to ship the option you showed your customer. Quotes expire after 30 minutes.\n\nAn empty `rates` list is a real answer, not an error: nothing available can carry that parcel to that address. Each service only prices parcels within its own weight and size limits — a parcel above all of them gets `rates: []`.\n\nA carrier that does not answer in time is not a \"no\". `complete: false` says at least one carrier did not answer, so a minute later there may be more options. When that leaves no rates at all, the answer is `503 carrier_unavailable` instead of an empty list: try again.\n\nRefused with `422`, naming the field: a postal code that does not exist (the same check as `GET /v1/coverage`), a state we do not recognise, and a parcel above 1,000 kg or 300 cm on any side, which no service carries.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["address_from","address_to","parcel"],"properties":{"address_from":{"type":"object","required":["postal_code"],"description":"Only the postal code is required: a missing city, state or colonia is filled from it. A fuller address can still price better.","properties":{"postal_code":{"type":"string","pattern":"^\\d{5}$","example":"44100"},"country_code":{"type":"string","default":"MX"},"street1":{"type":"string"},"colonia":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"}}},"address_to":{"type":"object","required":["postal_code"],"description":"Only the postal code is required: a missing city, state or colonia is filled from it.","properties":{"postal_code":{"type":"string","pattern":"^\\d{5}$","example":"45200"},"country_code":{"type":"string","default":"MX"},"street1":{"type":"string"},"colonia":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"}}},"parcel":{"type":"object","required":["length_cm","width_cm","height_cm","weight_kg"],"properties":{"length_cm":{"type":"number","minimum":0.1,"maximum":300,"example":20},"width_cm":{"type":"number","minimum":0.1,"maximum":300,"example":15},"height_cm":{"type":"number","minimum":0.1,"maximum":300,"example":10},"weight_kg":{"type":"number","minimum":0.001,"maximum":1000,"example":1.5}}}}}}}},"responses":{"200":{"description":"Rates, and a quote you can spend.","content":{"application/json":{"schema":{"type":"object","properties":{"quote_id":{"type":"string","format":"uuid"},"mode":{"type":"string","enum":["test","live"]},"expires_at":{"type":"string","format":"date-time"},"complete":{"type":"boolean","description":"`false`: at least one carrier did not answer, so there may be more options a minute later."},"rates":{"type":"array","items":{"$ref":"#/components/schemas/Rate"}}}}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The addresses or parcel cannot be priced — an unknown postal code, an unrecognised state, a parcel no service carries. `field` names the problem.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"`carrier_unavailable`: no rates came back because a carrier could not be reached. Not a coverage answer; try again in a minute.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"catalog.read"}},"/v1/shipments":{"get":{"tags":["Shipments"],"summary":"List shipments","description":"**Scope:** `shipments.read`\n\nNewest first. Only shipments from this key's mode. Filters are exact matches.","parameters":[{"name":"external_id","in":"query","schema":{"type":"string"},"description":"Your own order number."},{"name":"tracking_number","in":"query","schema":{"type":"string"}},{"name":"created_from","in":"query","schema":{"type":"string","format":"date-time"},"description":"Inclusive: shipments created at or after this instant."},{"name":"created_to","in":"query","schema":{"type":"string","format":"date-time"},"description":"Exclusive: shipments created before this instant, so consecutive windows never overlap."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"A page of shipments.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Shipment"}},"has_more":{"type":"boolean"},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}},"400":{"description":"A bad filter or a limit above 100.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"shipments.read"},"post":{"tags":["Shipments"],"summary":"Ship an order","description":"**Scope:** `shipments.write`\n\nBuys the label and charges your wallet.\n\n**Idempotent on `order_id`.** An order ships once; asking again returns the shipment that already exists with `200` instead of `201`, so a retry after a timeout can never buy a second label.\n\n**Allow up to 45 seconds.** Buying a label asks the carrier in real time and some carriers answer slowly; set your HTTP timeout to at least 45s. If you time out anyway, repeat the same request: it returns the label if it was bought.\n\nPass `quote_id` and `rate_id` together to ship a specific quoted rate. A quote ships only the route and parcel it priced: the order's destination postal code, weight and box sides (in any order) must match the quoted parcel, or the answer is `422 quote_mismatch` naming what differs. An order without a package (one shipped from a Wepaak warehouse, where the box is chosen at packing) is checked on destination and weight only: its weight is its products' weight, each piece at its product's weight in your catalogue, or 0.5 kg for a piece with none (a line that is not one of your products counts as 0.5 kg per unit). From your own warehouse an order needs a package: without one it is refused first, with `order_not_shippable` (`package_required`), before any quote is compared.\n\nYou can omit both ONLY if the order already has a courier — which means one of your automation rules assigned one when the order arrived. With no such rule there is nothing to ship it with, and this returns `422 carrier_required`. If you are integrating for the first time, quote and pass the rate: that is the path that always works.\n\nA `pending` status means the parcel is queued for pick and pack in a Wepaak warehouse; the label is minted then and reaches you by webhook. Nothing is wrong and there is nothing to retry.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["order_id"],"properties":{"order_id":{"type":"string","format":"uuid"},"quote_id":{"type":"string","format":"uuid","description":"Send with `rate_id`, or neither."},"rate_id":{"type":"string","example":"rate_4e800a8fc898d6a8"},"label_format":{"type":"string","enum":["standard","thermal"],"description":"`standard` prints on an office printer (letter page), `thermal` on a 4x6 label printer. Left out, your account's print setting in Wepaak is used. Applies to the national carriers; the Wepaak courier always produces its own label."}}}}}},"responses":{"200":{"description":"This order was already shipped — here is that shipment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Shipment"}}}},"201":{"description":"Shipped.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Shipment"}}}},"400":{"description":"`quote_expired`, or a `rate_id` that is not part of that quote.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"description":"`insufficient_balance`: the balance does not cover this label; the message says how much to add.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"`insufficient_scope`, `account_under_review` (shipments paused while Wepaak reviews the account) or `account_not_verified`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"The order cannot ship in its current state — cancelled, or not assigned to a warehouse — or `order_not_shippable` while an earlier request for the same order is still running (retry in a moment: it answers `200` with that shipment).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Something blocks the label: missing package dimensions, a stock shortfall, a rate whose COD setting does not match the order, or `quote_mismatch` (the quote was for another destination or parcel; `field` names it).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"If the message says the label was created but recording it failed, **do not retry** — contact support with the order id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"shipments.write"}},"/v1/shipments/{id}/label":{"get":{"tags":["Shipments"],"summary":"Download the label","description":"**Scope:** `shipments.read`\n\nThe label as a PDF. For the national carriers, the file the carrier produced, in the format chosen when it was bought (`label_format`). The Wepaak courier's label is converted to a 4x6 PDF. In the rare case the conversion is unavailable you receive its printable HTML page instead, so check `Content-Type`.\n\n**Test mode:** a sample 4x6 PDF marked TEST LABEL, so printing can be built before going live.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The label.","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}},"text/html":{"schema":{"type":"string"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"No such shipment, or `label_not_available` yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`shipment_cancelled`: the label must not be used.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"`carrier_unavailable`: try again in a few minutes.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"shipments.read"}},"/v1/shipments/{id}":{"get":{"tags":["Shipments"],"summary":"Fetch one shipment","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The shipment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Shipment"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"shipments.read","description":"**Scope:** `shipments.read`"}},"/v1/shipments/{id}/pickup-dates":{"get":{"tags":["Pickups"],"summary":"The carrier’s pickup dates for a shipment","description":"**Scope:** `shipments.read`\n\nThe days (and hours) the carrier can collect this shipment, as the carrier publishes them. Book one with POST /v1/pickups. `carrier_calendar: false` means this carrier publishes no calendar: book a weekday (after midday, the next one). A test key gets two simulated weekdays.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The pickup dates.","content":{"application/json":{"schema":{"type":"object","properties":{"shipment_id":{"type":"string","format":"uuid"},"carrier_calendar":{"type":"boolean"},"dates":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string","format":"date"},"start_hour":{"type":"string","example":"10:00"},"end_hour":{"type":"string","example":"19:00"}}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"shipments.read"}},"/v1/pickups":{"post":{"tags":["Pickups"],"summary":"Book a carrier pickup","description":"**Scope:** `shipments.write`\n\nAsks the carrier to collect a shipment on `date` (one of GET /v1/shipments/{id}/pickup-dates). The pickup window is the carrier’s for that day. Errors: `pickup_date_not_available` (422, `error.details.available_dates` lists the dates the carrier offers), `pickup_not_available` (422, a drop-off service), `pickup_already_scheduled` (409), `shipment_not_eligible` (409), `carrier_rejected` (422), `carrier_unavailable` (502/503, try again later). A test key books nothing: it accepts only the dates its pickup-dates lists, and answers `status: simulated`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["shipment_id","date"],"properties":{"shipment_id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date","example":"2026-11-18"},"packages":{"type":"integer","minimum":1,"maximum":100,"default":1},"weight_kg":{"type":"number","minimum":0.001,"maximum":10000},"instructions":{"type":"string","maxLength":500}}}}}},"responses":{"201":{"description":"Booked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pickup"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`pickup_already_scheduled`: this shipment already has a pickup. `shipment_not_eligible`: the shipment failed or is being cancelled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request` (the field is named), `pickup_date_not_available` (a past date, a weekend, or a day the carrier does not collect: use `GET /v1/shipments/{id}/pickup-dates`), `pickup_not_available` (a drop-off service), `carrier_rejected`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"shipments.write"},"get":{"tags":["Pickups"],"summary":"List your pickups","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Newest first.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Pickup"}},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}},"400":{"description":"`invalid_request`: `limit` or `offset` is not a valid number (the field is named).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"shipments.read","description":"**Scope:** `shipments.read`"}},"/v1/pickups/{id}":{"get":{"tags":["Pickups"],"summary":"Fetch one pickup","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The pickup.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pickup"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"shipments.read","description":"**Scope:** `shipments.read`"}},"/v1/cod/balance":{"get":{"tags":["Cash on delivery"],"summary":"COD totals","description":"**Scope:** `cod.read`\n\nHow many COD shipments, and how much, are in each status. `available_to_pay_out` is what could be paid out now, before any charges owed to Wepaak are kept back. Pass `pickup_address_id` for one client of yours (there is no `status` filter: every status is returned). A test key never reads real money: it gets empty lists and zero totals, marked `test: true` (sandbox shipments create no COD records).","parameters":[{"name":"pickup_address_id","in":"query","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Totals per status.","content":{"application/json":{"schema":{"type":"object","properties":{"currency":{"type":"string"},"totals":{"type":"object","additionalProperties":{"type":"object","properties":{"count":{"type":"integer"},"amount":{"type":"number"},"net":{"type":"number"}}}},"available_to_pay_out":{"type":"number"}}}}}},"400":{"description":"`invalid_request`: a filter is not valid (the field is named).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"cod.read"}},"/v1/cod/collections":{"get":{"tags":["Cash on delivery"],"summary":"COD records, one per shipment","description":"**Scope:** `cod.read`\n\nNewest dispatch first. Filter by status, shipment, order, your `external_id`, pickup address (one client of yours) or dispatch date. A test key never reads real money: it gets empty lists and zero totals, marked `test: true` (sandbox shipments create no COD records).","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["in_transit","collected","available","paid_out","returned"]}},{"name":"shipment_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"order_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"external_id","in":"query","schema":{"type":"string","maxLength":120}},{"name":"pickup_address_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"dispatched_from","in":"query","schema":{"type":"string","format":"date"}},{"name":"dispatched_to","in":"query","description":"A date includes that whole day; a date-time is inclusive.","schema":{"type":"string","format":"date"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"A page of records.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CodRecord"}},"has_more":{"type":"boolean"},"limit":{"type":"integer"},"offset":{"type":"integer"},"total":{"type":"integer"}}}}}},"400":{"description":"`invalid_request`: a filter is not valid (the field is named).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"cod.read"}},"/v1/cod/collections/{id}":{"get":{"tags":["Cash on delivery"],"summary":"Fetch one COD record","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The record.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodRecord"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"cod.read","description":"**Scope:** `cod.read`"}},"/v1/cod/payouts":{"get":{"tags":["Cash on delivery"],"summary":"List payouts","description":"**Scope:** `cod.read`\n\nNewest first. A test key never reads real money: it gets empty lists and zero totals, marked `test: true` (sandbox shipments create no COD records).","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["requested","processing","paid","failed","cancelled"]}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"A page of payouts.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CodPayout"}},"has_more":{"type":"boolean"},"limit":{"type":"integer"},"offset":{"type":"integer"},"total":{"type":"integer"}}}}}},"400":{"description":"`invalid_request`: a filter is not valid (the field is named).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"cod.read"},"post":{"tags":["Cash on delivery"],"summary":"Request a payout to a client of yours","description":"**Scope:** `cod.write`\n\nPays the COD of the shipments listed to the bank account in `recipient`: your client's. The charges your account owes Wepaak are withheld from it first, as for every payout (`withheld_charges`; `to_bank` is what is sent). The shipments are in the payout from this moment (`paid_out`); Wepaak reviews it and makes the transfer, and `cod.payout_updated` tells you when it is `processing` and `paid`.\n\nAll or nothing: if any shipment is not `available` or is already in a payout, the answer is `422 shipment_not_payable` listing each one with its status, and nothing is created.\n\nSend a `request_id` to make retries safe: the same one again (with the same `recipient` CLABE and name) returns the same payout with `200`, even if it was cancelled since (use a new one for a new payout). The same `request_id` with another recipient is `409 idempotency_mismatch`.\n\nNo payout is made while your account's wallet is negative (`422 wallet_negative`): that balance is owed to Wepaak.\n\n**Test keys** check everything (the CLABE included) and answer `201` with the payout that would be made, `test: true`, amounts 0. Nothing is written: sandbox shipments have no COD.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodPayoutRequest"}}}},"responses":{"200":{"description":"The same `request_id` again: the payout it already made.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodPayout"}}}},"201":{"description":"Requested. The payout, with its shipments.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodPayout"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"description":"`payout_conflict`: a shipment was taken by another payout meanwhile. `idempotency_mismatch`: this `request_id` was used for another recipient. Nothing was created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request` (the field is named: a CLABE whose check digit does not match, a repeated shipment id, a text field that is not a string…), `shipment_not_payable` (`error.details.shipments`), `payout_fully_withheld` (`error.details.collected` / `owed`), `payout_zero_amount`, `wallet_negative` (`error.details.wallet_balance`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"cod.write"}},"/v1/cod/payouts/{id}/cancel":{"post":{"tags":["Cash on delivery"],"summary":"Cancel a requested payout","description":"**Scope:** `cod.write`\n\nCancels a payout that is still `requested` and was requested through the API: its shipments are `available` again (`cod.status_changed`), the charges it withheld are owed again, and `cod.payout_updated` says `cancelled`. Once Wepaak is paying it (`processing`) it can no longer be cancelled here, nor can a payout your account asked for on the Wepaak website. A test key has no payouts: 404.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","maxLength":500}}}}}},"responses":{"200":{"description":"Cancelled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodPayout"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`payout_not_cancellable`: it is no longer `requested` (`error.details.status`), or it was not requested through the API (`error.details.reason`: `not_requested_through_api`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`: `reason` is not text or is longer than 500 characters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"cod.write"}},"/v1/cod/payouts/{id}":{"get":{"tags":["Cash on delivery"],"summary":"Fetch one payout, with its shipments","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The payout and every shipment it covered.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodPayout"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"cod.read","description":"**Scope:** `cod.read`"}},"/v1/shipments/{id}/cancel":{"post":{"tags":["Shipments"],"summary":"Cancel a shipment","description":"**Scope:** `shipments.write`\n\nThe same cancellation as in Wepaak, with the same rules: only before the carrier has the parcel, the label is cancelled with the carrier first, and the label price goes back to your wallet.\n\n**A late cancellation is reviewed.** A label cancelled after the free window answers `202` with status `cancellation_requested`: Wepaak checks with the carrier before refunding, and you receive `shipment.cancelled` if it is approved.\n\n**Idempotent.** A shipment that is already cancelled answers `200` again; nothing is refunded twice.\n\n**Shipping the goods again.** After a cancellation the order stays `dispatched`, and `POST /v1/shipments` for it returns this cancelled shipment: an order ships once. To send the goods again, create a new order (with a new `external_id`) and ship that.\n\n**Test mode:** no carrier and no money. The test shipment is cancelled and the test `shipment.status_changed` and `shipment.cancelled` webhooks are sent.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","maxLength":255}}}}}},"responses":{"200":{"description":"Cancelled (or already was).","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Shipment"},{"type":"object","properties":{"refunded_amount":{"type":"number","description":"MXN returned to your wallet. 0 in test mode, and on a repeat call."}}}]}}}},"202":{"description":"Cancelled late — under review. `status` is `cancellation_requested`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Shipment"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`shipment_not_cancellable`: the carrier already has it, or the service cannot be cancelled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`: `reason` is longer than 255 characters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"`carrier_unavailable`: the carrier did not confirm. Nothing changed — retry later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"shipments.write"}},"/v1/shipments/{id}/simulate":{"post":{"tags":["Shipments"],"summary":"Move a test shipment (test keys only)","description":"**Scope:** `shipments.write`\n\nBuild and test your tracking handling before going live. Moves a TEST shipment to `status` and sends the webhooks a real move would: always `shipment.status_changed`, plus `shipment.delivered` or `shipment.cancelled` for those. GET /v1/tracking then shows the steps. `status_detail` ends in \"(simulated)\".\n\nTwo rules are enforced, as for a real parcel: nothing after `delivered`, `returned` or `cancelled` (`409 shipment_finished`), and `cancelled` only before `picked_up`. Any other step may follow any other (`created` straight to `delivered`, `failed` back to `in_transit`…), so each webhook can be tested on its own; a real parcel usually goes `picked_up` → `in_transit` → `delivered`. A live key answers `403 test_mode_only`.\n\n**Automatic returns.** Moving a cash-on-delivery test shipment to `returned` opens its `cod_rejection` return, as a refused COD parcel does live: `in_transit`, every line of the order, back to the warehouse of the order, with its `return.created` webhook (test mode, no stock moves). A `cancellation` return, for a shipment cancelled after pickup, cannot be produced in test mode, because a test shipment is cancellable only before `picked_up`, as a real one is; it has the same shape, with `return_type: cancellation`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["picked_up","in_transit","delivered","returned","failed","cancelled"]}}}}}},"responses":{"200":{"description":"Moved; the webhooks are queued.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Shipment"},{"type":"object","properties":{"tracking_status":{"type":"string"},"previous_tracking_status":{"type":"string"}}}]}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`test_mode_only` with a live key, or `insufficient_scope`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`shipment_finished`, or `shipment_not_cancellable` for `cancelled` after pickup.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`status` is not one of the allowed values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"shipments.write"}},"/v1/tracking/{tracking_number}":{"get":{"tags":["Tracking"],"summary":"Where a parcel is","description":"**Scope:** `tracking.read`\n\nBranch on `status`, which is ours and stable. `status_detail` is the carrier's own wording — good to show a customer, unsafe to write code against, because carriers reword it without warning.\n\nAn empty `events` list means we have no step-by-step history for this carrier, not that nothing has happened.","parameters":[{"name":"tracking_number","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Current state.","content":{"application/json":{"schema":{"type":"object","properties":{"tracking_number":{"type":"string"},"mode":{"type":"string","enum":["test","live"]},"carrier":{"type":"string","nullable":true},"status":{"type":"string","enum":["created","picked_up","in_transit","delivered","returned","cancelled","failed","unknown"]},"status_detail":{"type":"string","nullable":true},"order_id":{"type":"string","format":"uuid","nullable":true},"external_id":{"type":"string","nullable":true,"description":"Your own order number, as you sent it on POST /v1/orders."},"events":{"type":"array","description":"Newest first, in test and live mode alike.","items":{"type":"object","properties":{"status":{"type":"string"},"description":{"type":"string","nullable":true},"note":{"type":"string","nullable":true},"occurred_at":{"type":"string","format":"date-time"}}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"tracking.read"}},"/v1/coverage":{"get":{"tags":["Lookups"],"summary":"Look up a postal code","description":"**Scope:** `catalog.read`\n\nValidates a Mexican postal code and returns its colonias, city and state — what a checkout needs to prefill an address.\n\nIt deliberately does not say which carriers serve the address: that depends on the parcel too, and only a quote can answer it honestly.","parameters":[{"name":"postal_code","in":"query","required":true,"schema":{"type":"string","pattern":"^\\d{5}$"},"example":"44160"}],"responses":{"200":{"description":"What we know about this postal code.","content":{"application/json":{"schema":{"type":"object","properties":{"postal_code":{"type":"string"},"known":{"type":"boolean","description":"False for a code that does not exist. Not an error."},"state":{"type":"string","nullable":true},"municipality":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"colonias":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string"}}}}}}}}},"400":{"description":"Not a 5-digit postal code.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"catalog.read"}},"/v1/carriers":{"get":{"tags":["Lookups"],"summary":"Carriers available to you","description":"**Scope:** `catalog.read`\n\nOnly carriers that can actually appear in your quotes — anything disabled platform-wide or by you is left out.","responses":{"200":{"description":"Your carriers.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"carrier":{"type":"string"},"name":{"type":"string"}}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"catalog.read"}},"/v1/wallet":{"get":{"tags":["Lookups"],"summary":"Your balance","description":"**Scope:** `wallet.read`\n\nSo you can warn before a shipment fails for want of funds. Test keys see the real balance but never spend it.","responses":{"200":{"description":"Current balance.","content":{"application/json":{"schema":{"type":"object","properties":{"balance":{"type":"number","example":431.68},"currency":{"type":"string","example":"MXN"},"mode":{"type":"string","enum":["test","live"]}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"wallet.read"}},"/v1/webhooks":{"post":{"tags":["Webhooks"],"summary":"Register an endpoint","description":"**Scope:** `webhooks.manage`\n\nWe POST to your URL when something happens. Idempotent on the URL: registering the same one twice returns the existing endpoint rather than delivering every event to you twice.\n\n**The signing secret is shown once, here.** Verify it on every delivery: we send `Wepaak-Signature: t=<unix>,v1=<hex>`, where the hex is HMAC-SHA256 of `\"<t>.<raw body>\"` using that secret. Compare in constant time, and reject a timestamp too far from now.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri","description":"Must be `https://` and must resolve to a public address. Loopback, private (10/172.16/192.168), link-local and cloud-metadata addresses are refused, at registration and again on every delivery. Redirects are followed at most 3 hops and each hop is checked the same way."},"events":{"type":"array","items":{"type":"string","enum":["order.dispatched","shipment.status_changed","shipment.delivered","shipment.cancelled","wallet.low_balance","inbound.received","inbound.status_changed","transfer.status_changed","return.created","return.awaiting_decision","return.status_changed","pickup.created","pickup.updated","pickup.cancelled","cod.status_changed","cod.payout_updated"]},"description":"Leave empty to receive everything, except `cod.*` and `wallet.low_balance`, which come only when named. Naming an event needs the key to hold its read scope: `order.*` and `shipment.*` any of `orders.read`, `shipments.read`, `tracking.read`; `pickup.*` `shipments.read`; `wallet.*` `wallet.read`; `inbound.*` `inbounds.read`; `transfer.*` `transfers.read`; `return.*` `returns.read`; `cod.*` `cod.read`. Otherwise `403 insufficient_scope`."}}}}}},"responses":{"200":{"description":"This URL was already registered — here it is, WITHOUT the secret: it is shown only when the endpoint is created. Lost it? Delete the endpoint and register it again. The answer says so too: `already_registered: true` and a `message`.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WebhookEndpoint"},{"type":"object","properties":{"already_registered":{"type":"boolean","enum":[true]},"message":{"type":"string","description":"What to do to get a new secret."}}}]}}}},"201":{"description":"Registered. The `secret` appears here and nowhere else.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"mode":{"type":"string","enum":["test","live"]},"active":{"type":"boolean"},"secret":{"type":"string","example":"whsec_…"},"created_at":{"type":"string","format":"date-time"}}}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The URL is not https, or an event name is not one we send.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"webhooks.manage"},"get":{"tags":["Webhooks"],"summary":"List your endpoints","description":"**Scope:** `webhooks.manage`\n\nEndpoints for this key's mode. Secrets are not included — they exist only in the response that created them.","responses":{"200":{"description":"Your endpoints.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEndpoint"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"webhooks.manage"}},"/v1/webhooks/{id}":{"delete":{"tags":["Webhooks"],"summary":"Remove an endpoint","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"204":{"description":"Removed. Deliveries stop immediately."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"webhooks.manage","description":"**Scope:** `webhooks.manage`"}},"/v1/webhooks/{id}/deliveries":{"get":{"tags":["Webhooks"],"summary":"Delivery log","description":"**Scope:** `webhooks.manage`\n\nWhat we sent, what you answered, and how many attempts it took. The first place to look when an endpoint is not receiving.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Recent deliveries.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"event":{"type":"string","example":"order.dispatched"},"status":{"type":"string","example":"delivered"},"attempts":{"type":"integer"},"response_status":{"type":"integer","nullable":true,"description":"The HTTP status your endpoint answered."},"error":{"type":"string","nullable":true},"delivered_at":{"type":"string","format":"date-time","nullable":true},"created_at":{"type":"string","format":"date-time"}}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"webhooks.manage"}},"/v1/warehouses":{"get":{"tags":["Inventory"],"summary":"List your warehouses","description":"**Scope:** `inventory.read`\n\nYour own warehouses and the Wepaak warehouses that hold your stock. Readable with a test key too: these are your real warehouses, products and stock, and reading changes nothing.","responses":{"200":{"description":"Your warehouses.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Warehouse"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"inventory.read"},"post":{"tags":["Inventory"],"summary":"Add a pickup address","description":"**Scope:** `orders.write`\n\nAdds a pickup address you run, for orders that ship from it (`warehouse_id` on POST /v1/orders). For platforms whose users each ship from their own place. If the same address (street, interior and postal code; case and accents ignored) is already on your account, that one is returned with **200** instead of a duplicate; a new one answers **201**. You can also skip this and send `address_from` on each order. With a **test key** the address is a test one (`test: true`): only test keys see it and only test orders ship from it, so trying an integration never adds to your real pickup addresses.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PickupAddressWrite"}}}},"responses":{"200":{"description":"This address was already on your account: here it is.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Warehouse"}}}},"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Warehouse"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`: a field is missing or not valid (the field is named), or the postal code is not a real Mexican one.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"orders.write"}},"/v1/warehouses/{id}":{"patch":{"tags":["Inventory"],"summary":"Edit or switch off a pickup address","description":"**Scope:** `orders.write`\n\nChanges only the fields you send. `status`: `paused` to stop using it, `active` to use it again. Only addresses you run (`operated_by: self`) can be changed; a Wepaak warehouse answers **409** `not_editable`. A required field (name, phone, street1, city, state) cannot be sent empty. Moving or re-activating it onto the address of another of your active ones answers **409** `duplicate_address`, with that one in `error.details.warehouse_id`. A test key changes only the test addresses it made: a real one answers **403** `live_key_required`. An address created through the API can be changed with `orders.write`; one set up in Wepaak needs a key with `inventory.write` (otherwise **403** `insufficient_scope`).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/PickupAddressWrite"}],"description":"Every field optional here.","properties":{"status":{"type":"string","enum":["active","paused"]}}}}}},"responses":{"200":{"description":"The pickup address, as it is now.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Warehouse"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`live_key_required`: a test key on one of your real pickup addresses. `insufficient_scope`: the key lacks `orders.write`, or the address was set up in Wepaak and the key lacks `inventory.write`.","content":{"application/json":{"schema":{"type":"object"}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`not_editable`: a Wepaak warehouse. `duplicate_address`: another active one is at that address.","content":{"application/json":{"schema":{"type":"object"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`: a field is not valid (the field is named), or the postal code is not a real Mexican one.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"orders.write"}},"/v1/inventory":{"get":{"tags":["Inventory"],"summary":"Stock per product and warehouse","description":"**Scope:** `inventory.read`\n\nOne row per product and warehouse, ordered by SKU. Readable with a test key too: these are your real warehouses, products and stock, and reading changes nothing.","parameters":[{"name":"sku","in":"query","schema":{"type":"string"},"description":"Only this SKU."},{"name":"warehouse_id","in":"query","schema":{"type":"string","format":"uuid"},"description":"Only this warehouse."},{"name":"low_stock","in":"query","schema":{"type":"boolean"},"description":"`true`: only rows whose available stock is at or under the product's low-stock threshold."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"A page of stock rows.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/InventoryRow"}},"has_more":{"type":"boolean"},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}},"400":{"description":"A filter was not understood. `field` names it. A limit above 100 is refused rather than quietly reduced.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"inventory.read"}},"/v1/products":{"get":{"tags":["Inventory"],"summary":"List products","description":"**Scope:** `inventory.read`\n\nYour catalog, ordered by SKU, with stock totals over every warehouse. Readable with a test key too: these are your real warehouses, products and stock, and reading changes nothing.","parameters":[{"name":"sku","in":"query","schema":{"type":"string"},"description":"Only this SKU."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"A page of products.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"has_more":{"type":"boolean"},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}},"400":{"description":"A filter was not understood. `field` names it. A limit above 100 is refused rather than quietly reduced.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"inventory.read"},"post":{"tags":["Inventory"],"summary":"Create a product","description":"**Scope:** `inventory.write`\n\nSo an inbound can carry a SKU that is new to Wepaak. **Idempotent on `sku`:** a SKU you already have returns that product with `200`, unchanged (use PATCH to change it). Your catalog is the same in both modes, so this needs a **live key**: a test key gets `403 live_key_required`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["sku","name"],"properties":{"sku":{"type":"string","maxLength":120,"description":"Unique in your account."},"name":{"type":"string","maxLength":255},"description":{"type":"string","maxLength":5000},"barcode":{"type":"string","maxLength":60,"description":"EAN / UPC."},"category":{"type":"string","maxLength":120},"status":{"type":"string","enum":["active","paused","discontinued"],"default":"active"},"declared_value":{"type":"number","minimum":0},"weight_kg":{"type":"number","minimum":0,"maximum":1000},"dimensions_cm":{"type":"object","properties":{"length":{"type":"number","minimum":0,"maximum":300},"width":{"type":"number","minimum":0,"maximum":300},"height":{"type":"number","minimum":0,"maximum":300}}},"sat_code":{"type":"string","maxLength":20},"manages_expiry":{"type":"boolean","description":"It has a shelf life: receiving records lot and expiry, and stock leaves soonest-expiry first."},"low_stock_threshold":{"type":"integer","minimum":0,"nullable":true,"description":"Drives `GET /v1/inventory?low_stock=true`."}}}}}},"responses":{"200":{"description":"You already have this SKU: that product.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`live_key_required`, or `insufficient_scope`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`sku_unavailable`: the SKU belongs to a product you removed, or one merged into another.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`, with `field`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"inventory.write"}},"/v1/products/{id}":{"get":{"tags":["Inventory"],"summary":"Fetch one product","description":"**Scope:** `inventory.read`\n\nWith its stock in each warehouse. Readable with a test key too: these are your real warehouses, products and stock, and reading changes nothing.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The product.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"inventory.read"},"patch":{"tags":["Inventory"],"summary":"Edit a product","description":"**Scope:** `inventory.write`\n\nSend only what changes. Once Wepaak holds the product it measures it, so weight and dimensions can then only change in Wepaak (`409 dimensions_locked`). Your catalog is the same in both modes, so this needs a **live key**: a test key gets `403 live_key_required`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"sku":{"type":"string","maxLength":120,"description":"Changing it does not change documents already created."},"name":{"type":"string","maxLength":255},"description":{"type":"string","maxLength":5000},"barcode":{"type":"string","maxLength":60,"description":"EAN / UPC."},"category":{"type":"string","maxLength":120},"status":{"type":"string","enum":["active","paused","discontinued"]},"declared_value":{"type":"number","minimum":0},"weight_kg":{"type":"number","minimum":0,"maximum":1000},"dimensions_cm":{"type":"object","properties":{"length":{"type":"number","minimum":0,"maximum":300},"width":{"type":"number","minimum":0,"maximum":300},"height":{"type":"number","minimum":0,"maximum":300}}},"sat_code":{"type":"string","maxLength":20},"manages_expiry":{"type":"boolean","description":"It has a shelf life: receiving records lot and expiry, and stock leaves soonest-expiry first."},"low_stock_threshold":{"type":"integer","minimum":0,"nullable":true,"description":"Drives `GET /v1/inventory?low_stock=true`."}}}}}},"responses":{"200":{"description":"The product as it is now.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`live_key_required`, or `insufficient_scope`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`sku_taken`, `sku_unavailable` or `dimensions_locked`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`, with `field`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"inventory.write"}},"/v1/products/{id}/movements":{"get":{"tags":["Inventory"],"summary":"Stock history of a product","description":"**Scope:** `inventory.read`\n\nThe stock ledger for one product, newest first: receipts, dispatches, transfers, returns, corrections. Readable with a test key too: these are your real warehouses, products and stock, and reading changes nothing.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"warehouse_id","in":"query","schema":{"type":"string","format":"uuid"},"description":"Only this warehouse."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"A page of movements.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StockMovement"}},"has_more":{"type":"boolean"},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}},"400":{"description":"A filter was not understood. `field` names it. A limit above 100 is refused rather than quietly reduced.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"inventory.read"}},"/v1/inbounds":{"get":{"tags":["Inbounds"],"summary":"List inbounds","description":"**Scope:** `inbounds.read`\n\nNewest first. Only documents from this key's mode are listed: a test key sees what it created in test mode.","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["scheduled","in_transit","pending_validation","validated","with_discrepancy","cancelled"]}},{"name":"warehouse_id","in":"query","schema":{"type":"string","format":"uuid"},"description":"Destination warehouse."},{"name":"external_id","in":"query","schema":{"type":"string"},"description":"Your own reference."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"A page of inbounds.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Inbound"}},"has_more":{"type":"boolean"},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}},"400":{"description":"A filter was not understood. `field` names it. A limit above 100 is refused rather than quietly reduced.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"inbounds.read"},"post":{"tags":["Inbounds"],"summary":"Create an inbound","description":"**Scope:** `inbounds.write`\n\nAnnounce goods you are sending into a warehouse. The pieces show as `incoming` at the destination until it is received. Every SKU must already be one of your products. **Idempotent on `external_id`.** With a test key the document is saved in test mode and **no stock moves**: no incoming, no reservation, nothing received, nothing billed.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["destination_warehouse_id","items"],"properties":{"destination_warehouse_id":{"type":"string","format":"uuid","description":"From `GET /v1/warehouses`."},"items":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","required":["sku","quantity"],"properties":{"sku":{"type":"string","maxLength":100,"description":"One of your SKUs (`GET /v1/products`). Each SKU once per request."},"quantity":{"type":"integer","minimum":1,"maximum":100000},"lot_code":{"type":"string","maxLength":100,"description":"For products with a shelf life: the batch."},"expiry_date":{"type":"string","format":"date","description":"For products with a shelf life, as YYYY-MM-DD."}}}},"scheduled_date":{"type":"string","format":"date","description":"When it should arrive, as YYYY-MM-DD."},"logistics_method":{"type":"string","enum":["own_means","wepaak_carrier"],"default":"own_means","description":"`wepaak_carrier`: it travels on a Wepaak shipment (link it with `shipment_id`, now or later)."},"shipment_id":{"type":"string","format":"uuid","description":"A shipment of yours that carries it."},"tracking_number":{"type":"string","maxLength":100},"notes":{"type":"string","maxLength":2000},"external_id":{"type":"string","maxLength":255,"description":"Your own reference, unique in your account and mode. Sending one already used returns that document with `200` instead of creating another."}}}}}},"responses":{"200":{"description":"Already created with this `external_id`: that inbound.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inbound"}}}},"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inbound"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request` (a field, named in `field`), `unknown_warehouse`, `unknown_sku` (`field` is `items[n].sku`) or `unknown_shipment`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"inbounds.write"}},"/v1/inbounds/{id}":{"get":{"tags":["Inbounds"],"summary":"Fetch one inbound","description":"**Scope:** `inbounds.read`\n\nAn inbound of the other mode answers 404.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The inbound.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inbound"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"inbounds.read"},"patch":{"tags":["Inbounds"],"summary":"Edit an inbound","description":"**Scope:** `inbounds.write`\n\nSend only what changes. `items` replaces every line and is accepted only while `scheduled`; the incoming stock follows it. Date, tracking, shipment and notes can change until it is received. `status: in_transit` tells us the goods are on their way.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","required":["sku","quantity"],"properties":{"sku":{"type":"string","maxLength":100,"description":"One of your SKUs (`GET /v1/products`). Each SKU once per request."},"quantity":{"type":"integer","minimum":1,"maximum":100000},"lot_code":{"type":"string","maxLength":100,"description":"For products with a shelf life: the batch."},"expiry_date":{"type":"string","format":"date","description":"For products with a shelf life, as YYYY-MM-DD."}}}},"scheduled_date":{"type":"string","format":"date"},"shipment_id":{"type":"string","format":"uuid"},"tracking_number":{"type":"string","maxLength":100},"notes":{"type":"string","maxLength":2000},"status":{"type":"string","enum":["in_transit"]}}}}}},"responses":{"200":{"description":"The inbound as it is now.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inbound"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`invalid_state`: it is not in a status that allows this; the message says which it is in.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`, `unknown_sku` or `unknown_shipment`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"inbounds.write"}},"/v1/transfers":{"get":{"tags":["Transfers"],"summary":"List transfers","description":"**Scope:** `transfers.read`\n\nNewest first. Only documents from this key's mode are listed: a test key sees what it created in test mode.","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["requested","approved","in_transit","sent","received","with_discrepancy","cancelled"]}},{"name":"warehouse_id","in":"query","schema":{"type":"string","format":"uuid"},"description":"Origin or destination."},{"name":"external_id","in":"query","schema":{"type":"string"},"description":"Your own reference."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"A page of transfers.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Transfer"}},"has_more":{"type":"boolean"},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}},"400":{"description":"A filter was not understood. `field` names it. A limit above 100 is refused rather than quietly reduced.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"transfers.read"},"post":{"tags":["Transfers"],"summary":"Create a transfer","description":"**Scope:** `transfers.write`\n\nMove stock between two of your warehouses. Refused when the origin does not have the pieces **available** (on hand minus what is already reserved). From then on they are reserved at the origin and `incoming` at the destination.\n\n- Between your own warehouses, or out of a Wepaak warehouse: it starts `in_transit`.\n- From your own warehouse into a Wepaak warehouse: it starts `requested` and waits for Wepaak's approval.\n\n**Idempotent on `external_id`.** With a test key the document is saved in test mode and **no stock moves**: no incoming, no reservation, nothing received, nothing billed.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["origin_warehouse_id","destination_warehouse_id","items"],"properties":{"origin_warehouse_id":{"type":"string","format":"uuid"},"destination_warehouse_id":{"type":"string","format":"uuid"},"items":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","required":["sku","quantity"],"properties":{"sku":{"type":"string","maxLength":100,"description":"One of your SKUs (`GET /v1/products`). Each SKU once per request."},"quantity":{"type":"integer","minimum":1,"maximum":100000}}}},"logistics_method":{"type":"string","enum":["own_means","wepaak_carrier"],"default":"own_means"},"shipment_id":{"type":"string","format":"uuid","description":"A shipment of yours that carries it."},"tracking_number":{"type":"string","maxLength":100},"notes":{"type":"string","maxLength":2000},"external_id":{"type":"string","maxLength":255,"description":"Your own reference, unique in your account and mode. Sending one already used returns that document with `200` instead of creating another."}}}}}},"responses":{"200":{"description":"Already created with this `external_id`: that transfer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transfer"}}}},"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transfer"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request` (also when origin and destination are the same), `unknown_warehouse`, `unknown_sku`, `unknown_shipment`, or `insufficient_stock` (`field` is `items[n].quantity`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"transfers.write"}},"/v1/transfers/{id}":{"get":{"tags":["Transfers"],"summary":"Fetch one transfer","description":"**Scope:** `transfers.read`\n\nA transfer of the other mode answers 404.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The transfer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transfer"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"transfers.read"},"patch":{"tags":["Transfers"],"summary":"Edit a transfer","description":"**Scope:** `transfers.write`\n\nThe shipment carrying it, its tracking number, notes. Warehouses and lines cannot change: cancel it and create another.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"shipment_id":{"type":"string","format":"uuid"},"tracking_number":{"type":"string","maxLength":100},"notes":{"type":"string","maxLength":2000}}}}}},"responses":{"200":{"description":"The transfer as it is now.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transfer"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`invalid_state`: it is not in a status that allows this; the message says which it is in.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request` or `unknown_shipment`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"transfers.write"}},"/v1/returns":{"get":{"tags":["Returns"],"summary":"List returns","description":"**Scope:** `returns.read`\n\nNewest first, including the returns created automatically (COD rejected, cancelled after pickup). Only documents from this key's mode are listed: a test key sees what it created in test mode.","parameters":[{"name":"type","in":"query","schema":{"type":"string","enum":["cod_rejection","cancellation","post_delivery"]}},{"name":"status","in":"query","schema":{"type":"string","enum":["requested","label_generated","in_transit","received","pending_approval","graded","restocked","written_off","cancelled"]}},{"name":"order_id","in":"query","schema":{"type":"string","format":"uuid"},"description":"Returns of this order."},{"name":"warehouse_id","in":"query","schema":{"type":"string","format":"uuid"},"description":"Destination warehouse."},{"name":"external_id","in":"query","schema":{"type":"string"},"description":"Your own reference."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"A page of returns.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Return"}},"has_more":{"type":"boolean"},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}},"400":{"description":"A filter was not understood. `field` names it. A limit above 100 is refused rather than quietly reduced.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-required-scope":"returns.read"},"post":{"tags":["Returns"],"summary":"Open a return after delivery","description":"**Scope:** `returns.write`\n\nFor goods a customer sends back after delivery. Name the order (`order_id`) or the shipment that delivered it (`shipment_id`, the `id` POST /v1/shipments answered with): every line must be on that order.\n\n**How many:** the cap is per **order**, not per return. Every return of the order that is not cancelled counts, automatic ones too, so two returns of 1 on a 2-unit order leave no room for a third (`quantity_exceeds_order`).\n\n**When:** the order must have **shipped** (`order_not_shipped` otherwise). Delivery is not required: tracking can lag behind the customer.\n\nThe pieces show as `incoming` at the warehouse until it arrives, which defaults to the warehouse the order shipped from.\n\nReturns for refused cash-on-delivery parcels and for shipments cancelled after pickup are created **automatically**; you do not open those.\n\n**Idempotent on `external_id`.** With a test key the document is saved in test mode and **no stock moves**: no incoming, no reservation, nothing received, nothing billed. A test key can only return a test order.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"order_id":{"type":"string","format":"uuid","description":"The order. Send this or `shipment_id`."},"shipment_id":{"type":"string","format":"uuid","description":"The shipment that delivered it. Send this or `order_id`."},"items":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","required":["sku","quantity"],"properties":{"sku":{"type":"string","maxLength":100,"description":"One of your SKUs (`GET /v1/products`). Each SKU once per request."},"quantity":{"type":"integer","minimum":1,"maximum":100000}}}},"reason":{"type":"string","maxLength":500},"destination_warehouse_id":{"type":"string","format":"uuid","description":"Where it goes back to. Defaults to the warehouse the order shipped from."},"return_tracking_number":{"type":"string","maxLength":100,"description":"The tracking number of the parcel coming back, if it has one."},"external_id":{"type":"string","maxLength":255,"description":"Your own reference, unique in your account and mode. Sending one already used returns that document with `200` instead of creating another."}}}}}},"responses":{"200":{"description":"Already opened with this `external_id`: that return.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Return"}}}},"201":{"description":"Opened.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Return"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`, `unknown_order`, `order_not_shipped`, `unknown_warehouse`, `unknown_sku`, `item_not_in_order` or `quantity_exceeds_order` (`field` names the line).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"returns.write"}},"/v1/returns/{id}":{"get":{"tags":["Returns"],"summary":"Fetch one return","description":"**Scope:** `returns.read`\n\nA return of the other mode answers 404.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The return.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Return"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"returns.read"}},"/v1/inbounds/{id}/cancel":{"post":{"tags":["Inbounds"],"summary":"Cancel an inbound","description":"**Scope:** `inbounds.write`\n\nBefore it is received. The incoming stock it announced is released. **Idempotent:** cancelling one already cancelled returns it again with `200`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The cancelled inbound.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inbound"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`invalid_state`: it is not in a status that allows this; the message says which it is in.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"inbounds.write"}},"/v1/inbounds/{id}/receive":{"post":{"tags":["Inbounds"],"summary":"Receive an inbound in your own warehouse","description":"**Scope:** `inbounds.write`\n\nCount what arrived, per SKU: `good` pieces enter stock, `damaged` ones are recorded and not stocked. A line you leave out arrived as 0. When a line differs from what was expected, the inbound ends as `with_discrepancy`.\n\n**Damaged pieces count as arrived.** A line of 2 received as 1 `good` + 1 `damaged` matches what was expected, so the inbound is `validated`, with the damaged piece recorded on the line and kept out of stock. `with_discrepancy` means a different NUMBER of pieces arrived (good + damaged is not what was expected).\n\nOnly for your own warehouses: at a Wepaak warehouse Wepaak counts the goods, and this answers `403 wepaak_only`. With a test key nothing enters stock; for a test inbound into a Wepaak warehouse use `simulate`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","minItems":1,"items":{"type":"object","required":["sku","good"],"properties":{"sku":{"type":"string","description":"A SKU on this inbound."},"good":{"type":"integer","minimum":0},"damaged":{"type":"integer","minimum":0,"default":0}}}}}}}}},"responses":{"200":{"description":"The received inbound.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inbound"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`wepaak_only`: the warehouse is Wepaak's; or `insufficient_scope`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`already_received`, or `invalid_state` (cancelled).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request` (for example more pieces than expected) or `item_not_in_inbound`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"inbounds.write"}},"/v1/inbounds/{id}/packing-list":{"get":{"tags":["Inbounds"],"summary":"Packing list (PDF)","description":"**Scope:** `inbounds.read`\n\nThe sheet that goes inside the box, in Spanish for the people who open it. The same one the web prints.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"A PDF.","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"x-required-scope":"inbounds.read"}},"/v1/inbounds/{id}/simulate":{"post":{"tags":["Inbounds"],"summary":"Simulate the warehouse (test mode)","description":"**Scope:** `inbounds.write`\n\n**Test keys only.** Moves a test inbound as if its goods travelled and arrived:\n- `in_transit`: on its way (from `scheduled`);\n- `validated`: every line arrived in full and good;\n- `with_discrepancy`: the first line arrived one piece short.\n\nNothing moves in stock.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["in_transit","validated","with_discrepancy"]}}}}}},"responses":{"200":{"description":"The inbound after the step.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inbound"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`test_mode_only` with a live key, or `insufficient_scope`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`invalid_state`: it is not in a status that allows this; the message says which it is in.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`: an unknown `status`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"inbounds.write"}},"/v1/returns/{id}/decision":{"post":{"tags":["Returns"],"summary":"Decide on damaged pieces","description":"**Scope:** `returns.write`\n\nFor a return in `pending_approval`: put the damaged pieces back in stock (`restock`) or write them off (`trash`). The good pieces went back into stock when the return was checked. The return ends `restocked`, `written_off`, or `graded` when it is a mix.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["decision"],"properties":{"decision":{"type":"string","enum":["restock","trash"]},"reason":{"type":"string","maxLength":500}}}}}},"responses":{"200":{"description":"The return after the decision.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Return"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`invalid_state`: it is not waiting for a decision.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"returns.write"}},"/v1/returns/{id}/cancel":{"post":{"tags":["Returns"],"summary":"Cancel a return","description":"**Scope:** `returns.write`\n\nOnly a return you opened (`post_delivery`), before it arrives. Its incoming stock is released. Automatic returns are real parcels on their way back and cannot be cancelled. **Idempotent.**","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The cancelled return.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Return"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`invalid_state`: it is not in a status that allows this; the message says which it is in.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"returns.write"}},"/v1/returns/{id}/simulate":{"post":{"tags":["Returns"],"summary":"Simulate the warehouse (test mode)","description":"**Scope:** `returns.write`\n\n**Test keys only.** Moves a test return as if it travelled and was checked:\n- `in_transit`: on its way back;\n- `restocked`: everything arrived good;\n- `pending_approval`: one piece of the first line arrived damaged and waits for your decision.\n\nNothing moves in stock.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["in_transit","restocked","pending_approval"]}}}}}},"responses":{"200":{"description":"The return after the step.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Return"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`test_mode_only` with a live key, or `insufficient_scope`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`invalid_state`: it is not in a status that allows this; the message says which it is in.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`: an unknown `status`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"returns.write"}},"/v1/transfers/{id}/cancel":{"post":{"tags":["Transfers"],"summary":"Cancel a transfer","description":"**Scope:** `transfers.write`\n\nBefore it ships. The reservation at the origin and the incoming stock at the destination are released. **Idempotent.**","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The cancelled transfer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transfer"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`invalid_state`: it is not in a status that allows this; the message says which it is in.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"transfers.write"}},"/v1/transfers/{id}/receive":{"post":{"tags":["Transfers"],"summary":"Receive a transfer in your own warehouse","description":"**Scope:** `transfers.write`\n\nHow many pieces of each SKU arrived; a line you leave out arrived as 0. They enter stock at the destination, and the origin gives up what it sent. When a line differs from what was sent, it ends `with_discrepancy`.\n\nOnly into your own warehouses: Wepaak receives at its own (`403 wepaak_only`). A transfer leaving a Wepaak warehouse can be received once Wepaak has shipped it (`shipped_at` is set).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","minItems":1,"items":{"type":"object","required":["sku","received"],"properties":{"sku":{"type":"string","description":"A SKU on this transfer."},"received":{"type":"integer","minimum":0}}}}}}}}},"responses":{"200":{"description":"The received transfer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transfer"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`wepaak_only`: the destination is a Wepaak warehouse; or `insufficient_scope`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`already_received`, or `invalid_state` (waiting for approval, or not shipped by Wepaak yet).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request` (for example more pieces than were sent) or `item_not_in_transfer`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"transfers.write"}},"/v1/transfers/{id}/simulate":{"post":{"tags":["Transfers"],"summary":"Simulate Wepaak and the warehouses (test mode)","description":"**Scope:** `transfers.write`\n\n**Test keys only.** Moves a test transfer:\n- `approved`: Wepaak approves a transfer into its warehouse (from `requested`);\n- `shipped`: it leaves the origin (`sent`, with `shipped_at` set);\n- `received`: every line arrived in full;\n- `with_discrepancy`: the first line arrived one piece short.\n\nNothing moves in stock.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["approved","shipped","received","with_discrepancy"]}}}}}},"responses":{"200":{"description":"The transfer after the step.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transfer"}}}},"400":{"description":"`invalid_request`: the body is not valid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`test_mode_only` with a live key, or `insufficient_scope`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`invalid_state`: it is not in a status that allows this; the message says which it is in.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"`invalid_request`: the body was sent without `Content-Type: application/json`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`invalid_request`: an unknown `status`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"transfers.write"}}}}