> For the complete documentation index, see [llms.txt](https://www.boxhero.io/docs/llms.txt). Every page is available as Markdown by appending `.md` to its URL; this page is [Markdown](https://www.boxhero.io/docs/de/developers/api/reference/sales-orders/create-sales-order.md).

# Create a sales order

> Creates a sales order.

Each item in `items[]` requires `price`. Set `finalize_immediately` with `location_id` to ship all ordered quantities immediately — the location must be covered by the team's plan or the request fails with `402`. `order_number` may only contain letters, numbers, hyphens, underscores, and whitespace; auto-generated when omitted.

`POST https://rest.boxhero-app.com/v1/sales-orders`

## Autorisierung

- `Authorization` (string, erforderlich): Bearer-Authentifizierungsheader im Format `Bearer <token>`, wobei `<token>` Ihr [API-Token](https://www.boxhero.io/docs/de/developers/api/authentication.md) ist.

## Anfragetext

- `order_number` (string): Order number. Whitespace is ignored and letters are uppercased. Use only letters, numbers, hyphens, and underscores. Auto-generated when omitted on create.
- `partner_id` (integer, minimum 0, maximum 2147483647, nullable): Supplier for purchase orders or customer for sales orders. Pass null to clear.
- `order_time` (string | number | string): ISO 8601 timestamp or millisecond epoch.
- `estimated_time` (string | number | string, nullable): ISO 8601 timestamp or millisecond epoch.
- `memo` (string, max length 2000)
- `custom_fields` (array of object): Ordered custom field name-value pairs.

  - `name` (string, erforderlich)
  - `value` (string, erforderlich)
- `currency_code` (string, min length 3, max length 3): ISO 4217 currency code. On create, defaults to the team's currency when omitted. On update, omitting it keeps the stored value; it cannot be cleared.
- `items` (array of object, erforderlich)

  - `item_id` (integer, minimum 0, maximum 2147483647): Existing item id. Mutually exclusive with item_sku, bundle_id, bundle_sku.
  - `item_sku` (string, min length 1, max length 255): Item SKU (case-insensitive). Mutually exclusive with item_id, bundle_id, bundle_sku.
  - `bundle_id` (integer, minimum 0, maximum 2147483647): Existing bundle id. Mutually exclusive with item_id, item_sku, bundle_sku.
  - `bundle_sku` (string, min length 1, max length 255): Bundle SKU (case-sensitive). Mutually exclusive with item_id, item_sku, bundle_id.
  - `quantity` (number, erforderlich): Quantity. May include up to four decimal places in core data.
  - `price` (string, erforderlich)
  - `tax` (LineTaxInput, nullable): Tax configuration for an order or return line.

    - `name` (string, min length 1, max length 255, erforderlich)
    - `rate` (string, erforderlich): Decimal value encoded as a string to avoid floating point drift.
    - `inclusive` (boolean, erforderlich)
  - `discount` (LineDiscountInput, nullable): Discount configuration for an order or return line.

    - `name` (string, min length 1, max length 255, erforderlich)
    - `type` (string, erforderlich): Discount type. `"percent"` is a 0-100 percentage; `"amount"` is an absolute amount.

      Mögliche Werte: `percent`, `amount`
    - `value` (string, erforderlich): Decimal value encoded as a string to avoid floating point drift.
- `costs` (array of OrderCostInput): Additional costs to attach, in display order. Included in total_price but not in any items\[\] figure.

  - `name` (string, min length 1, max length 255, erforderlich): Cost name.
  - `amount` (string, erforderlich): Cost amount. Negative for a deduction such as a prepayment. Additional costs carry no tax or discount, so the amount is the final value.
- `is_draft` (boolean): Create the order in draft status.
- `finalize_immediately` (boolean): Fulfill all lines immediately and mark the order done.
- `location_id` (integer, minimum 0, maximum 2147483647): Required when finalize_immediately is true.

## Antworten

**201** The created sales order's id.

- `id` (integer, minimum 0, maximum 2147483647, erforderlich): Created order id.

**400** Request validation failed (including an unknown `item_sku`/`bundle_sku`), core rejected the order, or the team is not in LOCATION mode.

- `id` (string, erforderlich): Unique exception id (`ex_` followed by 32 lowercase hex chars, no dashes — e.g. `ex_8f5c0c8e0e0a4a3c9b3f4f2c4f6c8d2a`). Quote this in support tickets so we can find the request in our logs.
- `type` (string, erforderlich): Stable, machine-readable error code (RFC 7807-style URI fragment). Branch your error handling on this, not on `title`.

  Mögliche Werte: `/errors/not-found`, `/errors/invalid-request`, `/errors/invalid-team-mode`, `/errors/tokens/invalid`, `/errors/tokens/required`, `/errors/too-many-requests`, `/errors/core/usage-limit-exceeded`, `/errors/core/forbidden`, `/errors/core/unhandled`, `/errors/unhandled`
- `title` (string, erforderlich): Human-readable summary of the error, in English.
- `correlationID` (string, erforderlich): Request correlation id (`rq_` followed by 32 lowercase hex chars, no dashes — e.g. `rq_01abf3...`). Identical to the `X-Correlation-Id` response header. A client-supplied `X-Correlation-Id` request header (at most 128 chars of `A-Z a-z 0-9 . _ : / = -`) is echoed back here and in the response header; a missing or invalid value is silently replaced with a generated `rq_…` id.
- `instance` (string): Pointer to the specific failing resource (e.g. `/items/12345`). Path-only, no `/v1` version prefix. Absent on unknown-path `404` and unexpected `500` responses.
- `code` (string): Sub-reason code surfaced from upstream BoxHero core (on core-mapped 4xx) or from the gateway itself (e.g. `not-available-for-api-token` on 403). Use this for fine-grained branching after dispatching on `type`.
- `errors` (array of object): Field-level error details. Present on request-validation `/errors/invalid-request` (400) responses. Absent on malformed-JSON `400`, `413` body-too-large, and most errors mapped from BoxHero core (which include it only when core supplies an array; this can include `403`). Each entry locates a single failure via JSONPath-like `path` segments and a human-readable `message`.

  - `path` (array of string | number, erforderlich)
  - `message` (string, erforderlich)

**401** Missing, invalid, or revoked API token. `/errors/tokens/required` when no Bearer token is sent; `/errors/tokens/invalid` when the token is unknown or revoked (a revoked token may keep working for up to 60 seconds because validation results are cached).

- `id` (string, erforderlich): Unique exception id (`ex_` followed by 32 lowercase hex chars, no dashes — e.g. `ex_8f5c0c8e0e0a4a3c9b3f4f2c4f6c8d2a`). Quote this in support tickets so we can find the request in our logs.
- `type` (string, erforderlich): Stable, machine-readable error code (RFC 7807-style URI fragment). Branch your error handling on this, not on `title`.

  Mögliche Werte: `/errors/not-found`, `/errors/invalid-request`, `/errors/invalid-team-mode`, `/errors/tokens/invalid`, `/errors/tokens/required`, `/errors/too-many-requests`, `/errors/core/usage-limit-exceeded`, `/errors/core/forbidden`, `/errors/core/unhandled`, `/errors/unhandled`
- `title` (string, erforderlich): Human-readable summary of the error, in English.
- `correlationID` (string, erforderlich): Request correlation id (`rq_` followed by 32 lowercase hex chars, no dashes — e.g. `rq_01abf3...`). Identical to the `X-Correlation-Id` response header. A client-supplied `X-Correlation-Id` request header (at most 128 chars of `A-Z a-z 0-9 . _ : / = -`) is echoed back here and in the response header; a missing or invalid value is silently replaced with a generated `rq_…` id.
- `instance` (string): Pointer to the specific failing resource (e.g. `/items/12345`). Path-only, no `/v1` version prefix. Absent on unknown-path `404` and unexpected `500` responses.
- `code` (string): Sub-reason code surfaced from upstream BoxHero core (on core-mapped 4xx) or from the gateway itself (e.g. `not-available-for-api-token` on 403). Use this for fine-grained branching after dispatching on `type`.
- `errors` (array of object): Field-level error details. Present on request-validation `/errors/invalid-request` (400) responses. Absent on malformed-JSON `400`, `413` body-too-large, and most errors mapped from BoxHero core (which include it only when core supplies an array; this can include `403`). Each entry locates a single failure via JSONPath-like `path` segments and a human-readable `message`.

  - `path` (array of string | number, erforderlich)
  - `message` (string, erforderlich)

**402** The team is over one of its plan limits (items, locations, or members). Upgrade the plan or reduce usage to continue.

- `id` (string, erforderlich): Unique exception id (`ex_` followed by 32 lowercase hex chars, no dashes — e.g. `ex_8f5c0c8e0e0a4a3c9b3f4f2c4f6c8d2a`). Quote this in support tickets so we can find the request in our logs.
- `type` (string, erforderlich): Stable, machine-readable error code (RFC 7807-style URI fragment). Branch your error handling on this, not on `title`.

  Mögliche Werte: `/errors/not-found`, `/errors/invalid-request`, `/errors/invalid-team-mode`, `/errors/tokens/invalid`, `/errors/tokens/required`, `/errors/too-many-requests`, `/errors/core/usage-limit-exceeded`, `/errors/core/forbidden`, `/errors/core/unhandled`, `/errors/unhandled`
- `title` (string, erforderlich): Human-readable summary of the error, in English.
- `correlationID` (string, erforderlich): Request correlation id (`rq_` followed by 32 lowercase hex chars, no dashes — e.g. `rq_01abf3...`). Identical to the `X-Correlation-Id` response header. A client-supplied `X-Correlation-Id` request header (at most 128 chars of `A-Z a-z 0-9 . _ : / = -`) is echoed back here and in the response header; a missing or invalid value is silently replaced with a generated `rq_…` id.
- `instance` (string): Pointer to the specific failing resource (e.g. `/items/12345`). Path-only, no `/v1` version prefix. Absent on unknown-path `404` and unexpected `500` responses.
- `code` (string): Sub-reason code surfaced from upstream BoxHero core (on core-mapped 4xx) or from the gateway itself (e.g. `not-available-for-api-token` on 403). Use this for fine-grained branching after dispatching on `type`.
- `errors` (array of object): Field-level error details. Present on request-validation `/errors/invalid-request` (400) responses. Absent on malformed-JSON `400`, `413` body-too-large, and most errors mapped from BoxHero core (which include it only when core supplies an array; this can include `403`). Each entry locates a single failure via JSONPath-like `path` segments and a human-readable `message`.

  - `path` (array of string | number, erforderlich)
  - `message` (string, erforderlich)

**413** Request body exceeds the size limit (1 MiB). Returned with type `/errors/invalid-request`.

- `id` (string, erforderlich): Unique exception id (`ex_` followed by 32 lowercase hex chars, no dashes — e.g. `ex_8f5c0c8e0e0a4a3c9b3f4f2c4f6c8d2a`). Quote this in support tickets so we can find the request in our logs.
- `type` (string, erforderlich): Stable, machine-readable error code (RFC 7807-style URI fragment). Branch your error handling on this, not on `title`.

  Mögliche Werte: `/errors/not-found`, `/errors/invalid-request`, `/errors/invalid-team-mode`, `/errors/tokens/invalid`, `/errors/tokens/required`, `/errors/too-many-requests`, `/errors/core/usage-limit-exceeded`, `/errors/core/forbidden`, `/errors/core/unhandled`, `/errors/unhandled`
- `title` (string, erforderlich): Human-readable summary of the error, in English.
- `correlationID` (string, erforderlich): Request correlation id (`rq_` followed by 32 lowercase hex chars, no dashes — e.g. `rq_01abf3...`). Identical to the `X-Correlation-Id` response header. A client-supplied `X-Correlation-Id` request header (at most 128 chars of `A-Z a-z 0-9 . _ : / = -`) is echoed back here and in the response header; a missing or invalid value is silently replaced with a generated `rq_…` id.
- `instance` (string): Pointer to the specific failing resource (e.g. `/items/12345`). Path-only, no `/v1` version prefix. Absent on unknown-path `404` and unexpected `500` responses.
- `code` (string): Sub-reason code surfaced from upstream BoxHero core (on core-mapped 4xx) or from the gateway itself (e.g. `not-available-for-api-token` on 403). Use this for fine-grained branching after dispatching on `type`.
- `errors` (array of object): Field-level error details. Present on request-validation `/errors/invalid-request` (400) responses. Absent on malformed-JSON `400`, `413` body-too-large, and most errors mapped from BoxHero core (which include it only when core supplies an array; this can include `403`). Each entry locates a single failure via JSONPath-like `path` segments and a human-readable `message`.

  - `path` (array of string | number, erforderlich)
  - `message` (string, erforderlich)

**429** Rate limit exceeded. Limits are per team and shared by all of the team's API tokens: 5 requests per second and 300 requests per minute. The `RateLimit` and `X-RateLimit-*` headers reflect the per-minute window; check them and `Retry-After` before retrying. This status is also returned when the client IP exceeds 30 failed authentication attempts within 60 seconds, even if the token is valid.

- `id` (string, erforderlich): Unique exception id (`ex_` followed by 32 lowercase hex chars, no dashes — e.g. `ex_8f5c0c8e0e0a4a3c9b3f4f2c4f6c8d2a`). Quote this in support tickets so we can find the request in our logs.
- `type` (string, erforderlich): Stable, machine-readable error code (RFC 7807-style URI fragment). Branch your error handling on this, not on `title`.

  Mögliche Werte: `/errors/not-found`, `/errors/invalid-request`, `/errors/invalid-team-mode`, `/errors/tokens/invalid`, `/errors/tokens/required`, `/errors/too-many-requests`, `/errors/core/usage-limit-exceeded`, `/errors/core/forbidden`, `/errors/core/unhandled`, `/errors/unhandled`
- `title` (string, erforderlich): Human-readable summary of the error, in English.
- `correlationID` (string, erforderlich): Request correlation id (`rq_` followed by 32 lowercase hex chars, no dashes — e.g. `rq_01abf3...`). Identical to the `X-Correlation-Id` response header. A client-supplied `X-Correlation-Id` request header (at most 128 chars of `A-Z a-z 0-9 . _ : / = -`) is echoed back here and in the response header; a missing or invalid value is silently replaced with a generated `rq_…` id.
- `instance` (string): Pointer to the specific failing resource (e.g. `/items/12345`). Path-only, no `/v1` version prefix. Absent on unknown-path `404` and unexpected `500` responses.
- `code` (string): Sub-reason code surfaced from upstream BoxHero core (on core-mapped 4xx) or from the gateway itself (e.g. `not-available-for-api-token` on 403). Use this for fine-grained branching after dispatching on `type`.
- `errors` (array of object): Field-level error details. Present on request-validation `/errors/invalid-request` (400) responses. Absent on malformed-JSON `400`, `413` body-too-large, and most errors mapped from BoxHero core (which include it only when core supplies an array; this can include `403`). Each entry locates a single failure via JSONPath-like `path` segments and a human-readable `message`.

  - `path` (array of string | number, erforderlich)
  - `message` (string, erforderlich)

Anfrage

**cURL**

```bash
curl --request POST \
  --url 'https://rest.boxhero-app.com/v1/sales-orders' \
  --header "Authorization: Bearer $BOXHERO_API_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
    "order_number": "PO-1001",
    "partner_id": 431485,
    "order_time": "2026-01-15T09:30:00.000Z",
    "estimated_time": "2026-01-20T00:00:00.000Z",
    "memo": "Restock for Q1",
    "currency_code": "USD",
    "items": [
      {
        "item_sku": "SKU-12345678",
        "quantity": 100,
        "price": "19.99"
      }
    ],
    "costs": [
      {
        "name": "Shipping fee",
        "amount": "45.00"
      }
    ]
  }'
```

**JavaScript**

```javascript
const response = await fetch("https://rest.boxhero-app.com/v1/sales-orders", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BOXHERO_API_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "order_number": "PO-1001",
    "partner_id": 431485,
    "order_time": "2026-01-15T09:30:00.000Z",
    "estimated_time": "2026-01-20T00:00:00.000Z",
    "memo": "Restock for Q1",
    "currency_code": "USD",
    "items": [
      {
        "item_sku": "SKU-12345678",
        "quantity": 100,
        "price": "19.99"
      }
    ],
    "costs": [
      {
        "name": "Shipping fee",
        "amount": "45.00"
      }
    ]
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.post(
    "https://rest.boxhero-app.com/v1/sales-orders",
    headers={
        "Authorization": "Bearer " + os.environ["BOXHERO_API_TOKEN"],
    },
    json={
        "order_number": "PO-1001",
        "partner_id": 431485,
        "order_time": "2026-01-15T09:30:00.000Z",
        "estimated_time": "2026-01-20T00:00:00.000Z",
        "memo": "Restock for Q1",
        "currency_code": "USD",
        "items": [
            {
                "item_sku": "SKU-12345678",
                "quantity": 100,
                "price": "19.99",
            },
        ],
        "costs": [
            {
                "name": "Shipping fee",
                "amount": "45.00",
            },
        ],
    },
)
data = response.json()
```

**HTTP**

```http
POST /v1/sales-orders HTTP/1.1
Host: rest.boxhero-app.com
Authorization: Bearer <token>
Content-Type: application/json

{
  "order_number": "PO-1001",
  "partner_id": 431485,
  "order_time": "2026-01-15T09:30:00.000Z",
  "estimated_time": "2026-01-20T00:00:00.000Z",
  "memo": "Restock for Q1",
  "currency_code": "USD",
  "items": [
    {
      "item_sku": "SKU-12345678",
      "quantity": 100,
      "price": "19.99"
    }
  ],
  "costs": [
    {
      "name": "Shipping fee",
      "amount": "45.00"
    }
  ]
}
```

Antwort

**201**

```json
{
  "id": 90101
}
```

**400**

```json
{
  "id": "ex_8f5c0c8e0e0a4a3c9b3f4f2c4f6c8d2a",
  "correlationID": "rq_01abf3c2b8e44a59be2a9c0f1e7d6a40",
  "type": "/errors/invalid-request",
  "title": "Request validation failed (including an unknown item_sku/bundle_sku), core rejected the order, or the team is not in LOCATION mode.",
  "instance": "/sales-orders"
}
```

**401**

```json
{
  "id": "ex_8f5c0c8e0e0a4a3c9b3f4f2c4f6c8d2a",
  "correlationID": "rq_01abf3c2b8e44a59be2a9c0f1e7d6a40",
  "type": "/errors/tokens/required",
  "title": "Missing API token. Provide a Bearer token in the Authorization header.",
  "instance": "/sales-orders",
  "example": "Bearer wqnot0dlysdg5vymubzi4kiv"
}
```

**402**

```json
{
  "id": "ex_8f5c0c8e0e0a4a3c9b3f4f2c4f6c8d2a",
  "correlationID": "rq_01abf3c2b8e44a59be2a9c0f1e7d6a40",
  "type": "/errors/core/usage-limit-exceeded",
  "title": "The team is over one of its plan limits (items, locations, or members). Upgrade the plan or reduce usage to continue.",
  "instance": "/sales-orders"
}
```

**413**

```json
{
  "id": "ex_8f5c0c8e0e0a4a3c9b3f4f2c4f6c8d2a",
  "correlationID": "rq_01abf3c2b8e44a59be2a9c0f1e7d6a40",
  "type": "/errors/invalid-request",
  "title": "Request body is too large.",
  "instance": "/sales-orders"
}
```

**429**

```json
{
  "id": "ex_8f5c0c8e0e0a4a3c9b3f4f2c4f6c8d2a",
  "correlationID": "rq_01abf3c2b8e44a59be2a9c0f1e7d6a40",
  "type": "/errors/too-many-requests",
  "title": "Too many requests.",
  "instance": "/sales-orders",
  "retryAfter": 60
}
```
