# Draft orders

> Draft orders staff make and shoppers' requests for a quote (D173, D431), sent as a pay link or declined.

| Operation | Method and path | Scope |
|---|---|---|
| [List draft orders](https://docs.kaizenaflow.com/reference/admin-api/draft-orders#drafts-list) | `GET /drafts` | [`orders:read`](https://docs.kaizenaflow.com/reference/scopes#orders-read) |
| [Get a draft order](https://docs.kaizenaflow.com/reference/admin-api/draft-orders#drafts-get) | `GET /drafts/{id}` | [`orders:read`](https://docs.kaizenaflow.com/reference/scopes#orders-read) |
| [Create a draft order](https://docs.kaizenaflow.com/reference/admin-api/draft-orders#drafts-create) | `POST /drafts` | [`orders:manage`](https://docs.kaizenaflow.com/reference/scopes#orders-manage) |
| [Change a draft order](https://docs.kaizenaflow.com/reference/admin-api/draft-orders#drafts-update) | `PATCH /drafts/{id}` | [`orders:manage`](https://docs.kaizenaflow.com/reference/scopes#orders-manage) |
| [Send a draft order](https://docs.kaizenaflow.com/reference/admin-api/draft-orders#drafts-send) | `POST /drafts/{id}/send` | [`orders:send`](https://docs.kaizenaflow.com/reference/scopes#orders-send) |
| [Decline a request for a quote](https://docs.kaizenaflow.com/reference/admin-api/draft-orders#drafts-decline) | `POST /drafts/{id}/decline` | [`orders:send`](https://docs.kaizenaflow.com/reference/scopes#orders-send) |

## List draft orders {#drafts-list}

`GET https://kaizenaflow.com/api/admin/v1/drafts`

The store's draft orders and shoppers' requests for a quote (D173, D431), newest first, each with its lines and what it totals now.

- **Operation:** `drafts.list`
- **Scope:** [`orders:read`](https://docs.kaizenaflow.com/reference/scopes#orders-read), or [`orders:write`](https://docs.kaizenaflow.com/reference/scopes#orders-write), which reads too
- **Answers:** `200`, a page: the rows under `data`, and `next` for the page after.
- **Pages:** at most 100 rows, 50 when `limit` is left out; give an answer's `next` as `?after=` for the page after.

### Query parameters {#drafts-list-query}

| Name | Type | Required | Description |
|---|---|---|---|
| `limit` | integer, 1 to 100 | no | Rows a page holds, at most 100; 50 when left out. A larger number gives 100. |
| `after` | string, at most 200 characters | no | The `next` cursor of the page before; the first page when left out. |
| `updated_after` | string (date-time) | no | Only what was made or changed after this time (ISO 8601 with its offset), for incremental sync. |
| `status` | one of `open`, `sent`, `paid`, `expired`, `cancelled` | no | Only drafts in this state. |
| `quotes` | one of `true`, `false` | no | true: only shoppers' requests for a quote. |

### Answer {#drafts-list-answer}

| Field | Type | Description |
|---|---|---|
| `data` | list of objects |   |
| `data[].id` | string (uuid) |   |
| `data[].number` | string | The draft's own number (D-…); the order it becomes gets the store's next order number. |
| `data[].status` | one of `open`, `sent`, `paid`, `expired`, `cancelled` | open: being made. sent: its order waits for payment. paid, expired or cancelled: ended. |
| `data[].source` | one of `staff`, `quote` | staff: made in the admin or here. quote: a shopper's request for a quote (D431). |
| `data[].quote` | one of `requested`, `declined` or null | A request for a quote: waiting (requested) or declined; null for any other draft. |
| `data[].version` | integer | Raised by every change: give it back with a change or a send, and one made since is refused as `conflict`. |
| `data[].market` | string | A market, by its code (the country's ISO 3166-1 code, such as NO). |
| `data[].currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data[].customer_id` | string (uuid) or null |   |
| `data[].email` | string or null |   |
| `data[].phone` | string or null |   |
| `data[].shipping_address` | object |   |
| `data[].shipping_address.name` | string |   |
| `data[].shipping_address.line1` | string |   |
| `data[].shipping_address.line2` | string |   |
| `data[].shipping_address.postal_code` | string |   |
| `data[].shipping_address.city` | string |   |
| `data[].shipping_address.country` | string |   |
| `data[].billing_address` | object |   |
| `data[].billing_address.name` | string |   |
| `data[].billing_address.line1` | string |   |
| `data[].billing_address.line2` | string |   |
| `data[].billing_address.postal_code` | string |   |
| `data[].billing_address.city` | string |   |
| `data[].billing_address.country` | string |   |
| `data[].company_name` | string or null |   |
| `data[].organisation_number` | string or null |   |
| `data[].note_to_buyer` | string or null |   |
| `data[].internal_note` | string or null |   |
| `data[].request_note` | string or null | What the shopper wrote with a request for a quote. |
| `data[].tags` | list of string |   |
| `data[].discount` | object or null | A discount staff give on the whole draft, with the words the buyer sees. |
| `data[].discount.kind` | one of `percent`, `amount` |   |
| `data[].discount.percent` | number or null |   |
| `data[].discount.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data[].discount.label` | string |   |
| `data[].shipping` | object | rate: the market's shipping rate. custom: the amount given. |
| `data[].shipping.kind` | one of `rate`, `free`, `custom` |   |
| `data[].shipping.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data[].lines` | list of objects |   |
| `data[].lines[].id` | string (uuid) |   |
| `data[].lines[].kind` | one of `goods`, `custom` |   |
| `data[].lines[].variant_id` | string (uuid) or null |   |
| `data[].lines[].sku` | string |   |
| `data[].lines[].title` | string |   |
| `data[].lines[].quantity` | integer |   |
| `data[].lines[].unit_price_minor` | integer | What one unit costs on the draft, VAT included. |
| `data[].lines[].list_price_minor` | integer or null | The market's list price when the line was last saved; null for a custom item. |
| `data[].lines[].custom_price` | boolean | A price given instead of the list price. |
| `data[].lines[].price_requested` | boolean | A requested product priced on request with no price given yet: the draft cannot be sent until it has one. |
| `data[].lines[].vat_category` | string or null |   |
| `data[].total_minor` | integer or null | What the draft totals now, with shipping, the discount and VAT, as the order would; null when it cannot be worked out yet. |
| `data[].blocking` | list of string | Why a send would be refused now, in words; empty when it can be sent. |
| `data[].order_id` | string (uuid) or null | The order a sent draft made. |
| `data[].sent_at` | string (date-time) or null |   |
| `data[].expires_at` | string (date-time) or null | When a sent draft's pay link ends and its order is cancelled. |
| `data[].created_at` | string (date-time) |   |
| `data[].updated_at` | string (date-time) |   |
| `next` | string or null | The cursor of the next page, given as `?after=`; null on the last page. |

### Errors {#drafts-list-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#drafts-list-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/drafts' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/drafts", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/drafts",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Get a draft order {#drafts-get}

`GET https://kaizenaflow.com/api/admin/v1/drafts/{id}`

One draft order or request for a quote, with what would stop it being sent now.

- **Operation:** `drafts.get`
- **Scope:** [`orders:read`](https://docs.kaizenaflow.com/reference/scopes#orders-read), or [`orders:write`](https://docs.kaizenaflow.com/reference/scopes#orders-write), which reads too
- **Answers:** `200`, the answer under `data`.

### Path parameters {#drafts-get-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Answer {#drafts-get-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.number` | string | The draft's own number (D-…); the order it becomes gets the store's next order number. |
| `data.status` | one of `open`, `sent`, `paid`, `expired`, `cancelled` | open: being made. sent: its order waits for payment. paid, expired or cancelled: ended. |
| `data.source` | one of `staff`, `quote` | staff: made in the admin or here. quote: a shopper's request for a quote (D431). |
| `data.quote` | one of `requested`, `declined` or null | A request for a quote: waiting (requested) or declined; null for any other draft. |
| `data.version` | integer | Raised by every change: give it back with a change or a send, and one made since is refused as `conflict`. |
| `data.market` | string | A market, by its code (the country's ISO 3166-1 code, such as NO). |
| `data.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.customer_id` | string (uuid) or null |   |
| `data.email` | string or null |   |
| `data.phone` | string or null |   |
| `data.shipping_address` | object |   |
| `data.shipping_address.name` | string |   |
| `data.shipping_address.line1` | string |   |
| `data.shipping_address.line2` | string |   |
| `data.shipping_address.postal_code` | string |   |
| `data.shipping_address.city` | string |   |
| `data.shipping_address.country` | string |   |
| `data.billing_address` | object |   |
| `data.billing_address.name` | string |   |
| `data.billing_address.line1` | string |   |
| `data.billing_address.line2` | string |   |
| `data.billing_address.postal_code` | string |   |
| `data.billing_address.city` | string |   |
| `data.billing_address.country` | string |   |
| `data.company_name` | string or null |   |
| `data.organisation_number` | string or null |   |
| `data.note_to_buyer` | string or null |   |
| `data.internal_note` | string or null |   |
| `data.request_note` | string or null | What the shopper wrote with a request for a quote. |
| `data.tags` | list of string |   |
| `data.discount` | object or null | A discount staff give on the whole draft, with the words the buyer sees. |
| `data.discount.kind` | one of `percent`, `amount` |   |
| `data.discount.percent` | number or null |   |
| `data.discount.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.discount.label` | string |   |
| `data.shipping` | object | rate: the market's shipping rate. custom: the amount given. |
| `data.shipping.kind` | one of `rate`, `free`, `custom` |   |
| `data.shipping.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.lines` | list of objects |   |
| `data.lines[].id` | string (uuid) |   |
| `data.lines[].kind` | one of `goods`, `custom` |   |
| `data.lines[].variant_id` | string (uuid) or null |   |
| `data.lines[].sku` | string |   |
| `data.lines[].title` | string |   |
| `data.lines[].quantity` | integer |   |
| `data.lines[].unit_price_minor` | integer | What one unit costs on the draft, VAT included. |
| `data.lines[].list_price_minor` | integer or null | The market's list price when the line was last saved; null for a custom item. |
| `data.lines[].custom_price` | boolean | A price given instead of the list price. |
| `data.lines[].price_requested` | boolean | A requested product priced on request with no price given yet: the draft cannot be sent until it has one. |
| `data.lines[].vat_category` | string or null |   |
| `data.total_minor` | integer or null | What the draft totals now, with shipping, the discount and VAT, as the order would; null when it cannot be worked out yet. |
| `data.blocking` | list of string | Why a send would be refused now, in words; empty when it can be sent. |
| `data.order_id` | string (uuid) or null | The order a sent draft made. |
| `data.sent_at` | string (date-time) or null |   |
| `data.expires_at` | string (date-time) or null | When a sent draft's pay link ends and its order is cancelled. |
| `data.created_at` | string (date-time) |   |
| `data.updated_at` | string (date-time) |   |

### Errors {#drafts-get-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#drafts-get-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Create a draft order {#drafts-create}

`POST https://kaizenaflow.com/api/admin/v1/drafts`

Makes a draft order through the draft editor's own functions: an empty draft in the market, then saved with what is given, checked as the editor checks it. Nothing is held and no order number used until it is sent.

- **Operation:** `drafts.create`
- **Scope:** [`orders:manage`](https://docs.kaizenaflow.com/reference/scopes#orders-manage)
- **Answers:** `201`, made: the answer under `data`.
- **Once only:** with an [`Idempotency-Key`](https://docs.kaizenaflow.com/reference/admin-api#idempotency) header.

### Body {#drafts-create-body}

JSON, with `Content-Type: application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `market` | string, matching `^[A-Z]{2}$` | no | The market the draft sells in, by its code; the store's own market when left out. |
| `customer_id` | string (uuid) or null | no | One of the store's customers, or null for none. |
| `email` | string, at most 254 characters or null | no |   |
| `phone` | string, at most 40 characters or null | no |   |
| `shipping_address` | object | no | Each field given replaces the draft's; one left out stays. |
| `shipping_address.name` | string, at most 200 characters | no |   |
| `shipping_address.line1` | string, at most 200 characters | no |   |
| `shipping_address.line2` | string, at most 200 characters | no |   |
| `shipping_address.postal_code` | string, at most 20 characters | no |   |
| `shipping_address.city` | string, at most 100 characters | no |   |
| `shipping_address.country` | string, at most 2 characters | no | An ISO 3166-1 code, such as NO. |
| `billing_address` | object | no | Each field given replaces the draft's; one left out stays. |
| `billing_address.name` | string, at most 200 characters | no |   |
| `billing_address.line1` | string, at most 200 characters | no |   |
| `billing_address.line2` | string, at most 200 characters | no |   |
| `billing_address.postal_code` | string, at most 20 characters | no |   |
| `billing_address.city` | string, at most 100 characters | no |   |
| `billing_address.country` | string, at most 2 characters | no | An ISO 3166-1 code, such as NO. |
| `company_name` | string, at most 120 characters or null | no |   |
| `organisation_number` | string, at most 30 characters or null | no |   |
| `note_to_buyer` | string, at most 500 characters or null | no | Words the buyer reads on the pay page and the order. |
| `internal_note` | string, at most 1,000 characters or null | no | Words for staff only. |
| `tags` | list of string, at most 120 characters, at most 250 items | no | The draft's tags, carried to its order; replaces the tags there. |
| `discount` | object or null | no |   |
| `discount.kind` | one of `percent`, `amount` | yes |   |
| `discount.percent` | number, 0.01 to 100 | no | For percent: how much is taken off, such as 10 or 12.5. |
| `discount.amount_minor` | integer, at least 1 | no | For amount: what is taken off, in minor units. |
| `discount.label` | string, 1 to 60 characters | yes | The words the buyer sees. |
| `shipping` | object | no |   |
| `shipping.kind` | one of `rate`, `free`, `custom` | yes |   |
| `shipping.amount_minor` | integer, at least 0 | no | For custom: the shipping price in minor units, VAT included. |
| `lines` | list of objects, at most 100 items | no | The draft's lines as they should be, in order: they replace the lines there. |
| `lines[].id` | string (uuid) | no | A line of the draft to keep (its quantity and price as given here). |
| `lines[].variant_id` | string (uuid) | no | A product's variant, by its id. |
| `lines[].sku` | string, 1 to 64 characters | no | A product's variant, by its SKU. |
| `lines[].title` | string, at most 120 characters | no | A custom item's title (no variant). |
| `lines[].quantity` | integer, 1 to 9,999 | yes |   |
| `lines[].unit_price_minor` | integer, 0 to 10,000,000,000 or null | no | The price of one unit, VAT included, in minor units of the draft's currency; left out or null on a product's line, its list price. A custom item needs one. |
| `lines[].vat_category` | string, matching `^[a-z][a-z0-9_]{1,30}$` | no | A custom item's VAT category, such as standard. |

### Answer {#drafts-create-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.number` | string | The draft's own number (D-…); the order it becomes gets the store's next order number. |
| `data.status` | one of `open`, `sent`, `paid`, `expired`, `cancelled` | open: being made. sent: its order waits for payment. paid, expired or cancelled: ended. |
| `data.source` | one of `staff`, `quote` | staff: made in the admin or here. quote: a shopper's request for a quote (D431). |
| `data.quote` | one of `requested`, `declined` or null | A request for a quote: waiting (requested) or declined; null for any other draft. |
| `data.version` | integer | Raised by every change: give it back with a change or a send, and one made since is refused as `conflict`. |
| `data.market` | string | A market, by its code (the country's ISO 3166-1 code, such as NO). |
| `data.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.customer_id` | string (uuid) or null |   |
| `data.email` | string or null |   |
| `data.phone` | string or null |   |
| `data.shipping_address` | object |   |
| `data.shipping_address.name` | string |   |
| `data.shipping_address.line1` | string |   |
| `data.shipping_address.line2` | string |   |
| `data.shipping_address.postal_code` | string |   |
| `data.shipping_address.city` | string |   |
| `data.shipping_address.country` | string |   |
| `data.billing_address` | object |   |
| `data.billing_address.name` | string |   |
| `data.billing_address.line1` | string |   |
| `data.billing_address.line2` | string |   |
| `data.billing_address.postal_code` | string |   |
| `data.billing_address.city` | string |   |
| `data.billing_address.country` | string |   |
| `data.company_name` | string or null |   |
| `data.organisation_number` | string or null |   |
| `data.note_to_buyer` | string or null |   |
| `data.internal_note` | string or null |   |
| `data.request_note` | string or null | What the shopper wrote with a request for a quote. |
| `data.tags` | list of string |   |
| `data.discount` | object or null | A discount staff give on the whole draft, with the words the buyer sees. |
| `data.discount.kind` | one of `percent`, `amount` |   |
| `data.discount.percent` | number or null |   |
| `data.discount.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.discount.label` | string |   |
| `data.shipping` | object | rate: the market's shipping rate. custom: the amount given. |
| `data.shipping.kind` | one of `rate`, `free`, `custom` |   |
| `data.shipping.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.lines` | list of objects |   |
| `data.lines[].id` | string (uuid) |   |
| `data.lines[].kind` | one of `goods`, `custom` |   |
| `data.lines[].variant_id` | string (uuid) or null |   |
| `data.lines[].sku` | string |   |
| `data.lines[].title` | string |   |
| `data.lines[].quantity` | integer |   |
| `data.lines[].unit_price_minor` | integer | What one unit costs on the draft, VAT included. |
| `data.lines[].list_price_minor` | integer or null | The market's list price when the line was last saved; null for a custom item. |
| `data.lines[].custom_price` | boolean | A price given instead of the list price. |
| `data.lines[].price_requested` | boolean | A requested product priced on request with no price given yet: the draft cannot be sent until it has one. |
| `data.lines[].vat_category` | string or null |   |
| `data.total_minor` | integer or null | What the draft totals now, with shipping, the discount and VAT, as the order would; null when it cannot be worked out yet. |
| `data.blocking` | list of string | Why a send would be refused now, in words; empty when it can be sent. |
| `data.order_id` | string (uuid) or null | The order a sent draft made. |
| `data.sent_at` | string (date-time) or null |   |
| `data.expires_at` | string (date-time) or null | When a sent draft's pay link ends and its order is cancelled. |
| `data.created_at` | string (date-time) |   |
| `data.updated_at` | string (date-time) |   |

### Errors {#drafts-create-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 409 | [`conflict`](https://docs.kaizenaflow.com/reference/errors#conflict) | Nothing was done: it clashes with how things are now (nothing left to send), or an `Idempotency-Key` is in use or was used for another request. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#drafts-create-example}

**curl**

```shell
curl -X POST 'https://kaizenaflow.com/api/admin/v1/drafts' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"market":"NO"}'
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/drafts", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "market": "NO"
  }),
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/drafts",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "market": "NO",
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Change a draft order {#drafts-update}

`PATCH https://kaizenaflow.com/api/admin/v1/drafts/{id}`

Changes only what is given on an open draft, through the editor's save: its customer, addresses, notes, tags, discount, shipping, lines, or its lines' prices by SKU.

- **Operation:** `drafts.update`
- **Scope:** [`orders:manage`](https://docs.kaizenaflow.com/reference/scopes#orders-manage)
- **Answers:** `200`, the answer under `data`.

### Path parameters {#drafts-update-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Body {#drafts-update-body}

JSON, with `Content-Type: application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `version` | integer, at least 1 | no | The version the change was made against: a draft changed since is refused as `conflict`. The draft as it is now when left out. |
| `market` | string, matching `^[A-Z]{2}$` | no | Moves the draft to another market: lines at their list price take that market's. |
| `customer_id` | string (uuid) or null | no | One of the store's customers, or null for none. |
| `email` | string, at most 254 characters or null | no |   |
| `phone` | string, at most 40 characters or null | no |   |
| `shipping_address` | object | no | Each field given replaces the draft's; one left out stays. |
| `shipping_address.name` | string, at most 200 characters | no |   |
| `shipping_address.line1` | string, at most 200 characters | no |   |
| `shipping_address.line2` | string, at most 200 characters | no |   |
| `shipping_address.postal_code` | string, at most 20 characters | no |   |
| `shipping_address.city` | string, at most 100 characters | no |   |
| `shipping_address.country` | string, at most 2 characters | no | An ISO 3166-1 code, such as NO. |
| `billing_address` | object | no | Each field given replaces the draft's; one left out stays. |
| `billing_address.name` | string, at most 200 characters | no |   |
| `billing_address.line1` | string, at most 200 characters | no |   |
| `billing_address.line2` | string, at most 200 characters | no |   |
| `billing_address.postal_code` | string, at most 20 characters | no |   |
| `billing_address.city` | string, at most 100 characters | no |   |
| `billing_address.country` | string, at most 2 characters | no | An ISO 3166-1 code, such as NO. |
| `company_name` | string, at most 120 characters or null | no |   |
| `organisation_number` | string, at most 30 characters or null | no |   |
| `note_to_buyer` | string, at most 500 characters or null | no | Words the buyer reads on the pay page and the order. |
| `internal_note` | string, at most 1,000 characters or null | no | Words for staff only. |
| `tags` | list of string, at most 120 characters, at most 250 items | no | The draft's tags, carried to its order; replaces the tags there. |
| `discount` | object or null | no |   |
| `discount.kind` | one of `percent`, `amount` | yes |   |
| `discount.percent` | number, 0.01 to 100 | no | For percent: how much is taken off, such as 10 or 12.5. |
| `discount.amount_minor` | integer, at least 1 | no | For amount: what is taken off, in minor units. |
| `discount.label` | string, 1 to 60 characters | yes | The words the buyer sees. |
| `shipping` | object | no |   |
| `shipping.kind` | one of `rate`, `free`, `custom` | yes |   |
| `shipping.amount_minor` | integer, at least 0 | no | For custom: the shipping price in minor units, VAT included. |
| `lines` | list of objects, at most 100 items | no | The draft's lines as they should be, in order: they replace the lines there. |
| `lines[].id` | string (uuid) | no | A line of the draft to keep (its quantity and price as given here). |
| `lines[].variant_id` | string (uuid) | no | A product's variant, by its id. |
| `lines[].sku` | string, 1 to 64 characters | no | A product's variant, by its SKU. |
| `lines[].title` | string, at most 120 characters | no | A custom item's title (no variant). |
| `lines[].quantity` | integer, 1 to 9,999 | yes |   |
| `lines[].unit_price_minor` | integer, 0 to 10,000,000,000 or null | no | The price of one unit, VAT included, in minor units of the draft's currency; left out or null on a product's line, its list price. A custom item needs one. |
| `lines[].vat_category` | string, matching `^[a-z][a-z0-9_]{1,30}$` | no | A custom item's VAT category, such as standard. |
| `prices` | list of objects, at most 100 items | no | Prices of the draft's lines by SKU (D437): each line of the SKU takes it; the other lines keep theirs. A request priced on request is answered so. |
| `prices[].sku` | string, 1 to 64 characters | yes |   |
| `prices[].unit_price_minor` | integer, 0 to 10,000,000,000 or null | yes | null: back to the list price. |

### Answer {#drafts-update-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.number` | string | The draft's own number (D-…); the order it becomes gets the store's next order number. |
| `data.status` | one of `open`, `sent`, `paid`, `expired`, `cancelled` | open: being made. sent: its order waits for payment. paid, expired or cancelled: ended. |
| `data.source` | one of `staff`, `quote` | staff: made in the admin or here. quote: a shopper's request for a quote (D431). |
| `data.quote` | one of `requested`, `declined` or null | A request for a quote: waiting (requested) or declined; null for any other draft. |
| `data.version` | integer | Raised by every change: give it back with a change or a send, and one made since is refused as `conflict`. |
| `data.market` | string | A market, by its code (the country's ISO 3166-1 code, such as NO). |
| `data.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.customer_id` | string (uuid) or null |   |
| `data.email` | string or null |   |
| `data.phone` | string or null |   |
| `data.shipping_address` | object |   |
| `data.shipping_address.name` | string |   |
| `data.shipping_address.line1` | string |   |
| `data.shipping_address.line2` | string |   |
| `data.shipping_address.postal_code` | string |   |
| `data.shipping_address.city` | string |   |
| `data.shipping_address.country` | string |   |
| `data.billing_address` | object |   |
| `data.billing_address.name` | string |   |
| `data.billing_address.line1` | string |   |
| `data.billing_address.line2` | string |   |
| `data.billing_address.postal_code` | string |   |
| `data.billing_address.city` | string |   |
| `data.billing_address.country` | string |   |
| `data.company_name` | string or null |   |
| `data.organisation_number` | string or null |   |
| `data.note_to_buyer` | string or null |   |
| `data.internal_note` | string or null |   |
| `data.request_note` | string or null | What the shopper wrote with a request for a quote. |
| `data.tags` | list of string |   |
| `data.discount` | object or null | A discount staff give on the whole draft, with the words the buyer sees. |
| `data.discount.kind` | one of `percent`, `amount` |   |
| `data.discount.percent` | number or null |   |
| `data.discount.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.discount.label` | string |   |
| `data.shipping` | object | rate: the market's shipping rate. custom: the amount given. |
| `data.shipping.kind` | one of `rate`, `free`, `custom` |   |
| `data.shipping.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.lines` | list of objects |   |
| `data.lines[].id` | string (uuid) |   |
| `data.lines[].kind` | one of `goods`, `custom` |   |
| `data.lines[].variant_id` | string (uuid) or null |   |
| `data.lines[].sku` | string |   |
| `data.lines[].title` | string |   |
| `data.lines[].quantity` | integer |   |
| `data.lines[].unit_price_minor` | integer | What one unit costs on the draft, VAT included. |
| `data.lines[].list_price_minor` | integer or null | The market's list price when the line was last saved; null for a custom item. |
| `data.lines[].custom_price` | boolean | A price given instead of the list price. |
| `data.lines[].price_requested` | boolean | A requested product priced on request with no price given yet: the draft cannot be sent until it has one. |
| `data.lines[].vat_category` | string or null |   |
| `data.total_minor` | integer or null | What the draft totals now, with shipping, the discount and VAT, as the order would; null when it cannot be worked out yet. |
| `data.blocking` | list of string | Why a send would be refused now, in words; empty when it can be sent. |
| `data.order_id` | string (uuid) or null | The order a sent draft made. |
| `data.sent_at` | string (date-time) or null |   |
| `data.expires_at` | string (date-time) or null | When a sent draft's pay link ends and its order is cancelled. |
| `data.created_at` | string (date-time) |   |
| `data.updated_at` | string (date-time) |   |

### Errors {#drafts-update-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | [`conflict`](https://docs.kaizenaflow.com/reference/errors#conflict) | Nothing was done: it clashes with how things are now (nothing left to send), or an `Idempotency-Key` is in use or was used for another request. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#drafts-update-example}

**curl**

```shell
curl -X PATCH 'https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"version":1}'
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "version": 1
  }),
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f",
    method="PATCH",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "version": 1,
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Send a draft order {#drafts-send}

`POST https://kaizenaflow.com/api/admin/v1/drafts/{id}/send`

Makes the draft's order (waiting for payment, numbered, stock held until the link ends) and emails the customer its pay link, or answers the link once with `create_link`. A request for a quote goes as a quote. Refused while it has a problem (`blocking`).

- **Operation:** `drafts.send`
- **Scope:** [`orders:send`](https://docs.kaizenaflow.com/reference/scopes#orders-send)
- **Answers:** `200`, the answer under `data`.
- **Once only:** with an [`Idempotency-Key`](https://docs.kaizenaflow.com/reference/admin-api#idempotency) header.

### Path parameters {#drafts-send-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Body {#drafts-send-body}

JSON, with `Content-Type: application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `version` | integer, at least 1 | no |   |
| `valid_days` | integer, 1 to 30 | no | How long the pay link lasts; the store's own when left out. |
| `create_link` | boolean | no, default `false` | true: answer the pay link (once) instead of emailing it to the customer. |

### Answer {#drafts-send-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.draft` | object |   |
| `data.draft.id` | string (uuid) |   |
| `data.draft.number` | string | The draft's own number (D-…); the order it becomes gets the store's next order number. |
| `data.draft.status` | one of `open`, `sent`, `paid`, `expired`, `cancelled` | open: being made. sent: its order waits for payment. paid, expired or cancelled: ended. |
| `data.draft.source` | one of `staff`, `quote` | staff: made in the admin or here. quote: a shopper's request for a quote (D431). |
| `data.draft.quote` | one of `requested`, `declined` or null | A request for a quote: waiting (requested) or declined; null for any other draft. |
| `data.draft.version` | integer | Raised by every change: give it back with a change or a send, and one made since is refused as `conflict`. |
| `data.draft.market` | string | A market, by its code (the country's ISO 3166-1 code, such as NO). |
| `data.draft.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.draft.customer_id` | string (uuid) or null |   |
| `data.draft.email` | string or null |   |
| `data.draft.phone` | string or null |   |
| `data.draft.shipping_address` | object |   |
| `data.draft.shipping_address.name` | string |   |
| `data.draft.shipping_address.line1` | string |   |
| `data.draft.shipping_address.line2` | string |   |
| `data.draft.shipping_address.postal_code` | string |   |
| `data.draft.shipping_address.city` | string |   |
| `data.draft.shipping_address.country` | string |   |
| `data.draft.billing_address` | object |   |
| `data.draft.billing_address.name` | string |   |
| `data.draft.billing_address.line1` | string |   |
| `data.draft.billing_address.line2` | string |   |
| `data.draft.billing_address.postal_code` | string |   |
| `data.draft.billing_address.city` | string |   |
| `data.draft.billing_address.country` | string |   |
| `data.draft.company_name` | string or null |   |
| `data.draft.organisation_number` | string or null |   |
| `data.draft.note_to_buyer` | string or null |   |
| `data.draft.internal_note` | string or null |   |
| `data.draft.request_note` | string or null | What the shopper wrote with a request for a quote. |
| `data.draft.tags` | list of string |   |
| `data.draft.discount` | object or null | A discount staff give on the whole draft, with the words the buyer sees. |
| `data.draft.discount.kind` | one of `percent`, `amount` |   |
| `data.draft.discount.percent` | number or null |   |
| `data.draft.discount.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.draft.discount.label` | string |   |
| `data.draft.shipping` | object | rate: the market's shipping rate. custom: the amount given. |
| `data.draft.shipping.kind` | one of `rate`, `free`, `custom` |   |
| `data.draft.shipping.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.draft.lines` | list of objects |   |
| `data.draft.lines[].id` | string (uuid) |   |
| `data.draft.lines[].kind` | one of `goods`, `custom` |   |
| `data.draft.lines[].variant_id` | string (uuid) or null |   |
| `data.draft.lines[].sku` | string |   |
| `data.draft.lines[].title` | string |   |
| `data.draft.lines[].quantity` | integer |   |
| `data.draft.lines[].unit_price_minor` | integer | What one unit costs on the draft, VAT included. |
| `data.draft.lines[].list_price_minor` | integer or null | The market's list price when the line was last saved; null for a custom item. |
| `data.draft.lines[].custom_price` | boolean | A price given instead of the list price. |
| `data.draft.lines[].price_requested` | boolean | A requested product priced on request with no price given yet: the draft cannot be sent until it has one. |
| `data.draft.lines[].vat_category` | string or null |   |
| `data.draft.total_minor` | integer or null | What the draft totals now, with shipping, the discount and VAT, as the order would; null when it cannot be worked out yet. |
| `data.draft.blocking` | list of string | Why a send would be refused now, in words; empty when it can be sent. |
| `data.draft.order_id` | string (uuid) or null | The order a sent draft made. |
| `data.draft.sent_at` | string (date-time) or null |   |
| `data.draft.expires_at` | string (date-time) or null | When a sent draft's pay link ends and its order is cancelled. |
| `data.draft.created_at` | string (date-time) |   |
| `data.draft.updated_at` | string (date-time) |   |
| `data.order_id` | string (uuid) |   |
| `data.order_number` | string |   |
| `data.expires_at` | string (date-time) |   |
| `data.link` | string or null | The pay link, answered only this once and only with `create_link`. |
| `data.emailed` | one of `sent`, `logged`, `failed`, `duplicate`, `suppressed` or null |   |

### Errors {#drafts-send-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | [`conflict`](https://docs.kaizenaflow.com/reference/errors#conflict) | Nothing was done: it clashes with how things are now (nothing left to send), or an `Idempotency-Key` is in use or was used for another request. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#drafts-send-example}

**curl**

```shell
curl -X POST 'https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/send' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"version":1}'
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/send", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "version": 1
  }),
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/send",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "version": 1,
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Decline a request for a quote {#drafts-decline}

`POST https://kaizenaflow.com/api/admin/v1/drafts/{id}/decline`

Declines a shopper's open request for a quote with a short reply they are emailed, as the draft page does.

- **Operation:** `drafts.decline`
- **Scope:** [`orders:send`](https://docs.kaizenaflow.com/reference/scopes#orders-send)
- **Answers:** `200`, the answer under `data`.
- **Once only:** with an [`Idempotency-Key`](https://docs.kaizenaflow.com/reference/admin-api#idempotency) header.

### Path parameters {#drafts-decline-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Body {#drafts-decline-body}

JSON, with `Content-Type: application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `reply` | string, 1 to 1,000 characters | yes | What the shopper is emailed: why their request is declined. |

### Answer {#drafts-decline-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.number` | string | The draft's own number (D-…); the order it becomes gets the store's next order number. |
| `data.status` | one of `open`, `sent`, `paid`, `expired`, `cancelled` | open: being made. sent: its order waits for payment. paid, expired or cancelled: ended. |
| `data.source` | one of `staff`, `quote` | staff: made in the admin or here. quote: a shopper's request for a quote (D431). |
| `data.quote` | one of `requested`, `declined` or null | A request for a quote: waiting (requested) or declined; null for any other draft. |
| `data.version` | integer | Raised by every change: give it back with a change or a send, and one made since is refused as `conflict`. |
| `data.market` | string | A market, by its code (the country's ISO 3166-1 code, such as NO). |
| `data.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.customer_id` | string (uuid) or null |   |
| `data.email` | string or null |   |
| `data.phone` | string or null |   |
| `data.shipping_address` | object |   |
| `data.shipping_address.name` | string |   |
| `data.shipping_address.line1` | string |   |
| `data.shipping_address.line2` | string |   |
| `data.shipping_address.postal_code` | string |   |
| `data.shipping_address.city` | string |   |
| `data.shipping_address.country` | string |   |
| `data.billing_address` | object |   |
| `data.billing_address.name` | string |   |
| `data.billing_address.line1` | string |   |
| `data.billing_address.line2` | string |   |
| `data.billing_address.postal_code` | string |   |
| `data.billing_address.city` | string |   |
| `data.billing_address.country` | string |   |
| `data.company_name` | string or null |   |
| `data.organisation_number` | string or null |   |
| `data.note_to_buyer` | string or null |   |
| `data.internal_note` | string or null |   |
| `data.request_note` | string or null | What the shopper wrote with a request for a quote. |
| `data.tags` | list of string |   |
| `data.discount` | object or null | A discount staff give on the whole draft, with the words the buyer sees. |
| `data.discount.kind` | one of `percent`, `amount` |   |
| `data.discount.percent` | number or null |   |
| `data.discount.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.discount.label` | string |   |
| `data.shipping` | object | rate: the market's shipping rate. custom: the amount given. |
| `data.shipping.kind` | one of `rate`, `free`, `custom` |   |
| `data.shipping.amount_minor` | integer or null | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.lines` | list of objects |   |
| `data.lines[].id` | string (uuid) |   |
| `data.lines[].kind` | one of `goods`, `custom` |   |
| `data.lines[].variant_id` | string (uuid) or null |   |
| `data.lines[].sku` | string |   |
| `data.lines[].title` | string |   |
| `data.lines[].quantity` | integer |   |
| `data.lines[].unit_price_minor` | integer | What one unit costs on the draft, VAT included. |
| `data.lines[].list_price_minor` | integer or null | The market's list price when the line was last saved; null for a custom item. |
| `data.lines[].custom_price` | boolean | A price given instead of the list price. |
| `data.lines[].price_requested` | boolean | A requested product priced on request with no price given yet: the draft cannot be sent until it has one. |
| `data.lines[].vat_category` | string or null |   |
| `data.total_minor` | integer or null | What the draft totals now, with shipping, the discount and VAT, as the order would; null when it cannot be worked out yet. |
| `data.blocking` | list of string | Why a send would be refused now, in words; empty when it can be sent. |
| `data.order_id` | string (uuid) or null | The order a sent draft made. |
| `data.sent_at` | string (date-time) or null |   |
| `data.expires_at` | string (date-time) or null | When a sent draft's pay link ends and its order is cancelled. |
| `data.created_at` | string (date-time) |   |
| `data.updated_at` | string (date-time) |   |

### Errors {#drafts-decline-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | [`conflict`](https://docs.kaizenaflow.com/reference/errors#conflict) | Nothing was done: it clashes with how things are now (nothing left to send), or an `Idempotency-Key` is in use or was used for another request. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#drafts-decline-example}

**curl**

```shell
curl -X POST 'https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/decline' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"reply":"example"}'
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/decline", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "reply": "example"
  }),
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/drafts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/decline",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "reply": "example",
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

---

https://docs.kaizenaflow.com/reference/admin-api/draft-orders · made from the API contract 1.57
