{"openapi":"3.1.0","info":{"title":"OrderKrab API","version":"1.0.0","summary":"Orders, shipments, labels, returns, inventory and analytics of an OrderKrab organization.","contact":{"name":"OrderKrab support","email":"info@orderkrab.com","url":"https://orderkrab.com/contact"},"description":"The OrderKrab API gives your own systems and AI assistants such as Claude access to one OrderKrab organization:\nits orders, shipments and labels, returns, products, stock and fulfillment analytics. It is included in every plan.\n\nBase URL: `https://api.orderkrab.com/api/v1`. Requests and responses are JSON, except label downloads.\n\n# Quickstart\n\n1. In OrderKrab, open **Settings → API \u0026 Apps** and click **Create API key**. Give it a name, and tick\n   **Allow changes (write access)** only if the key has to change data. Copy the key: it is shown once.\n2. Send the key as a bearer token:\n\n```bash\ncurl \"https://api.orderkrab.com/api/v1/orders?status=pending_fulfillment\u0026per_page=5\" \\\n  -H \"Authorization: Bearer ok_your_key\"\n```\n\n3. Look up one order by its OrderKrab id, or search by order number, customer or tracking code:\n\n```bash\ncurl \"https://api.orderkrab.com/api/v1/orders?query=1001\" -H \"Authorization: Bearer ok_your_key\"\ncurl \"https://api.orderkrab.com/api/v1/orders/8429\" -H \"Authorization: Bearer ok_your_key\"\n```\n\n4. Ship an order with a write key: create the label, download it, then mark the order fulfilled.\n\n```bash\ncurl -X POST \"https://api.orderkrab.com/api/v1/orders/8429/label\" -H \"Authorization: Bearer ok_your_key\"\ncurl -o label.pdf \"https://api.orderkrab.com/api/v1/orders/8429/label.pdf\" -H \"Authorization: Bearer ok_your_key\"\ncurl -X POST \"https://api.orderkrab.com/api/v1/orders/8429/fulfill\" -H \"Authorization: Bearer ok_your_key\"\n```\n\n# Authentication\n\nEvery request carries `Authorization: Bearer \u003ctoken\u003e` and acts on exactly one organization, the one the\ncredential belongs to. There is no organization parameter.\n\n## API keys\n\nAPI keys (`ok_…`) are for your own servers and scripts. Owners and admins create and revoke them in\n**Settings → API \u0026 Apps**.\n\n- A key is read-only unless write access was allowed when it was created.\n- A key acts as the person who created it: changes it makes appear in the order history as **API** with\n  that person's email.\n- A key stops working when it is revoked, or when its creator leaves the organization or is no longer an\n  owner or admin.\n- Keep keys on the server. Anyone holding a key can use it.\n\n## OAuth 2.1\n\nApps that let each person sign in with their own OrderKrab account, such as Claude, use OAuth 2.1 with the\nauthorization code flow and PKCE. Scopes are `read` and `write`.\n\n| Step | Endpoint |\n| --- | --- |\n| Discovery | `GET https://api.orderkrab.com/.well-known/oauth-authorization-server` and `GET https://api.orderkrab.com/.well-known/oauth-protected-resource` |\n| Register a client (RFC 7591) | `POST https://api.orderkrab.com/oauth/register` with `redirect_uris`, `client_name` and `token_endpoint_auth_method` (`none`, `client_secret_post` or `client_secret_basic`) |\n| Ask the person | `GET https://api.orderkrab.com/oauth/authorize` with `response_type=code`, `client_id`, `redirect_uri`, `code_challenge` (S256), `state` and `scope=read write` |\n| Get tokens | `POST https://api.orderkrab.com/oauth/token` with `grant_type=authorization_code`, `code`, `redirect_uri` and `code_verifier` |\n| Refresh | `POST https://api.orderkrab.com/oauth/token` with `grant_type=refresh_token` and `refresh_token` |\n| Revoke | `POST https://api.orderkrab.com/oauth/revoke` with `token` |\n\nThe person signs in to OrderKrab, picks the organization and decides whether the app may make changes.\nAccess tokens (`oka_…`) last one hour. Refresh tokens (`okr_…`) last 90 days and are replaced on every refresh;\nreusing an old refresh token disconnects the app. People see and disconnect apps under\n**Settings → API \u0026 Apps → Connect apps**, where each connection is listed under its app.\n\n# Permissions\n\n- Every `GET` endpoint needs the `read` scope, which every credential has.\n- Every endpoint that changes data needs `write`. A read-only credential gets `403 insufficient_scope`.\n- Stock endpoints need a plan with inventory (Pro, Free and Warehouse; not Labels); others get `403 not_a_warehouse_organization`.\n- Creating labels follows the same rules as the OrderKrab app: an organization without fulfillment credits\n  or a subscription gets `402 billing_required_for_fulfillment`.\n\n# Errors\n\nErrors share one shape and a matching HTTP status:\n\n```json\n{ \"error\": { \"code\": \"not_found\", \"message\": \"Order not found in this organization\" } }\n```\n\n| Status | Code | Meaning |\n| --- | --- | --- |\n| 400 | e.g. `order_wrong_old_status` | The order is in a state that does not allow the change; the message says why |\n| 401 | `invalid_token` | Missing, unknown, expired or revoked credential |\n| 402 | `billing_required_for_fulfillment` | No fulfillment credits left and no subscription |\n| 403 | `insufficient_scope`, `forbidden` | Read-only credential, or not allowed in this organization |\n| 404 | `not_found` | The record does not exist in this organization |\n| 422 | `invalid_parameter` | A parameter is missing, unknown or out of range |\n| 429 | `rate_limited` | Too many requests; wait for the `Retry-After` seconds |\n| 503 | `carrier_unavailable` | The carrier did not answer in time; retry later |\n\n# Pagination\n\nLists take `page` (from 1) and `per_page` (25 by default, at most 100) and answer with\n`{ \"data\": [...], \"meta\": { \"page\": 1, \"per_page\": 25, \"has_more\": true } }`. Keep requesting the next page\nwhile `has_more` is true.\n\n# Rate limits\n\nEach credential can make 300 requests per minute across the REST API and the MCP server. Over the limit\nyou get `429` with a `Retry-After` header.\n\n# Orders and shipping\n\nOrderKrab imports orders from your Shopify and WooCommerce stores. An order moves through these statuses:\n\n| Status | Meaning |\n| --- | --- |\n| `pending_fulfillment` | Ready to pack |\n| `being_fulfilled` | Has a label and is being packed |\n| `scheduled_to_fulfill` | Being marked fulfilled in the store |\n| `fulfilled`, `cancelled`, `refunded` | Closed |\n| `needs_attention` | Has problems, listed on the order |\n| `waiting_for_shipping_method` | No carrier chosen yet |\n| `waiting_for_payment`, `waiting_for_products`, `skipped` | On hold |\n| `waiting_for_pre_pack`, `being_pre_packed` | In the picking queue |\n\nTo ship an order: if it has no shipping method, read `GET /orders/{id}/shipping_rates` and pass a rate's\n`shipping_code` to `PUT /orders/{id}/shipping_method`; then `POST /orders/{id}/label`; then\n`POST /orders/{id}/fulfill`, which also marks the order fulfilled in your store and sends the store's shipping\nnotification. Creating a label books a real shipment with the carrier and counts as a billable fulfillment.\n\nMoney values are decimal strings in the order currency (`\"25.50\"`), times are UTC ISO 8601, and `created_at`\nis when OrderKrab received the order. Orders split across store locations appear as separate orders numbered\n`1001-1`, `1001-2`. Practice orders created by the onboarding demo are left out of lists unless you pass\n`include_demo=true`.\n\n# MCP server for Claude\n\nThe same capabilities are available to AI assistants through a remote MCP server at `https://api.orderkrab.com/mcp`\n(Streamable HTTP). It accepts OAuth access tokens and API keys. In OrderKrab, click **Connect** next to\nClaude in **Settings → API \u0026 Apps** to see the URL and these steps.\n\n- **Claude on the web, desktop and mobile:** open **Customize → Connectors**, choose\n  **Add custom connector**, paste `https://api.orderkrab.com/mcp` and click **Connect**. Sign in to OrderKrab, choose the\n  organization and whether Claude may make changes.\n- **Claude Code:** run `claude mcp add --transport http orderkrab https://api.orderkrab.com/mcp`, then type `/mcp` in\n  Claude Code to sign in. To use an API key instead, add `--header \"Authorization: Bearer ok_your_key\"`.\n- **Other MCP clients:** point them at `https://api.orderkrab.com/mcp`; clients that support OAuth discover the sign-in\n  from the server's `401` response.\n\nRead-only connections see only the read tools. Claude asks before every tool that changes data.\n\n**Read tools**\n\n- `get_organization`: Returns the connected OrderKrab organization: its stores, plan, fulfillment credit balance and the permissions of this connection.\n- `list_orders`: Lists and searches orders, newest first. Filter by status, free-text query (order number, customer name, email, phone or tracking code), store, tag, carrier and creation date. Archived and practice orders are left out unless asked for.\n- `get_order`: Returns one order with its items, shipping address, carrier and shipping method, problems, comments, shipments with tracking links and fulfillment details.\n- `get_order_counts`: Counts open, non-archived orders per status, for example how many are ready to pack (pending_fulfillment) or need attention.\n- `get_order_history`: Returns the timeline of an order: status changes, labels, comments and who did what.\n- `get_shipping_rates`: Lists the carrier services, parcel lockers and store pick-up points available for an order with their prices. The shipping_code of a rate is what set_order_shipping_method expects.\n- `list_shipping_options`: Lists the carriers the organization has connected, with their shipping methods.\n- `get_shipping_label`: Returns a download link for the shipping label of an order or shipment. The link works without signing in and expires after 15 minutes.\n- `list_returns`: Lists customer return requests with their items and reasons, newest first.\n- `list_products`: Lists the store products OrderKrab knows about, with a name search.\n- `get_inventory_levels`: Lists product variants with their stock per location. Not available on the Labels plan.\n- `get_analytics`: Returns an analytics report for a period (this month by default). summary: labels created (shipped, billable) and orders packed in the period against the previous period of the same length, average packing time and open orders by status. fulfillment_series: orders received and packed per day, week or month. countries, products (top sellers), carriers and packers rank the period.\n\n**Tools that change data** (Claude asks before each call)\n\n- `add_order_comment`: Adds an internal comment to an order. Packers see it during pick and pack.\n- `update_order_address`: Changes the recipient name, contact details or shipping address of an order and refreshes its shipment. Changing the country removes the chosen shipping method.\n- `set_order_status`: Moves an order between queue states: pending_fulfillment releases it to the packing queue, waiting_for_products puts it on hold until stock arrives, skipped sets it aside, waiting_for_pre_pack sends it to the picking queue.\n- `archive_order`: Archives an order so it leaves the order lists, or restores it with archived false.\n- `resolve_order_problems`: Clears the shipment and label problems of an order that needs attention after the cause was fixed, and moves it back to its queue.\n- `set_order_shipping_method`: Chooses the carrier service, parcel locker or pick-up point of an order using a shipping_code from get_shipping_rates.\n- `create_shipping_label`: Books the shipment of an order with its carrier and creates the label; the order becomes being_fulfilled. This is a real carrier booking and counts as a billable fulfillment.\n- `fulfill_order`: Marks an order that has a label as fulfilled in OrderKrab and in the store, which sends the store shipping notification with the tracking number to the customer.\n- `reset_order_fulfillment`: Returns an order that is being fulfilled to the packing queue.\n- `retry_order_shipment`: Recreates the carrier shipment of an order, for example after fixing an address that the carrier rejected.\n- `approve_return`: Approves a return request and creates its return label with the carrier.\n- `reject_return`: Rejects a return request.\n- `adjust_inventory`: Adds or removes stock of a product variant at a location and syncs it to the store. Not available on the Labels plan.\n\n# Versioning\n\nThis is version 1. New endpoints, parameters and response fields can appear at any time, so ignore fields\nyou do not know. Changes that would break existing integrations get a new version.\n"},"servers":[{"url":"https://api.orderkrab.com/api/v1"}],"security":[{"bearerAuth":[]},{"oauth2":["read"]}],"tags":[{"name":"Organization","description":"The organization behind the credential, its stores and the credential's permissions."},{"name":"Orders","description":"Find, read and change orders."},{"name":"Fulfillment","description":"Create labels, download them and mark orders fulfilled."},{"name":"Shipping","description":"Carriers, rates, shipping methods and shipments."},{"name":"Returns","description":"Customer return requests from the returns portal."},{"name":"Products","description":"Products imported from your stores."},{"name":"Inventory","description":"Stock per variant and location, on plans with inventory (Pro, Free and Warehouse)."},{"name":"Analytics","description":"Fulfillment reports for a period of up to two years."}],"paths":{"/organization":{"get":{"tags":["Organization"],"operationId":"getOrganization","summary":"The organization, its stores and the permissions of the credential","responses":{"200":{"description":"Organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Organization"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/orders":{"get":{"tags":["Orders"],"operationId":"listOrders","summary":"List and search orders","description":"Newest first. Archived and practice orders are left out unless asked for.","parameters":[{"name":"status","in":"query","description":"Comma-separated statuses","schema":{"type":"string","example":"pending_fulfillment,needs_attention"}},{"name":"query","in":"query","description":"Free-text search: order number, customer name, email, phone, tracking code","schema":{"type":"string"}},{"name":"shop_id","in":"query","schema":{"type":"integer"}},{"name":"tag","in":"query","description":"Comma-separated store tags, any of them","schema":{"type":"string"}},{"name":"carrier","in":"query","description":"Comma-separated carrier codes","schema":{"type":"string","example":"omniva"}},{"name":"created_after","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"created_before","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"archived","in":"query","description":"true lists only archived orders","schema":{"type":"boolean","default":false}},{"name":"include_demo","in":"query","schema":{"type":"boolean","default":false}},{"name":"sort","in":"query","schema":{"type":"string","enum":["newest","oldest"],"default":"newest"}},{"$ref":"#/components/parameters/Page"},{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Orders","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/OrderSummary"}},"meta":{"$ref":"#/components/schemas/Meta"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"422":{"$ref":"#/components/responses/Invalid"}}}},"/orders/counts":{"get":{"tags":["Orders"],"operationId":"countOrders","summary":"Open, non-archived orders per status","parameters":[{"name":"shop_id","in":"query","schema":{"type":"integer"}}],"responses":{"200":{"description":"Counts","content":{"application/json":{"schema":{"type":"object","properties":{"counts":{"type":"object","additionalProperties":{"type":"integer"}},"total":{"type":"integer"}}}}}}}}},"/orders/{id}":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"get":{"tags":["Orders"],"operationId":"getOrder","summary":"One order with items, address, problems, comments and shipments","responses":{"200":{"description":"Order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"404":{"$ref":"#/components/responses/NotFound"}}},"patch":{"tags":["Orders"],"operationId":"updateOrderAddress","summary":"Change the recipient and shipping address","description":"Refreshes the shipment. Changing the country removes the shipping method. Split orders are updated together.","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"address1":{"type":"string"},"address2":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"zip_code":{"type":"string"},"country_code":{"type":"string","description":"Two-letter ISO code"}}}}}},"responses":{"200":{"$ref":"#/components/responses/OrderChange"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/orders/{id}/history":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"get":{"tags":["Orders"],"operationId":"getOrderHistory","summary":"Timeline of the order","responses":{"200":{"description":"Actions","content":{"application/json":{"schema":{"type":"object","properties":{"order_id":{"type":"integer"},"data":{"type":"array","items":{"$ref":"#/components/schemas/OrderAction"}}}}}}}}}},"/orders/{id}/comments":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"post":{"tags":["Orders"],"operationId":"addOrderComment","summary":"Add an internal comment","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string","maxLength":5000}}}}}},"responses":{"201":{"description":"Comment","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"integer"},"order_id":{"type":"integer"},"message":{"type":"string"},"author":{"type":"string"},"created_at":{"type":"string","format":"date-time"}}}}}}}}},"/orders/{id}/status":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"post":{"tags":["Orders"],"operationId":"setOrderStatus","summary":"Hold or release an order","description":"`pending_fulfillment` releases the order to the packing queue, `waiting_for_products` holds it until stock arrives,\n`skipped` sets it aside, `waiting_for_pre_pack` sends it to the picking queue.\n","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["pending_fulfillment","waiting_for_pre_pack","skipped","waiting_for_products"]}}}}}},"responses":{"200":{"description":"Order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderSummary"}}}},"400":{"$ref":"#/components/responses/Invalid"}}}},"/orders/{id}/archive":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"post":{"tags":["Orders"],"operationId":"archiveOrder","summary":"Archive an order","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"responses":{"200":{"description":"Order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderSummary"}}}}}}},"/orders/{id}/unarchive":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"post":{"tags":["Orders"],"operationId":"unarchiveOrder","summary":"Restore an archived order","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"responses":{"200":{"description":"Order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderSummary"}}}}}}},"/orders/{id}/resolve_problems":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"post":{"tags":["Orders"],"operationId":"resolveOrderProblems","summary":"Clear shipment and label problems of an order that needs attention","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"responses":{"200":{"description":"Order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}}}}},"/orders/{id}/shipping_rates":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"get":{"tags":["Shipping"],"operationId":"getShippingRates","summary":"Carrier services, lockers and pick-up points available for the order","responses":{"200":{"description":"Rates","content":{"application/json":{"schema":{"type":"object","properties":{"order_id":{"type":"integer"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Rate"}}}}}}}}}},"/orders/{id}/shipping_method":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"put":{"tags":["Shipping"],"operationId":"setOrderShippingMethod","summary":"Choose the shipping method with a shipping_code from the rates","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["shipping_code"],"properties":{"shipping_code":{"type":"string","example":"courier:omniva"}}}}}},"responses":{"200":{"$ref":"#/components/responses/OrderChange"}}}},"/orders/{id}/label":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"post":{"tags":["Fulfillment"],"operationId":"createShippingLabel","summary":"Book the shipment with the carrier and create the label","description":"Works for orders that are pending_fulfillment, waiting_for_pre_pack or being_fulfilled; the order becomes being_fulfilled.\nThis is a real carrier booking and counts as a billable fulfillment. Calling it again returns the existing label.\n","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"responses":{"201":{"description":"Order and label link","content":{"application/json":{"schema":{"type":"object","properties":{"order":{"$ref":"#/components/schemas/Order"},"label":{"$ref":"#/components/schemas/LabelLink"}}}}}},"402":{"$ref":"#/components/responses/Invalid"},"422":{"$ref":"#/components/responses/Invalid"}}}},"/orders/{id}/label.{format}":{"parameters":[{"$ref":"#/components/parameters/OrderId"},{"name":"format","in":"path","required":true,"schema":{"type":"string","enum":["pdf","zpl"]}}],"get":{"tags":["Fulfillment"],"operationId":"downloadOrderLabel","summary":"Download the label of the order primary shipment","responses":{"200":{"description":"Label file","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}},"text/plain":{"schema":{"type":"string"}}}}}}},"/orders/{id}/fulfill":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"post":{"tags":["Fulfillment"],"operationId":"fulfillOrder","summary":"Mark an order with a label as fulfilled in OrderKrab and in the store","description":"Runs in the background; the store sends its shipping notification with the tracking number.","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"responses":{"202":{"description":"Queued","content":{"application/json":{"schema":{"type":"object","properties":{"order":{"$ref":"#/components/schemas/OrderSummary"},"message":{"type":"string"}}}}}}}}},"/orders/{id}/reset_fulfillment":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"post":{"tags":["Fulfillment"],"operationId":"resetOrderFulfillment","summary":"Return an order that is being fulfilled to the packing queue","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"responses":{"200":{"description":"Order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderSummary"}}}}}}},"/orders/{id}/retry_shipment":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"post":{"tags":["Fulfillment"],"operationId":"retryOrderShipment","summary":"Recreate the carrier shipment of an order","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"responses":{"200":{"description":"Order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}}}}},"/orders/{id}/shipments":{"parameters":[{"$ref":"#/components/parameters/OrderId"}],"get":{"tags":["Shipping"],"operationId":"listOrderShipments","summary":"All shipments of an order, including returns","responses":{"200":{"description":"Shipments","content":{"application/json":{"schema":{"type":"object","properties":{"order_id":{"type":"integer"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Shipment"}}}}}}}}}},"/shipments/{id}/label.{format}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},{"name":"format","in":"path","required":true,"schema":{"type":"string","enum":["pdf","zpl"]}}],"get":{"tags":["Fulfillment"],"operationId":"downloadShipmentLabel","summary":"Download the label of a shipment","responses":{"200":{"description":"Label file","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}},"text/plain":{"schema":{"type":"string"}}}}}}},"/shipping_options":{"get":{"tags":["Shipping"],"operationId":"listShippingOptions","summary":"Carriers connected to the organization","parameters":[{"name":"include_inactive","in":"query","schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"Carriers","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ShippingOption"}}}}}}}}}},"/returns":{"get":{"tags":["Returns"],"operationId":"listReturns","summary":"Customer return requests, newest first","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["pending","approved","processed","rejected","completed","cancelled"]}},{"name":"query","in":"query","schema":{"type":"string"}},{"$ref":"#/components/parameters/Page"},{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Return requests","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ReturnRequest"}},"meta":{"$ref":"#/components/schemas/Meta"}}}}}}}}},"/returns/{id}/approve":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"post":{"tags":["Returns"],"operationId":"approveReturn","summary":"Approve a return request and create its return label","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"responses":{"200":{"description":"Return request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReturnRequest"}}}}}}},"/returns/{id}/reject":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"post":{"tags":["Returns"],"operationId":"rejectReturn","summary":"Reject a return request","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"responses":{"200":{"description":"Return request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReturnRequest"}}}}}}},"/products":{"get":{"tags":["Products"],"operationId":"listProducts","summary":"Store products","parameters":[{"name":"query","in":"query","schema":{"type":"string"}},{"name":"shop_id","in":"query","schema":{"type":"integer"}},{"$ref":"#/components/parameters/Page"},{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Products","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"meta":{"$ref":"#/components/schemas/Meta"}}}}}}}}},"/inventory/levels":{"get":{"tags":["Inventory"],"operationId":"getInventoryLevels","summary":"Stock per variant and location (plans with inventory)","parameters":[{"name":"query","in":"query","description":"Name, SKU or barcode","schema":{"type":"string"}},{"name":"shop_id","in":"query","schema":{"type":"integer"}},{"$ref":"#/components/parameters/Page"},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":99,"default":25}}],"responses":{"200":{"description":"Variants with levels"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/inventory/adjustments":{"post":{"tags":["Inventory"],"operationId":"adjustInventory","summary":"Add or remove stock of a variant at a location","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["variant_id","location_id","quantity_delta","note"],"properties":{"variant_id":{"type":"integer"},"location_id":{"type":"integer"},"quantity_delta":{"type":"integer"},"note":{"type":"string"},"idempotency_key":{"type":"string"}}}}}},"responses":{"201":{"description":"Inventory transaction"}}}},"/inventory/receipts":{"post":{"tags":["Inventory"],"operationId":"receiveInventory","summary":"Receive several variants into a location at once","security":[{"bearerAuth":[]},{"oauth2":["write"]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["location_id","idempotency_key","items"],"properties":{"location_id":{"type":"integer"},"idempotency_key":{"type":"string"},"note":{"type":"string"},"items":{"type":"array","items":{"type":"object","required":["variant_id","quantity"],"properties":{"variant_id":{"type":"integer"},"quantity":{"type":"integer","minimum":1}}}}}}}}},"responses":{"201":{"description":"Inventory transactions"}}}},"/analytics/{report}":{"get":{"tags":["Analytics"],"operationId":"getAnalytics","summary":"Fulfillment analytics for a period (this month by default)","description":"`summary` returns `labels_created` (orders shipped and billed in the period), `orders_packed`,\n`average_packing_seconds` and `average_seconds_from_order_to_packed`, each with `period`, `previous_period`\n(the same number of days before), `change_percent` and `all_time`, plus `open_orders_by_status`.\n`fulfillment_series` returns orders received and packed per day, week or month.\n","parameters":[{"name":"report","in":"path","required":true,"schema":{"type":"string","enum":["summary","fulfillment_series","countries","products","carriers","packers"]}},{"name":"from","in":"query","schema":{"type":"string","format":"date"}},{"name":"to","in":"query","schema":{"type":"string","format":"date"}},{"name":"shop_id","in":"query","description":"Comma-separated store ids","schema":{"type":"string"}}],"responses":{"200":{"description":"Report","content":{"application/json":{"schema":{"type":"object","properties":{"report":{"type":"string"},"from":{"type":"string","format":"date"},"to":{"type":"string","format":"date"},"data":{"type":"object"}}}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"An API key (`ok_...`) or an OAuth access token (`oka_...`)."},"oauth2":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"https://api.orderkrab.com/oauth/authorize","tokenUrl":"https://api.orderkrab.com/oauth/token","refreshUrl":"https://api.orderkrab.com/oauth/token","scopes":{"read":"Read orders, shipments, returns, products and analytics","write":"Change orders, create labels, fulfill orders and handle returns"}}}}},"parameters":{"OrderId":{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},"Page":{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},"PerPage":{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}}},"responses":{"Unauthorized":{"description":"Missing, invalid, expired or revoked credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"The credential is read-only or the organization cannot do this","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"Not found in this organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Invalid":{"description":"Invalid parameters or a state that does not allow the change","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"OrderChange":{"description":"Updated order and the split parts the change reached","content":{"application/json":{"schema":{"type":"object","properties":{"order":{"$ref":"#/components/schemas/Order"},"applied_order_ids":{"type":"array","items":{"type":"integer"}},"skipped":{"type":"array","items":{"type":"object","properties":{"order_id":{"type":"integer"},"split_part":{"type":"integer"},"reason":{"type":"string"}}}}}}}}}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"not_found"},"message":{"type":"string"}}}}},"Meta":{"type":"object","properties":{"page":{"type":"integer"},"per_page":{"type":"integer"},"has_more":{"type":"boolean"}}},"Organization":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"country_code":{"type":"string"},"plan":{"type":"string"},"subscribed":{"type":"boolean"},"free_fulfillments_balance":{"type":"integer"},"can_fulfill":{"type":"boolean"},"shops":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"vendor":{"type":"string","enum":["shopify","woo","presta"]},"domain":{"type":"string"},"status":{"type":"string"}}}},"credential":{"type":"object","properties":{"type":{"type":"string","enum":["api_key","oauth"]},"scopes":{"type":"array","items":{"type":"string"}},"user_email":{"type":"string"}}}}},"OrderStatus":{"type":"string","enum":["processing","unprocessable","waiting_for_payment","waiting_for_shipping_method","needs_attention","waiting_for_products","waiting_for_pre_pack","being_pre_packed","pending_fulfillment","skipped","being_fulfilled","scheduled_to_fulfill","in_transit_to_store","ready_for_pick_up","fulfilled","cancelled","refunded"]},"OrderSummary":{"type":"object","properties":{"id":{"type":"integer"},"order_number":{"type":"string","example":"#1001"},"shop":{"type":"object","properties":{"id":{"type":"integer"},"vendor":{"type":"string"},"domain":{"type":"string"}}},"status":{"$ref":"#/components/schemas/OrderStatus"},"payment_status":{"type":["string","null"]},"archived":{"type":"boolean"},"customer":{"type":"object","properties":{"name":{"type":"string"},"company":{"type":["string","null"]},"email":{"type":["string","null"]},"phone":{"type":"string"}}},"destination":{"type":"object","properties":{"country_code":{"type":"string"},"city":{"type":"string"}}},"total_price":{"type":["string","null"],"example":"25.50"},"currency":{"type":"string"},"items_count":{"type":"integer"},"tags":{"type":"array","items":{"type":"string"}},"shipping":{"type":"object","properties":{"provider_code":{"type":["string","null"]},"provider_name":{"type":["string","null"]},"method_code":{"type":["string","null"]},"method_name":{"type":["string","null"]},"store_pick_up":{"type":"boolean"}}},"tracking_codes":{"type":"array","items":{"type":"string"},"description":"Tracking code of every parcel, first box first. Return labels are listed under the order's shipments."},"problems":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"date-time","description":"When OrderKrab received the order"},"fulfillment_completed_at":{"type":["string","null"],"format":"date-time"}}},"Order":{"allOf":[{"$ref":"#/components/schemas/OrderSummary"},{"type":"object","properties":{"vendor_order_id":{"type":"string"},"vendor_status":{"type":"string"},"demo":{"type":"boolean"},"split":{"type":["object","null"],"properties":{"part":{"type":"integer"},"parts_count":{"type":"integer"}}},"shipping_address":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"company":{"type":["string","null"]},"address1":{"type":"string"},"address2":{"type":["string","null"]},"city":{"type":"string"},"state":{"type":["string","null"]},"zip_code":{"type":"string"},"country_code":{"type":"string"},"phone":{"type":"string"},"email":{"type":["string","null"]}}},"total_outstanding":{"type":["string","null"]},"shipping_price":{"type":["string","null"]},"discount_codes":{"type":"array","items":{"type":"string"}},"note":{"type":["string","null"]},"risk_level":{"type":["string","null"]},"location":{"type":["string","null"]},"items":{"type":"array","items":{"$ref":"#/components/schemas/OrderItem"}},"problems":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"description":{"type":"string"}}}},"comments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"message":{"type":"string"},"author":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}}}},"shipments":{"type":"array","items":{"$ref":"#/components/schemas/Shipment"}},"fulfillment":{"type":"object","properties":{"started_at":{"type":["string","null"],"format":"date-time"},"completed_at":{"type":["string","null"],"format":"date-time"},"fulfilled_by":{"type":["string","null"]},"labels_printed_count":{"type":"integer"}}},"updated_at":{"type":"string","format":"date-time"}}}]},"OrderItem":{"type":"object","properties":{"id":{"type":"integer"},"sku":{"type":["string","null"]},"barcode":{"type":["string","null"]},"name":{"type":"string"},"variant":{"type":["string","null"]},"quantity":{"type":"integer"},"unit_price":{"type":["string","null"]},"total_price":{"type":["string","null"]},"currency":{"type":"string"},"unit_weight_grams":{"type":["integer","null"]},"type":{"type":["string","null"]},"archived":{"type":"boolean"}}},"Shipment":{"type":"object","properties":{"id":{"type":"integer"},"order_id":{"type":"integer"},"type":{"type":"string","enum":["primary","additional","return","auto_return","custom"]},"status":{"type":"string","enum":["not_created","created","started_initiating","initiated","voided"]},"carrier":{"type":["object","null"],"properties":{"code":{"type":"string"},"name":{"type":"string"}}},"tracking_code":{"type":["string","null"]},"tracking_url":{"type":["string","null"]},"box_number":{"type":["integer","null"]},"created_at":{"type":"string","format":"date-time"},"initiated_at":{"type":["string","null"],"format":"date-time"}}},"LabelLink":{"type":"object","properties":{"url":{"type":"string","description":"Download link valid for 15 minutes without a credential"},"expires_at":{"type":"string","format":"date-time"},"shipment_id":{"type":"integer"},"order_id":{"type":"integer"},"tracking_code":{"type":["string","null"]},"format":{"type":"string","enum":["pdf","zpl"]}}},"OrderAction":{"type":"object","properties":{"id":{"type":"integer"},"action":{"type":"string"},"description":{"type":"string"},"comment":{"type":["string","null"]},"order_status":{"type":["string","null"]},"actor_type":{"type":"string","enum":["user","system","api","customer"]},"actor_email":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}}},"Rate":{"type":"object","properties":{"shipping_code":{"type":"string","description":"Pass to PUT /orders/{id}/shipping_method"},"name":{"type":"string"},"description":{"type":["string","null"]},"price":{"type":["string","null"]},"currency":{"type":["string","null"]}}},"ShippingOption":{"type":"object","properties":{"id":{"type":"integer"},"provider_code":{"type":"string"},"provider_name":{"type":"string"},"status":{"type":"string","enum":["active","inactive"]},"own_contract":{"type":"boolean"},"shown_in_checkout":{"type":["boolean","null"]},"methods":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"code":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"}}}}}},"ReturnRequest":{"type":"object","properties":{"id":{"type":"integer"},"status":{"type":"string"},"order":{"type":"object","properties":{"id":{"type":"integer"},"order_number":{"type":"string"},"status":{"type":"string"}}},"customer":{"type":"object","properties":{"name":{"type":"string"},"email":{"type":["string","null"]}}},"items":{"type":"array","items":{"type":"object","properties":{"order_item_id":{"type":"integer"},"name":{"type":["string","null"]},"sku":{"type":["string","null"]},"quantity":{"type":"integer"},"reason":{"type":["string","null"]},"reason_description":{"type":["string","null"]}}}},"return_tracking_code":{"type":["string","null"]},"customer_notified":{"type":["boolean","null"]},"created_at":{"type":"string","format":"date-time"}}},"Product":{"type":"object","properties":{"id":{"type":"integer"},"shop_id":{"type":"integer"},"vendor_product_id":{"type":["string","null"]},"name":{"type":"string"},"image_url":{"type":["string","null"]},"fulfillable":{"type":["boolean","null"]},"returnable":{"type":["boolean","null"]},"made_to_order":{"type":["boolean","null"]}}}}}}