With the order addresses of the API you send orders from your online shop, ERP or inventory system straight into the warehouse. You ask how far each order has got, fetch the tracking numbers once it has left the warehouse, and change it as long as the warehouse has not started on it.

| What | Method and address | Permission of the token |
|---|---|---|
| Create an order | `POST /api/v1/orders` | Orders: create |
| List and search orders | `GET /api/v1/orders` | Orders: read |
| Orders in a status | `GET /api/v1/orders/status/{status}` | Orders: read |
| Count orders per status | `GET /api/v1/orders/status` | Orders: read |
| Query one order | `GET /api/v1/orders/{id}` | Orders: read |
| Change an order | `PATCH /api/v1/orders/{id}` | Orders: change |
| Change a position | `PATCH /api/v1/orders/{id}/positions/{position}` | Orders: change |
| Modules of the orders | `GET /api/v1/orders/modules` | Orders: read |

!!!
You find the complete description of every field in X-Sitter under **Settings > API documentation** (*Einstellungen > API-Dokumentation*) once you are logged in. There you can try every address right away with a token of your company.
!!!

## Step 1: Check the requirements

- Your user has the menu entry **Settings > API access** (*Einstellungen > API Zugang*) in X-Sitter and the permissions of the group **Orders** (*Aufträge*) your token is meant to get.
- Your company has the module the orders arrive in. Orders sent through the API land in the module **API** unless you name another one. `GET /api/v1/orders/modules` shows the modules of your company. Without the module the API refuses every order with `422 order_module_not_enabled`. As a logistician you assign modules under [Administration > Jobs & connections > Modules](../administration/jobs-and-connections.md#assign-modules-to-a-company); as a client, ask your logistician.
- The articles you ship exist in X-Sitter. The API finds them by their article number (`sku`). An article number X-Sitter does not know is taken anyway, but the order can only be processed once the article exists.

## Step 2: Create a token

1. Click your name in the top right corner of X-Sitter, then **Settings** (*Einstellungen*).
2. Choose **API access** (*API Zugang*) on the left.
3. In the **API token** section, enter a **Name** (*Bezeichnung*), e.g. "Shop orders".
4. In the group **Orders** (*Aufträge*), tick what your system needs: **read** (*lesen*) for status and tracking numbers, **create** (*anlegen*) for new orders, **change** (*ändern*) for corrections.
5. Click **Create token** (*Token anlegen*) and take the token (it starts with `xst_`) right away with **copy** (*kopieren*). It is shown only this one time.

!!!warning
The token is as valuable as a password. More about this in the [overview](overview.md#create-a-token).
!!!

## Step 3: Test the order as a dry run

Before you send real orders, try your request as a **dry run**. Send the header `X-XSitter-Dry-Run: true` with it. The request then runs as usual: the same checks, the same response with the same status code, also the same error messages. At the end, however, everything is rolled back: the order is not saved, the warehouse never sees it and no workflows run. To make sure, the response carries the header `X-XSitter-Dry-Run: true` as well.

Replace `xst_YOUR_TOKEN` in the examples with your token:

+++ cURL
```bash
curl -X POST "https://app.x-sitter.com/api/v1/orders" \
  -H "Authorization: Bearer xst_YOUR_TOKEN" \
  -H "X-XSitter-Dry-Run: true" \
  -H "Content-Type: application/json" \
  -d '{
    "order_id": "1000123",
    "delivery_address": {
      "first_name": "Jane",
      "last_name": "Doe",
      "street": "123 Maple Street",
      "zip": "12345",
      "city": "Anytown",
      "country": "DE",
      "email": "jane@example.com"
    },
    "positions": [
      { "sku": "SKU-100", "quantity": 2, "price": 19.99 }
    ]
  }'
```
+++ PHP
```php
<?php
$token = 'xst_YOUR_TOKEN';
$order = [
    'order_id' => '1000123',
    'delivery_address' => [
        'first_name' => 'Jane',
        'last_name' => 'Doe',
        'street' => '123 Maple Street',
        'zip' => '12345',
        'city' => 'Anytown',
        'country' => 'DE',
        'email' => 'jane@example.com',
    ],
    'positions' => [
        ['sku' => 'SKU-100', 'quantity' => 2, 'price' => 19.99],
    ],
];

$ch = curl_init('https://app.x-sitter.com/api/v1/orders');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($order),
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $token,
        'Content-Type: application/json',
        'X-XSitter-Dry-Run: true',
    ],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$result = json_decode($body, true);
print_r($status === 201 ? $result['data'] : $result['error']);
```
+++ Python
```python
import requests

token = "xst_YOUR_TOKEN"
order = {
    "order_id": "1000123",
    "delivery_address": {
        "first_name": "Jane",
        "last_name": "Doe",
        "street": "123 Maple Street",
        "zip": "12345",
        "city": "Anytown",
        "country": "DE",
        "email": "jane@example.com",
    },
    "positions": [{"sku": "SKU-100", "quantity": 2, "price": 19.99}],
}

response = requests.post(
    "https://app.x-sitter.com/api/v1/orders",
    json=order,
    headers={"Authorization": f"Bearer {token}", "X-XSitter-Dry-Run": "true"},
    timeout=30,
)
result = response.json()
print(result["data"] if response.ok else result["error"])
```
+++ JavaScript (Node.js)
```js
const token = 'xst_YOUR_TOKEN';
const order = {
    order_id: '1000123',
    delivery_address: {
        first_name: 'Jane',
        last_name: 'Doe',
        street: '123 Maple Street',
        zip: '12345',
        city: 'Anytown',
        country: 'DE',
        email: 'jane@example.com',
    },
    positions: [{ sku: 'SKU-100', quantity: 2, price: 19.99 }],
};

const response = await fetch('https://app.x-sitter.com/api/v1/orders', {
    method: 'POST',
    headers: {
        Authorization: `Bearer ${token}`,
        'Content-Type': 'application/json',
        'X-XSitter-Dry-Run': 'true',
    },
    body: JSON.stringify(order),
});
const result = await response.json();
console.log(response.ok ? result.data : result.error);
```
+++

If you get `201`, the order is fine. Leave out the header and the same call creates the order for real. Reading requests (`GET`) always run for real, the header changes nothing for them.

## Step 4: Create an order

An order needs three things: your order number, the delivery address and at least one position. Everything else is optional.

| Field | Meaning | Required |
|---|---|---|
| `order_id` | Your order number, up to 32 characters. Only once per module: a second order with the same number is refused with `409 order_number_taken`. | yes |
| `delivery_address` | The delivery address, see below. | yes |
| `positions` | The positions, see below. | yes |
| `order_number` | Number your customer knows, if it differs from `order_id`. | no |
| `order_date` | Order date, e.g. `2026-11-06`, `2026-11-06 14:30:00` or ISO 8601 with a time zone. Missing: now. | no |
| `module` | Module of the order, default `api`. `GET /api/v1/orders/modules` returns the possible values. | no |
| `platform` | Shop or marketplace the order was placed on, e.g. `webshop`. | no |
| `business` | `true` for a business customer. Default `false`. | no |
| `note` | Remark for the warehouse. | no |
| `customer_group` | Shortname of a [customer group](../products/customer-groups.md). Positions without a price get the price of this group; without the field, the default group applies. | no |

**Delivery address:** `company`, `first_name`, `last_name`, `street`, `house_number`, `add_on`, `zip`, `city`, `state`, `country`, `phone`, `email`. Required are `street`, `zip`, `city`, `country` (two letters according to ISO 3166-1, e.g. `DE`) and either `last_name` or `company`. The house number may be part of `street` or separate in `house_number`. X-Sitter stores every value as you send it.

**Positions:**

| Field | Meaning | Required |
|---|---|---|
| `sku` | Article number. Name, EAN and weight come from the article when the position does not name them. | yes |
| `quantity` | Pieces, at least 1. | yes |
| `name` | Name on the delivery note. Only required when X-Sitter does not know the article number. | no |
| `ean` | EAN, up to 13 characters. | no |
| `price` | Price of one piece. `0` or empty: price of the customer group. | no |
| `tax_rate` | Tax rate in percent, default 19. | no |
| `position` | Number of the line; missing: its place in the list. | no |
| `batch` | Batch the warehouse has to pick the position from, up to 32 characters. See [Batch per position](#batch-per-position). | no |

The response is `201` with the whole order as it was saved. The header `Location` names its address. Keep the field `id`: you use it to query and change the order later. The order starts in the status `open` and appears right away in the order overview of the warehouse.

## Step 5: Understand the response

A shipped order looks like this:

```json
{
  "data": {
    "id": "01a0ca21-c3a9-7f5a-b51d-6a62a4736f7a",
    "order_id": "1000123",
    "order_number": null,
    "company_id": 27,
    "module": "api",
    "platform": "webshop",
    "status": "sent",
    "business": false,
    "priority": 10,
    "order_date": "2026-11-06 09:30:00",
    "added_at": "2026-11-06 09:30:02",
    "updated_at": "2026-11-06 15:12:40",
    "shipped_at": "2026-11-06 15:12:40",
    "note": null,
    "delivery_address": { "first_name": "Jane", "last_name": "Doe", "street": "123 Maple Street", "zip": "12345", "city": "Anytown", "country": "DE" },
    "weight": 1.4,
    "tracking": {
      "carrier": "DHL",
      "parcels": [
        { "number": "00340434161094042557", "url": "https://www.dhl.de/..." }
      ]
    },
    "positions": [
      {
        "id": "01a0ca21-c469-75dc-9e51-965821f74267",
        "position": 1,
        "article_id": "0198314b-fa6b-71d6-bccd-2da190385b72",
        "sku": "SKU-100",
        "ean": "4006381333931",
        "name": "Spice mill",
        "quantity": 2,
        "delivered_quantity": 2,
        "price": 19.99,
        "tax_rate": 19,
        "weight": 1.2,
        "status": null,
        "bundle": null,
        "batch": null,
        "delivered_batches": [
          { "batch": "529674", "best_before": "2027-02-11", "quantity": 2 }
        ]
      }
    ]
  }
}
```

| Field | Meaning |
|---|---|
| `id` | ID of the order in X-Sitter. You use it to query and change the order. |
| `order_id` | Your order number. |
| `company_id` | Company number the order belongs to. |
| `status` | How far the order has got in the warehouse, see the table below. |
| `updated_at` | Last change. The filter `updated_since` compares with it. |
| `shipped_at` | When the order left the warehouse. |
| `weight` | Weight of the shipment in kg, once it is packed. |
| `tracking.carrier` | Carrier, e.g. `DHL`. |
| `tracking.parcels` | Per parcel the tracking number (`number`) and the link to the tracking page (`url`, `null` without a link). Empty until the order has left the warehouse. |
| `positions[].id` | ID of the position. You use it to change the position (step 7). |
| `positions[].delivered_quantity` | Pieces that left the warehouse. |
| `positions[].bundle` | `parent` for a set, `part` for an article of a set, otherwise `null`. See [Sets](#sets-bills-of-materials). |
| `positions[].batch` | The batch the position asks for, otherwise `null`. |
| `positions[].delivered_batches` | Per batch and best before date the pieces the position left the warehouse with, the oldest date first. Empty until the warehouse has picked. |

The most important values of `status` (all statuses explained in [Order statuses](../orders/order-statuses.md)):

| `status` | In the interface | Meaning |
|---|---|---|
| `open` | Open (*Offen*) | New, waits for picking. |
| `on_hold` | Pending (*Wartend*) | Held back. |
| `waiting_payment` | Payment receipt (*Zahlungseingang*) | Waits for the payment. |
| `faulty` | Error (*Fehler*) | Needs a look, e.g. because of an unknown article. |
| `on_picklist`, `in_progress`, `picked` | on the pick list, In progress, Picked | The warehouse is working on it. |
| `packed`, `wait_for_loading` | Packaged, waiting for loading | Packed, or picked and waiting for loading. |
| `process` | in shipping (*im Versand*) | Handed over to the carrier. |
| `sent` | Sent (*Versendet*) | Has left the warehouse, `tracking` is filled. |
| `partially_send` | partially shipped (*teilweise versendet*) | Shipped with a shortfall. |
| `cancelled` | Cancelled (*Storniert*) | Cancelled. |

## Step 6: Query status and tracking numbers

For a single order, call `GET /api/v1/orders/{id}`. For a regular sync, ask only for what has changed instead, for example every minute for the orders that were shipped since your last call:

```bash
curl "https://app.x-sitter.com/api/v1/orders/status/sent?updated_since=2026-11-06T08:00:00%2B01:00" \
  -H "Authorization: Bearer xst_YOUR_TOKEN"
```

Remember the time of every call and send it as `updated_since` the next time. Separate several statuses with commas, e.g. `/api/v1/orders/status/sent,cancelled`. `GET /api/v1/orders/status` counts how many orders are in which status.

### Narrow down the list

`GET /api/v1/orders` and `GET /api/v1/orders/status/{status}` know the same parameters:

| Parameter | Example | Effect |
|---|---|---|
| `q` | `q=Doe` | Part of the order number or of the delivery address. |
| `status` | `status=open,process` | Only orders in these statuses (only for `GET /api/v1/orders`). |
| `module` | `module=api` | Only orders of this module. |
| `platform` | `platform=webshop` | Only orders of this platform. |
| `order_id` | `order_id=1000123` | Exactly this order number. |
| `date_from`, `date_to` | `date_from=2026-11-01` | Order date from or up to this day. |
| `updated_since` | `updated_since=2026-11-06T08:00:00+01:00` | Only orders changed since then (a day or ISO 8601). |
| `sort` | `sort=updated` | Sorting by `order_date` (default), `added`, `updated` or `status`. |
| `direction` | `direction=asc` | `desc` (default) or `asc`. |
| `page`, `per_page` | `per_page=100` | Page and orders per page, default 25, **at most 100**, because every order brings its positions along. |

Write a `+` in the time zone as `%2B` in the address, otherwise it arrives as a space. How to fetch all pages one after the other is explained in the [overview](overview.md#fetching-lists-page-by-page).

## Step 7: Change an order

As long as the warehouse has not started on the order, you can change it. That works in the statuses `open`, `on_hold`, `faulty` and `waiting_payment`. Afterwards the API answers with `409 order_not_editable` and names the current status in `details.order_status`. Every change shows in the history of the order.

**Head of the order:** `PATCH /api/v1/orders/{id}` with the fields that change: `order_number`, `order_date`, `platform`, `business`, `note` and single fields of the `delivery_address`. An empty text removes an address field, but the address has to stay complete. Status, company and `order_id` never change here.

```bash
curl -X PATCH "https://app.x-sitter.com/api/v1/orders/01a0ca21-c3a9-7f5a-b51d-6a62a4736f7a" \
  -H "Authorization: Bearer xst_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "note": "Ring twice", "delivery_address": { "street": "125 Maple Street", "add_on": "" } }'
```

**Position:** `PATCH /api/v1/orders/{id}/positions/{position}` with `sku`, `name`, `ean`, `quantity`, `price`, `tax_rate` or `batch`. `{position}` is the `id` of the position from the response. Another `sku` or `quantity` sets article and weight of the position anew. Positions of a set (`bundle` is `parent` or `part`) cannot be changed.

```bash
curl -X PATCH "https://app.x-sitter.com/api/v1/orders/01a0ca21-c3a9-7f5a-b51d-6a62a4736f7a/positions/01a0ca21-c469-75dc-9e51-965821f74267" \
  -H "Authorization: Bearer xst_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "quantity": 3 }'
```

Both calls answer with the whole order after the change.

## Batch per position

If a position has to come from a specific batch, for example a lot of your ERP, send the batch in the field `batch` of the position:

```json
"positions": [
  { "sku": "SKU-100", "quantity": 1, "batch": "529674" }
]
```

- The warehouse then picks the position **only** from stock of this batch. If the batch is not enough, the missing quantity stays open. It is never filled up from another batch.
- Positions without `batch` run as usual; the warehouse then takes the oldest stock first.
- Upper and lower case and spaces at the start or end do not matter. The batch has to be named the way the warehouse keeps it (as recorded at goods receipt).
- Up to 32 characters. The API refuses a longer batch with `422 invalid_order`.
- As long as the warehouse has not started, you change the batch with `PATCH …/positions/{position}` and `"batch": "…"`; `"batch": null` or an empty text removes it.

As soon as the warehouse has picked, `delivered_batches` names per position the batches and best before dates the pieces left the warehouse with, also for positions that did not ask for a batch:

```json
"batch": "529674",
"delivered_batches": [
  { "batch": "529674", "best_before": "2027-02-11", "quantity": 1 }
]
```

`batch` or `best_before` is `null` when the stock had no batch or no date. In the order form of X-Sitter you set the same batch by hand in the column **Batch** (*Charge*) of the position.

## Sets (bills of materials)

If the `sku` of a position is a set from your catalogue, X-Sitter splits it into its parts. The set stays as a position with `bundle: "parent"` and is not picked. The parts follow as positions of their own with `bundle: "part"`; those are what the warehouse picks. A set has no batch of its own, its parts come from any batch.

## For logisticians: orders of a client

As a logistician you see your own orders and those of your clients in the lists. With the header `X-Company` and the company number of the client you work for this one client only. A new order then belongs to the client:

```bash
curl -X POST "https://app.x-sitter.com/api/v1/orders" \
  -H "Authorization: Bearer xst_YOUR_TOKEN" \
  -H "X-Company: 27" \
  -H "Content-Type: application/json" \
  -d @order.json
```

As a client you never need `X-Company`. You see and change only your own orders.

## Moving from api.x-sitter.com

The old API at `api.x-sitter.com` is being switched off, its functions now live here. What changes for your system:

- **No login call any more.** Instead of `GET /token` with `api-id` and `api-secret` you create a token once (step 2) and send it with every request. It does not expire after eight hours.
- **Dry run instead of sandbox.** The sandbox at `api.x-sitter.com/sandbox/` is gone; use the header `X-XSitter-Dry-Run: true` (step 3).
- **One shape for every response.** Data comes as `{"data": …, "meta": …}`, errors as `{"error": …}` with the matching HTTP status (the old API mostly answered with 406).

| Old (api.x-sitter.com) | New | What differs |
|---|---|---|
| `GET /orders` | `GET /api/v1/orders` | `limit` is `per_page`, `sort_by`/`sort_dir` are `sort`/`direction`, `order_date_from`/`order_date_to` are `date_from`/`date_to`, `modul` is `module`. |
| `GET /orders?status=process` | `GET /api/v1/orders/status/process` | Several statuses with commas. |
| `GET /order/{id}` | `GET /api/v1/orders/{id}` | `products` are `positions`, `package_weight` is `weight`, `tracking.deliverer` is `tracking.carrier`, `tracking.tracking_ids[].id` is `tracking.parcels[].number`. |
| `POST /order` | `POST /api/v1/orders` | `products` are `positions`, `modul` is `module`, `is_b2b` is `business`. Response `201` with the whole order; names are stored as they are sent. |
| `PUT /order/{id}` | `PATCH /api/v1/orders/{id}` | Only the fields you send change. |
| `PUT /order/{id}/product/{id}` | `PATCH /api/v1/orders/{id}/positions/{position}` | |
| `GET /modul` | `GET /api/v1/orders/modules` | |

Sets are no longer checked against the stock when an order comes in: every order is taken with all its sets and waits in the warehouse for missing goods.

## If something does not work

| Response | Cause | Solution |
|---|---|---|
| `401 missing_token`, `401 invalid_token` | Token missing, misspelt, locked or expired. | See [Query stock](stock.md#if-something-does-not-work). |
| `403 scope_missing` | The token lacks the permission of the address, `details.scope` names it. | Create a token with the permission from the group **Orders** (*Aufträge*). |
| `404 order_not_found` | The `id` does not exist, or the order does not belong to your company. | Use the `id` from the response, not your `order_id`. |
| `404 order_position_not_found` | The position does not belong to this order. | Use the `id` of the position from the response. |
| `409 order_number_taken` | The `order_id` already exists in the module, `details.existing_id` names the order. | Send another number or change the existing order. |
| `409 order_not_editable` | The warehouse is already working on the order or it is finished. | Clarify the change with your logistician. |
| `422 invalid_order` | Fields are missing or wrong. `details.problems` names all of them at once, e.g. `"delivery_address.zip": "is missing"`. | Correct the fields named. Unknown fields are named as well. |
| `422 order_module_not_enabled` | Your company does not have the module, `details.enabled` names its modules. | See step 1. |
