---
title: "import sales orders"
method: POST
path: "/api/v1/sales/orders/import"
tags: ["orders"]
---

# import sales orders

`POST /api/v1/sales/orders/import`

## Request

- Base URL: `https://api.app.tightly.io`
- URL: `https://api.app.tightly.io/api/v1/sales/orders/import`
- Auth: HTTP bearer

Turns a file already uploaded and column-mapped into owned orders: one document per order number and channel, one line per SKU. Re-importing the same file updates the same orders rather than making a second set, so a corrected file is sent again rather than cleaned up by hand. Rows that cannot be written come back in `failed_rows` with the reason in words, and nothing in the file is written twice.

This is the door for a file of orders you owe. A backfill of sales HISTORY is a different entity and a different door: it writes lines, not documents, and tells Tightly nothing about what is still to ship.

Scope: `orders:write`, which includes `orders:read`.

## Headers

- `Tightly-Version` string
- `Idempotency-Key` string

## Request body

- ImportSalesOrdersRequest
  - `mappings` object, required
  - `s3_key` string, required

## Response `202`

What the import wrote, and what it refused.

- object
  - `data` object: upload_id, counts and failed_rows.
  - `message` object: severity, service and desc.

## Other responses

- `400`: The body names no file, or maps none of the order number, the SKU and the quantity.
- `401`: No usable key: malformed, unknown, revoked, expired or stopped.
- `403`: The key does not hold Orders (`scope_missing`), or is issued to one account, which a file of orders cannot be narrowed to (`account_mismatch`).
- `429`: The key has spent its allowance for this minute. 600 reads and 120 writes a minute, counted per key, refused calls included. `Retry-After` says how long to wait.
- `503`: The database is briefly out of reach, which is what a failover or a full connection pool looks like from outside. Wait the seconds `Retry-After` names and send the request again. A read is safe to repeat. A write is not, because the connection was lost in the middle of it, so read the object back before sending it a second time. Branch on the status rather than on `code`, which is `POSTGRES_UNAVAILABLE` from one of the two seams that raise this and `SERVICE_UNAVAILABLE` from the other.

---

[API](https://skmtc.dev/tightly/apis/tightly-api.md) · [All operations](https://skmtc.dev/tightly/apis/tightly-api/llms.txt) · [OpenAPI document](https://skmtc.dev/tightly/apis/tightly-api/revisions/199f7eb35afb?raw)
