---
title: "Take a refused order file as the new draft"
method: POST
path: "/api/v1/sales/orders/documents/{document_id}/take"
tags: ["orders"]
---

# Take a refused order file as the new draft

`POST /api/v1/sales/orders/documents/{document_id}/take`

## Request

- Base URL: `https://api.app.tightly.io`
- URL: `https://api.app.tightly.io/api/v1/sales/orders/documents/{document_id}/take`
- Auth: HTTP bearer

Takes a paper Tightly refused and makes it the order instead. Use it when a retailer sends the same order number again with different lines: the first draft still stands, and this cancels it with the reason and reads the newer paper in its place, in one call.

Re-sending the file cannot do this: those bytes are already on the refused paper, so Tightly would answer that it already has them and create nothing.

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

## Path parameters

- `document_id` integer, required

## Headers

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

## Response `200`

The paper, read again, with the draft it now carries, in the same whole shape `GET /sales/orders/documents/{document_id}` serves: the reading, the matcher's answer per document line, the source to check it against, and the account. The example shows the fields the take moves rather than the whole answer.

- object
  - `data` object
  - `message` object

## Other responses

- `401`: No usable key: malformed, unknown, revoked, expired or stopped. One refusal covers all five.
- `403`: The key may not reach this operation. `plan_excludes` when this organisation's plan does not include Tightly Connect, which the arriving order file needs and which is sold with Essentials+; `scope_missing` when the key does not hold Orders; `ip_not_allowed` when the caller's address is outside the key's allowlist; `account_mismatch` when a key issued to one account names another, or a paper that is not that account's.
- `404`: No order file with that id is on file (`document_not_on_file`).
- `409`: `document_still_reading`, the paper has not been read yet; `document_not_refused`, it was not refused, so there is nothing to take; `document_replaces_nothing`, it was refused for something other than a standing draft; `standing_order_confirmed`, the order it would replace is no longer a draft; `file_names_another_account`, the paper's letterhead names another account on file.
- `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)
