# Resty Orders API

Fetch unprinted kitchen tickets and receipts as full JSON, then mark each as printed over the API — ideal for kitchen printers, POS bridges, and AI agents.

## Authentication

Send your merchant Orders API key on every request. Never expose the key in public front-end code.

```http
X-Api-Key: YOUR_ORDERS_API_KEY
```

Alternatively: `Authorization: Bearer YOUR_ORDERS_API_KEY`

Generate or rotate the key in **Dashboard → Settings → Orders API**.

## 1) List unprinted orders (kitchen tickets)

```
GET https://resty.gr/api/public/orders/unprinted
```

Returns JSON with ok, username, currency, count, and an orders array. Only kitchen tickets with Printed = No are included (up to 500, oldest first). When an order was invoiced, invoice (Wrapp/receipt JSON) and invoice_receipt_printed are included; otherwise invoice is null.

Top-level keys: `ok`, `username`, `currency` (`code`, `symbol`, `label`, `position`), `count`, `orders`.
Each order may include `invoice` (saved Wrapp/receipt JSON) and `invoice_receipt_printed`.

### Example request

```bash
curl -sS -H "X-Api-Key: YOUR_ORDERS_API_KEY" "https://resty.gr/api/public/orders/unprinted"
```

### Example response

```json
{
    "ok": true,
    "username": "your_username",
    "currency": {
        "code": "EUR",
        "symbol": "€",
        "label": "EUR — Euro (€)",
        "position": "left"
    },
    "count": 1,
    "orders": [
        {
            "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "order_code": "A104",
            "username": "your_username",
            "currency": {
                "code": "EUR",
                "symbol": "€",
                "label": "EUR — Euro (€)",
                "position": "left"
            },
            "status_id": "…",
            "status_name": "Preparing",
            "status_color": "#22c55e",
            "order_mode": "in_store",
            "floor_table_id": "…",
            "floor_table_code": "T12",
            "customer_inputs": {
                "custom_fields": [
                    {
                        "label": "Name",
                        "value": "Maria"
                    },
                    {
                        "label": "Phone",
                        "value": "6900000000"
                    },
                    {
                        "label": "Address",
                        "value": ""
                    }
                ]
            },
            "custom_fields": [
                {
                    "label": "Name",
                    "value": "Maria"
                },
                {
                    "label": "Phone",
                    "value": "6900000000"
                },
                {
                    "label": "Address",
                    "value": ""
                }
            ],
            "cart_items": [
                {
                    "id": "line_…",
                    "product_id": "…",
                    "name": "Burger",
                    "quantity": 2,
                    "unit_price": 8.5,
                    "total_num": 17,
                    "comment": "No onions",
                    "option_labels": [
                        "Size: Large",
                        "Extra cheese"
                    ],
                    "options": [
                        {
                            "group_id": "…",
                            "group": "Size",
                            "item_id": "…",
                            "label": "Large",
                            "price_num": 1
                        },
                        {
                            "group_id": "…",
                            "group": "Extras",
                            "item_id": "…",
                            "label": "Extra cheese",
                            "price_num": 0.5
                        }
                    ],
                    "selections": {},
                    "thumb_url": ""
                }
            ],
            "cart_total": 17,
            "show_on_order_screen": true,
            "is_printed": false,
            "payment_method_type": null,
            "invoice": null,
            "invoice_receipt_printed": false,
            "created_at": "2026-07-20 12:00:00",
            "updated_at": "2026-07-20 12:01:00",
            "created_at_unix": 1721476800,
            "updated_at_unix": 1721476860
        }
    ]
}
```

## 2) Mark kitchen ticket as printed

```
POST https://resty.gr/api/public/orders/{orderId}/printed
```

Sets Printed = Yes for that order (owned by the API key’s merchant). Response includes username and currency. Idempotent: calling again still returns ok with already_printed true.

Replace `{orderId}` with the order `id` UUID from the list response.

### Example request

```bash
curl -sS -X POST -H "X-Api-Key: YOUR_ORDERS_API_KEY" "https://resty.gr/api/public/orders/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/printed"
```

### Example response

```json
{
    "ok": true,
    "username": "your_username",
    "currency": {
        "code": "EUR",
        "symbol": "€",
        "label": "EUR — Euro (€)",
        "position": "left"
    },
    "order_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "order_code": "A104",
    "is_printed": true,
    "already_printed": false
}
```

- `already_printed: true` means the order was already Yes; the call is still success.
- After a successful mark, the order no longer appears in the unprinted list.

## 3) List unprinted receipts

```
GET https://resty.gr/api/public/orders/unprinted-receipts
```

Returns orders that have saved invoice/receipt JSON and Receipt printed = No (up to 500, oldest first). Each cart_items[] includes vat_rate, net_total, and vat_total for receipt printing. Print using cart_items (+ invoice), then mark receipt-printed.

### Example request

```bash
curl -sS -H "X-Api-Key: YOUR_ORDERS_API_KEY" "https://resty.gr/api/public/orders/unprinted-receipts"
```

### Example response

```json
{
    "ok": true,
    "username": "your_username",
    "currency": {
        "code": "EUR",
        "symbol": "€",
        "label": "EUR — Euro (€)",
        "position": "left"
    },
    "count": 1,
    "orders": [
        {
            "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "order_code": "A104",
            "username": "your_username",
            "currency": {
                "code": "EUR",
                "symbol": "€",
                "label": "EUR — Euro (€)",
                "position": "left"
            },
            "status_id": "…",
            "status_name": "Completed",
            "status_color": "#22c55e",
            "order_mode": "in_store",
            "floor_table_id": "…",
            "floor_table_code": "T12",
            "customer_inputs": {
                "custom_fields": [
                    {
                        "label": "Name",
                        "value": "Maria"
                    },
                    {
                        "label": "Phone",
                        "value": "6900000000"
                    }
                ]
            },
            "custom_fields": [
                {
                    "label": "Name",
                    "value": "Maria"
                },
                {
                    "label": "Phone",
                    "value": "6900000000"
                }
            ],
            "cart_items": [
                {
                    "id": "line_…",
                    "product_id": "…",
                    "name": "Burger",
                    "quantity": 2,
                    "unit_price": 8.5,
                    "total_num": 17,
                    "net_total": 13.71,
                    "vat_total": 3.29,
                    "vat_rate": 24,
                    "vat_exemption_code": null,
                    "comment": "No onions",
                    "option_labels": [
                        "Size: Large"
                    ],
                    "options": [
                        {
                            "group_id": "…",
                            "group": "Size",
                            "item_id": "…",
                            "label": "Large",
                            "price_num": 1
                        }
                    ],
                    "selections": {},
                    "thumb_url": ""
                },
                {
                    "id": "line_…",
                    "product_id": "…",
                    "name": "Coffee",
                    "quantity": 1,
                    "unit_price": 2.5,
                    "total_num": 2.5,
                    "net_total": 2.21,
                    "vat_total": 0.29,
                    "vat_rate": 13,
                    "vat_exemption_code": null,
                    "comment": "",
                    "option_labels": [],
                    "options": [],
                    "selections": {},
                    "thumb_url": ""
                }
            ],
            "cart_total": 19.5,
            "show_on_order_screen": true,
            "is_printed": true,
            "payment_method_type": 0,
            "invoice": {
                "invoice_id": "wrapp-…",
                "mark": "123456789",
                "my_data_uid": "…",
                "my_data_qr_url": "https://…",
                "wrapp_invoice_url": "https://…",
                "pdf_url": "https://…",
                "pdf_status": "ready",
                "payment_method_type": 0,
                "pos_device_id": "",
                "sandbox": false,
                "has_pdf": true,
                "receipt_printed": false,
                "request_payload": {
                    "invoice_lines": [
                        {
                            "line_number": 1,
                            "name": "Burger",
                            "quantity": 2,
                            "unit_price": 6.85,
                            "net_total_price": 13.71,
                            "vat_rate": 24,
                            "vat_total": 3.29,
                            "subtotal": 17
                        },
                        {
                            "line_number": 2,
                            "name": "Coffee",
                            "quantity": 1,
                            "unit_price": 2.21,
                            "net_total_price": 2.21,
                            "vat_rate": 13,
                            "vat_total": 0.29,
                            "subtotal": 2.5
                        }
                    ]
                }
            },
            "invoice_receipt_printed": false,
            "created_at": "2026-07-20 12:00:00",
            "updated_at": "2026-07-20 12:05:00",
            "created_at_unix": 1721476800,
            "updated_at_unix": 1721477100
        }
    ]
}
```

Every order in this feed has a non-null `invoice` object. Use `invoice` (+ `cart_items`) to print the receipt, then mark it printed.

## 4) Mark receipt as printed

```
POST https://resty.gr/api/public/orders/{orderId}/receipt-printed
```

Sets invoice_receipt_printed = Yes and updates invoice.receipt_printed in the stored JSON. Idempotent. After success, the order leaves the unprinted-receipts feed.

### Example request

```bash
curl -sS -X POST -H "X-Api-Key: YOUR_ORDERS_API_KEY" "https://resty.gr/api/public/orders/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/receipt-printed"
```

### Example response

```json
{
    "ok": true,
    "username": "your_username",
    "currency": {
        "code": "EUR",
        "symbol": "€",
        "label": "EUR — Euro (€)",
        "position": "left"
    },
    "order_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "order_code": "A104",
    "invoice_receipt_printed": true,
    "already_printed": false
}
```

## Order object fields (list response)

| Field | Description |
| --- | --- |
| `id` | Order UUID (use this as {orderId} when marking printed). |
| `order_code` | Human-readable order code shown on the board. |
| `username` | Merchant username (also returned at the top level of the list/print response). |
| `currency` | Merchant display currency from Settings: {code, symbol, label, position} where position is left or right. Also returned at the top level. |
| `status_*` | Status id, name, and color. |
| `order_mode` | delivery | takeaway | in_store (or empty for legacy cards). |
| `floor_table_*` | Floor table id and code when in-store. |
| `customer_inputs` | Full inputs object (includes custom_fields and any extra keys). |
| `custom_fields` | All custom fields for the order as [{label, value}, …], including empty values. Same list is also under customer_inputs.custom_fields. |
| `cart_items` | Detailed cart lines (name, product_id, quantity, prices, VAT, comment, options, selections, thumb). |
| `cart_items[].quantity` | Quantity for the line (integer, min 1). |
| `cart_items[].unit_price` | Price for one unit (before quantity). |
| `cart_items[].total_num` | Line total = unit_price × quantity. |
| `cart_items[].net_total` | Line net amount (ex-VAT), derived from total_num and vat_rate. |
| `cart_items[].vat_total` | Line VAT amount. |
| `cart_items[].vat_rate` | VAT percent for the line (e.g. 24, 13, 6, 0). Defaults to 24 when missing on older orders. |
| `cart_items[].vat_exemption_code` | myDATA exemption code when vat_rate is 0; otherwise null. |
| `cart_items[].comment` | Optional kitchen/staff note for this line. |
| `cart_items[].options` | Selected options as [{group, label, price_num, …}] plus option_labels strings. |
| `cart_total` | Sum of line total_num values. |
| `show_on_order_screen` | Whether the order appears on the Order screen. |
| `invoice.request_payload.invoice_lines` | Wrapp invoice lines with vat_rate / vat_total (when stored on the invoice JSON). Useful alternate source for receipt layout. |
| `is_printed` | Kitchen ticket printed flag (always false in the unprinted list). |
| `payment_method_type` | Checkout payment type when invoiced: 0 = cash, 3 = card, 7 = IRIS; null if not set / forward only. |
| `invoice` | Saved Wrapp invoice/receipt JSON when the order was invoiced; null otherwise. Includes mark, pdf_url, has_pdf, receipt_printed, and related Wrapp fields. |
| `invoice_receipt_printed` | Receipt print flag (false in unprinted-receipts). Mark via POST …/receipt-printed. |
| `invoice.receipt_printed` | Same receipt flag mirrored inside invoice.receipt_printed (kept in sync with invoice_receipt_printed). |
| `created_at` / `updated_at` | MySQL datetime strings plus unix timestamps. |

## Receipt print tip

For each cart_items line, print name, quantity, total_num, then vat_rate (%) with net_total / vat_total underneath. The same rates are also under invoice.request_payload.invoice_lines[].vat_rate when present.

Example line layout:

```
2× Burger                 €17.00
   VAT 24%   net €13.71   VAT €3.29
1× Coffee                  €2.50
   VAT 13%   net €2.21    VAT €0.29
```

## Recommended automation flow

1. Poll `GET …/unprinted` every 5–15 seconds for kitchen tickets.
2. Print each ticket, then `POST …/orders/{id}/printed`.
3. Poll `GET …/unprinted-receipts` for invoiced orders; print using `invoice` + `cart_items`.
4. Call `POST …/orders/{id}/receipt-printed` so the receipt leaves that feed.

## AI / integration notes

Download the Markdown file and attach it to your agent instructions. Poll kitchen tickets (…/unprinted) and receipts (…/unprinted-receipts). On receipts, print each item with vat_rate / net_total / vat_total, then POST …/printed or …/receipt-printed.
