# Tickets

{% hint style="success" %}
Before you dive into the tickets API reference, it's a great idea to check out some articles that talk about different [ticket states](/api-reference/tickets/ticket-model-states.md), the [math used in tickets](/api-reference/tickets/ticket-model-mathematics.md).

Additionally, if you plan to both read and edit tickets, don't miss the article on [how tickets work with users' permissions](/api-reference/tickets/ticket-operations-and-user-rights.md).
{% endhint %}

## API methods

## Get tickets

<mark style="color:blue;">`GET`</mark> `http://{server-address}/tickets`

Returns all customers that matches query parameters. Result is of type [`QueryResult<Ticket>`](/data-models.md#queryresult).

#### Query Parameters

| Name                              | Type               | Description                                                                                                                                                                                                      |
| --------------------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| IsClosed                          | bool               | Option to retrieve only closed or only opened tickets, if value is specified. Supports NData syntax.                                                                                                             |
| HasCustomer                       | bool               | Only tickets with non-empty `Customer` field are returned, if value is set to `true`. Tickets with `Customer` field set to `null` are returned, if value is set to `false`. Supports NData syntax.               |
| HasDiscount                       | bool               | Only tickets with non-zero discount amount are returned, if value is set to `true`. Tickets with zero discount amount are returned, if value is set to `false`. Supports NData syntax.                           |
| HasNegativeItem                   | bool               | Only tickets with at least one item with negative total price are returned, if value is set to `true`. Tickets with positive items only are returned, if value is set to `false`. Supports NData syntax.         |
| HasReturnedItem                   | bool               | Only tickets with at least one item with type equal to `negative` are returned, if value is set to `true`. Tickets with non-negative items only are returned, if value is set to `false`. Supports NData syntax. |
| Id                                | string             | Supports NData syntax. Allows to filter based on `id` property.                                                                                                                                                  |
| ExternalId                        | string             | Supports NData syntax. Allows to filter based on `externalId` property.                                                                                                                                          |
| Name                              | string             | Supports NData syntax. Allows filter based on by `name` property.                                                                                                                                                |
| DeviceName                        | string\[]          | One or multiple comma separated values can be specified. If ticket is opened, value of `originDeviceName` property is compared. When closed, `closeInfo.deviceName` property is compared. Supports NData syntax. |
| PurchaseType                      | TicketPurchaseType | Supports NData syntax. Allows to filter based on `purchaseType` property.                                                                                                                                        |
| OriginDeviceName                  | string             | Supports NData syntax. Allows to filter based on `originDeviceName` property.                                                                                                                                    |
| CurrencyLabel                     | string             | Supports NData syntax. Allows to filter based on `currencyLabel` property.                                                                                                                                       |
| DiscountRate                      | decimal            | Supports NData syntax. Allows to filter based on `discountRate` property.                                                                                                                                        |
| OpenDate                          | DateTime           | Supports NData syntax. Allows to filter based on `openDate` property.                                                                                                                                            |
| CloseDate                         | DateTime           | Supports NData syntax. Allows to filter based on `closeDate` property.                                                                                                                                           |
| CloseInfoDeviceName               | string             | Supports NData syntax. Allows to filter based on `closeInfo.deviceName` property.                                                                                                                                |
| CloseInfoFiscalName               | string             | Supports NData syntax. Allows to filter based on `closeInfo.fiscalName` property.                                                                                                                                |
| CloseInfoNumber                   | int                | Supports NData syntax. Allows to filter based on `closeInfo.number` property.                                                                                                                                    |
| CloseInfoDailySalesReportNumber   | int                | Supports NData syntax. Allows to filter based on `closeInfo.dailySalesReportNumber` property.                                                                                                                    |
| CloseInfoFiscalMemorySerialNumber | string             | Supports NData syntax. Allows to filter based on `closeInfo.fiscalMemorySerialNumber` property.                                                                                                                  |
| LocationTableName                 | string             | Supports NData syntax. Allows to filter based on `location.tableName` property.                                                                                                                                  |
| LocationZoneName                  | string             | Supports NData syntax. Allows to filter based on `location.zoneName` property.                                                                                                                                   |
| CustomerCardSerialNumber          | string             | Supports NData syntax. Allows to filter based on `customer.cardSerialNumber` property.                                                                                                                           |
| EmployeeUserName                  | string             | Supports NData syntax. Allows to filter based on `employee.userName` property.                                                                                                                                   |
| ItemPluCode                       | int                | Supports NData syntax. Allows to filter based on `plu.code` property in `items` collection.                                                                                                                      |
| ItemPluStockName                  | string             | Supports NData syntax. Allows to filter based on `plu.stockName` property in `items` collection.                                                                                                                 |
| $skip                             | int                | Pagination property. Describing number of records to skip from beginning of result collection.                                                                                                                   |
| $take                             | int                | Pagination property. Maximum count of items to be returned.                                                                                                                                                      |
| $sort                             | string\[]          | Comma separated list of property names. Please see NData syntax.                                                                                                                                                 |
| $count                            | bool               | <p><br>If set to <code>true</code>, response will not contain <code>items</code> collection. Use to get resource count, not the resources themselves.</p>                                                        |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successful response" %}

```javascript
{
    "items":
    [
        {
            "id": "635f70e1fa3dab15784a0b45",
            "externalId": null,
            "state": "Closed",
            "type": "CashRegister",
            "name": "7",
            "openDate": "2022-10-31T06:53:20.76Z",
            "issueDate": null,
            "closeDate": "2022-10-31T07:05:43Z",
            "closeInfo":
            {
                "eKasa": null,
                "dailySalesReportNumber": 123,
                "number": 3,
                "fiscalMemorySerialNumber": "347...005",
                "fiscalName": "eKasa",
                "deviceName": "P01"
            },
            "purchaseType": "WalkIn",
            "location":
            {
                "zoneName": "Bar",
                "tableName": "B7"
            },
            "customer":
            {
                "id": null,
                "externalId": null,
                "cardSerialNumber": "customer-card-serial-number",
                "firstName": null,
                "lastName": null,
                "fullName": "John Doe",
                "gender": null,
                "birthDate": null,
                "address": null,
                "deliveryAddress": null,
                "isCompany": false,
                "company": null,
                "phone": null,
                "email": null,
                "creditRate": null,
                "meta":
                {}
            },
            "originDeviceName": "P01",
            "employee":
            {
                "name": "Mr. Waiter",
                "userName": "1",
                "featureName": null
            },
            "items":
            [
                {
                    "id": 1,
                    "externalId": null,
                    "type": "Positive",
                    "plu":
                    {
                        "name": "Cappucino",
                        "description": null,
                        "stockName": "S01",
                        "code": 9,
                        "articleCategoryLabel": "KAV",
                        "vatInfo":
                        {
                            "category": 1,
                            "rate": 20.0
                        },
                        "isDiscountAllowed": true,
                        "isPriceFixed": true,
                        "isSplittable": true,
                        "orderEndpointNames":
                        [
                            "Bar"
                        ],
                        "type": "Recipe",
                        "specialRegulation": null,
                        "isCashbackAllowed": true
                    },
                    "comment": null,
                    "unitPrice":
                    {
                        "amount": 2.083333,
                        "currencyLabel": "EUR"
                    },
                    "quantity":
                    {
                        "amount": 1.0,
                        "unit": "ks"
                    },
                    "discountRate": 0.0,
                    "referenceFiscalTicketId": null,
                    "voucherNumber": null,
                    "isQuantityFixed": false,
                    "courseNumber": null,
                    "subItems":
                    [
                        {
                            "id": 95674534,
                            "externalId": null,
                            "type": 0,
                            "plu":
                            {
                                "name": "Extra milk",
                                "description": null,
                                "stockName": "S01",
                                "code": 3001,
                                "articleCategoryLabel": "KAV",
                                "vatInfo":
                                {
                                    "category": 1,
                                    "rate": "5"
                                },
                                "isDiscountAllowed": true,
                                "isPriceFixed": false,
                                "isSplittable": true,
                                "orderEndpointNames":
                                [
                                    "Bar"
                                ],
                                "type": 2,
                                "specialRegulation": null,
                                "isCashbackAllowed": true
                            },
                            "quantity":
                            {
                                "amount": 1.0,
                                "unit": "ks"
                            },
                            "unitPrice":
                            {
                                "amount": 0.0,
                                "currencyLabel": "EUR"
                            },
                            "discountRate": 0.0,
                            "comment": null,
                            "voucherNumber": null,
                            "isQuantityFixed": false,
                            "modifier":
                            {
                                "id": "66681cbe9f5a50cd4e9a6b75",
                                "optionId": "66681cbe9f5a50cd4e9a6b75"
                            }
                        }
                    ]
                },
                {
                    "id": 2,
                    "externalId": null,
                    "type": "Positive",
                    "plu":
                    {
                        "name": "Espresso Doppio",
                        "description": null,
                        "stockName": "S01",
                        "code": 7,
                        "articleCategoryLabel": "KAV",
                        "vatInfo":
                        {
                            "category": 1,
                            "rate": 20.0
                        },
                        "isDiscountAllowed": true,
                        "isPriceFixed": true,
                        "isSplittable": true,
                        "orderEndpointNames":
                        [
                            "Bar"
                        ],
                        "type": "Recipe",
                        "specialRegulation": null,
                        "isCashbackAllowed": true
                    },
                    "comment": null,
                    "unitPrice":
                    {
                        "amount": 2.166667,
                        "currencyLabel": "EUR"
                    },
                    "quantity":
                    {
                        "amount": 1.0,
                        "unit": "ks"
                    },
                    "discountRate": 0.0,
                    "referenceFiscalTicketId": null,
                    "voucherNumber": null,
                    "isQuantityFixed": false,
                    "courseNumber": null,
                    "subItems":
                    [
                        {
                            "id": 95674367,
                            "externalId": null,
                            "type": 0,
                            "plu":
                            {
                                "name": "Extra milk",
                                "description": null,
                                "stockName": "S01",
                                "code": 3001,
                                "articleCategoryLabel": "KAV",
                                "vatInfo":
                                {
                                    "category": 1,
                                    "rate": "5"
                                },
                                "isDiscountAllowed": true,
                                "isPriceFixed": false,
                                "isSplittable": true,
                                "orderEndpointNames":
                                [
                                    "Bar"
                                ],
                                "type": 2,
                                "specialRegulation": null,
                                "isCashbackAllowed": true
                            },
                            "quantity":
                            {
                                "amount": 1.0,
                                "unit": "ks"
                            },
                            "unitPrice":
                            {
                                "amount": 0.0,
                                "currencyLabel": "EUR"
                            },
                            "discountRate": 0.0,
                            "comment": null,
                            "voucherNumber": null,
                            "isQuantityFixed": false,
                            "modifier":
                            {
                                "id": "66681cbe9f5a50cd4e9a6b75",
                                "optionId": "66681cbe9f5a50cd4e9a6b75"
                            }
                        }
                    ]
                },
                {
                    "id": 3,
                    "externalId": null,
                    "type": "Positive",
                    "plu":
                    {
                        "name": "Espresso",
                        "description": null,
                        "stockName": "S01",
                        "code": 1,
                        "articleCategoryLabel": "KAV",
                        "vatInfo":
                        {
                            "category": 1,
                            "rate": 20.0
                        },
                        "isDiscountAllowed": true,
                        "isPriceFixed": true,
                        "isSplittable": true,
                        "orderEndpointNames":
                        [
                            "Bar"
                        ],
                        "type": "Recipe",
                        "specialRegulation": null,
                        "isCashbackAllowed": true
                    },
                    "comment": null,
                    "unitPrice":
                    {
                        "amount": 1.416667,
                        "currencyLabel": "EUR"
                    },
                    "quantity":
                    {
                        "amount": 1.0,
                        "unit": "ks"
                    },
                    "discountRate": 0.0,
                    "referenceFiscalTicketId": null,
                    "voucherNumber": null,
                    "isQuantityFixed": false,
                    "courseNumber": null,
                    "subItems": null
                },
                {
                    "id": 4,
                    "externalId": null,
                    "type": "Positive",
                    "plu":
                    {
                        "name": "Mlieko",
                        "description": null,
                        "stockName": "S01",
                        "code": 49,
                        "articleCategoryLabel": "KAV",
                        "vatInfo":
                        {
                            "category": 1,
                            "rate": 20.0
                        },
                        "isDiscountAllowed": true,
                        "isPriceFixed": true,
                        "isSplittable": true,
                        "orderEndpointNames":
                        [
                            "Bar"
                        ],
                        "type": "Recipe",
                        "specialRegulation": null,
                        "isCashbackAllowed": true
                    },
                    "comment": null,
                    "unitPrice":
                    {
                        "amount": 0.25,
                        "currencyLabel": "EUR"
                    },
                    "quantity":
                    {
                        "amount": 1.0,
                        "unit": "ks"
                    },
                    "discountRate": 0.0,
                    "referenceFiscalTicketId": null,
                    "voucherNumber": null,
                    "isQuantityFixed": false,
                    "courseNumber": null,
                    "subItems": null
                }
            ],
            "payments":
            [
                {
                    "paymentType":
                    {
                        "number": 2,
                        "description": "Kreditná karta",
                        "isChangeable": false,
                        "category": "CreditCard"
                    },
                    "amount":
                    {
                        "amount": 6.73,
                        "currencyLabel": "EUR",
                        "domesticCurrencyLabel": "EUR",
                        "exchangeRate": 1.0
                    }
                }
            ],
            "currencyLabel": "EUR",
            "discountRate": 5.0,
            "roundingAmount":
            {
                "amount": 0.0,
                "currencyLabel": "EUR"
            },
            "invoiceNumber": null,
            "paragonNumber": null,
            "isParagon": false,
            "_v": 2
        }
    ],
    "count": 1,
    "totalCount": 258773
}
```

{% endtab %}
{% endtabs %}

## Get ticket

<mark style="color:blue;">`GET`</mark> `http://{server-address}/tickets/{id}`

Result is of type [`Ticket`](#ticket).

#### Query Parameters

| Name                                 | Type   | Description              |
| ------------------------------------ | ------ | ------------------------ |
| id<mark style="color:red;">\*</mark> | string | Unique ticket identifier |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Success response. Ticket is found." %}

```javascript
{
    "id": "635f70e1fa3dab15784a0b45",
    "externalId": null,
    "state": "Closed",
    "type": "CashRegister",
    "name": "7",
    "openDate": "2022-10-31T06:53:20.76Z",
    "issueDate": null,
    "closeDate": "2022-10-31T07:05:43Z",
    "closeInfo":
    {
        "eKasa": null,
        "dailySalesReportNumber": 123,
        "number": 3,
        "fiscalMemorySerialNumber": "347...005",
        "fiscalName": "eKasa",
        "deviceName": "P01"
    },
    "purchaseType": "WalkIn",
    "location":
    {
        "zoneName": "Bar",
        "tableName": "B7"
    },
    "customer":
    {
        "id": null,
        "externalId": null,
        "cardSerialNumber": "customer-card-serial-number",
        "firstName": null,
        "lastName": null,
        "fullName": "John Doe",
        "gender": null,
        "birthDate": null,
        "address": null,
        "deliveryAddress": null,
        "isCompany": false,
        "company": null,
        "phone": null,
        "email": null,
        "creditRate": null,
        "meta":
        {}
    },
    "originDeviceName": "P01",
    "employee":
    {
        "name": "Mr. Waiter",
        "userName": "1",
        "featureName": null
    },
    "items":
    [
        {
            "id": 1,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Cappucino",
                "description": null,
                "stockName": "S01",
                "code": 9,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.083333,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems":
            [
                {
                    "id": 95674534,
                    "externalId": null,
                    "type": 0,
                    "plu":
                    {
                        "name": "Extra milk",
                        "description": null,
                        "stockName": "S01",
                        "code": 3001,
                        "articleCategoryLabel": "KAV",
                        "vatInfo":
                        {
                            "category": 1,
                            "rate": "5"
                        },
                        "isDiscountAllowed": true,
                        "isPriceFixed": false,
                        "isSplittable": true,
                        "orderEndpointNames":
                        [
                            "Bar"
                        ],
                        "type": 2,
                        "specialRegulation": null,
                        "isCashbackAllowed": true
                    },
                    "quantity":
                    {
                        "amount": 1.0,
                        "unit": "ks"
                    },
                    "unitPrice":
                    {
                        "amount": 0.0,
                        "currencyLabel": "EUR"
                    },
                    "discountRate": 0.0,
                    "comment": null,
                    "voucherNumber": null,
                    "isQuantityFixed": false,
                    "modifier":
                    {
                        "id": "66681cbe9f5a50cd4e9a6b75",
                        "optionId": "66681cbe9f5a50cd4e9a6b75"
                    }
                }
            ]
        },
        {
            "id": 2,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso Doppio",
                "description": null,
                "stockName": "S01",
                "code": 7,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.166667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems":
            [
                {
                    "id": 95674367,
                    "externalId": null,
                    "type": 0,
                    "plu":
                    {
                        "name": "Extra milk",
                        "description": null,
                        "stockName": "S01",
                        "code": 3001,
                        "articleCategoryLabel": "KAV",
                        "vatInfo":
                        {
                            "category": 1,
                            "rate": "5"
                        },
                        "isDiscountAllowed": true,
                        "isPriceFixed": false,
                        "isSplittable": true,
                        "orderEndpointNames":
                        [
                            "Bar"
                        ],
                        "type": 2,
                        "specialRegulation": null,
                        "isCashbackAllowed": true
                    },
                    "quantity":
                    {
                        "amount": 1.0,
                        "unit": "ks"
                    },
                    "unitPrice":
                    {
                        "amount": 0.0,
                        "currencyLabel": "EUR"
                    },
                    "discountRate": 0.0,
                    "comment": null,
                    "voucherNumber": null,
                    "isQuantityFixed": false,
                    "modifier":
                    {
                        "id": "66681cbe9f5a50cd4e9a6b75",
                        "optionId": "66681cbe9f5a50cd4e9a6b75"
                    }
                }
            ]
        },
        {
            "id": 3,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso",
                "description": null,
                "stockName": "S01",
                "code": 1,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 1.416667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 4,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Mlieko",
                "description": null,
                "stockName": "S01",
                "code": 49,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 0.25,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        }
    ],
    "payments":
    [
        {
            "paymentType":
            {
                "number": 2,
                "description": "Kreditná karta",
                "isChangeable": false,
                "category": "CreditCard"
            },
            "amount":
            {
                "amount": 6.73,
                "currencyLabel": "EUR",
                "domesticCurrencyLabel": "EUR",
                "exchangeRate": 1.0
            }
        }
    ],
    "currencyLabel": "EUR",
    "discountRate": 5.0,
    "roundingAmount":
    {
        "amount": 0.0,
        "currencyLabel": "EUR"
    },
    "invoiceNumber": null,
    "paragonNumber": null,
    "isParagon": false,
    "_v": 2
}
```

{% endtab %}

{% tab title="404: Not Found Ticket with given ID is not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Create ticket

<mark style="color:green;">`POST`</mark> `http://{server-address}/tickets`

Creates new opened ticket. Result is of type [`Ticket`](#ticket).

**Required rights**

Please see [User rights required for creating and modifying ticket](/api-reference/tickets/ticket-operations-and-user-rights.md#creating-and-modifying-ticket) section.

**Required environments**

[Sale environment](/device-environments.md) required.

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type   | Description     |
| ---------------------------------------- | ------ | --------------- |
| (body)<mark style="color:red;">\*</mark> | Ticket | Model to create |

{% tabs %}
{% tab title="201: Created Successfuly created." %}

```javascript
{
    "id": "635f70e1fa3dab15784a0b45",
    "externalId": null,
    "state": "Closed",
    "type": "CashRegister",
    "name": "7",
    "openDate": "2022-10-31T06:53:20.76Z",
    "issueDate": null,
    "closeDate": "2022-10-31T07:05:43Z",
    "closeInfo":
    {
        "eKasa": null,
        "dailySalesReportNumber": 123,
        "number": 3,
        "fiscalMemorySerialNumber": "347...005",
        "fiscalName": "eKasa",
        "deviceName": "P01"
    },
    "purchaseType": "WalkIn",
    "location":
    {
        "zoneName": "Bar",
        "tableName": "B7"
    },
    "customer":
    {
        "id": null,
        "externalId": null,
        "cardSerialNumber": "customer-card-serial-number",
        "firstName": null,
        "lastName": null,
        "fullName": "John Doe",
        "gender": null,
        "birthDate": null,
        "address": null,
        "deliveryAddress": null,
        "isCompany": false,
        "company": null,
        "phone": null,
        "email": null,
        "creditRate": null,
        "meta":
        {}
    },
    "originDeviceName": "P01",
    "employee":
    {
        "name": "Mr. Waiter",
        "userName": "1",
        "featureName": null
    },
    "items":
    [
        {
            "id": 1,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Cappucino",
                "description": null,
                "stockName": "S01",
                "code": 9,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.083333,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems":
            [
                {
                    "id": 95674534,
                    "externalId": null,
                    "type": 0,
                    "plu":
                    {
                        "name": "Extra milk",
                        "description": null,
                        "stockName": "S01",
                        "code": 3001,
                        "articleCategoryLabel": "KAV",
                        "vatInfo":
                        {
                            "category": 1,
                            "rate": "5"
                        },
                        "isDiscountAllowed": true,
                        "isPriceFixed": false,
                        "isSplittable": true,
                        "orderEndpointNames":
                        [
                            "Bar"
                        ],
                        "type": 2,
                        "specialRegulation": null,
                        "isCashbackAllowed": true
                    },
                    "quantity":
                    {
                        "amount": 1.0,
                        "unit": "ks"
                    },
                    "unitPrice":
                    {
                        "amount": 0.0,
                        "currencyLabel": "EUR"
                    },
                    "discountRate": 0.0,
                    "comment": null,
                    "voucherNumber": null,
                    "isQuantityFixed": false,
                    "modifier":
                    {
                        "id": "66681cbe9f5a50cd4e9a6b75",
                        "optionId": "66681cbe9f5a50cd4e9a6b75"
                    }
                }
            ]
        },
        {
            "id": 2,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso Doppio",
                "description": null,
                "stockName": "S01",
                "code": 7,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.166667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems":
            [
                {
                    "id": 95674367,
                    "externalId": null,
                    "type": 0,
                    "plu":
                    {
                        "name": "Extra milk",
                        "description": null,
                        "stockName": "S01",
                        "code": 3001,
                        "articleCategoryLabel": "KAV",
                        "vatInfo":
                        {
                            "category": 1,
                            "rate": "5"
                        },
                        "isDiscountAllowed": true,
                        "isPriceFixed": false,
                        "isSplittable": true,
                        "orderEndpointNames":
                        [
                            "Bar"
                        ],
                        "type": 2,
                        "specialRegulation": null,
                        "isCashbackAllowed": true
                    },
                    "quantity":
                    {
                        "amount": 1.0,
                        "unit": "ks"
                    },
                    "unitPrice":
                    {
                        "amount": 0.0,
                        "currencyLabel": "EUR"
                    },
                    "discountRate": 0.0,
                    "comment": null,
                    "voucherNumber": null,
                    "isQuantityFixed": false,
                    "modifier":
                    {
                        "id": "66681cbe9f5a50cd4e9a6b75",
                        "optionId": "66681cbe9f5a50cd4e9a6b75"
                    }
                }
            ]
        },
        {
            "id": 3,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso",
                "description": null,
                "stockName": "S01",
                "code": 1,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 1.416667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 4,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Mlieko",
                "description": null,
                "stockName": "S01",
                "code": 49,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 0.25,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        }
    ],
    "payments":
    [
        {
            "paymentType":
            {
                "number": 2,
                "description": "Kreditná karta",
                "isChangeable": false,
                "category": "CreditCard"
            },
            "amount":
            {
                "amount": 6.73,
                "currencyLabel": "EUR",
                "domesticCurrencyLabel": "EUR",
                "exchangeRate": 1.0
            }
        }
    ],
    "currencyLabel": "EUR",
    "discountRate": 5.0,
    "roundingAmount":
    {
        "amount": 0.0,
        "currencyLabel": "EUR"
    },
    "invoiceNumber": null,
    "paragonNumber": null,
    "isParagon": false,
    "_v": 2
}
```

{% endtab %}
{% endtabs %}

## Create or update ticket

<mark style="color:orange;">`PUT`</mark> `http://{server-address}/tickets/{id}`

Creates new or updates existing opened ticket. Attempt to update closed ticket will result in HTTP Status 403 (Forbidden). Result is of type [`Ticket`](#ticket).

**Required rights**

Please see [User rights required for creating and modifying ticket](/api-reference/tickets/ticket-operations-and-user-rights.md#creating-and-modifying-ticket) section.

**Required environments**

[Sale environment](/device-environments.md) required.

#### Path Parameters

| Name                                 | Type   | Description              |
| ------------------------------------ | ------ | ------------------------ |
| id<mark style="color:red;">\*</mark> | string | Unique ticket identifier |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type   | Description                |
| ---------------------------------------- | ------ | -------------------------- |
| (body)<mark style="color:red;">\*</mark> | Ticket | Model to create or update. |

{% tabs %}
{% tab title="200: OK Successfuly created or updated." %}

```javascript
{
    "id": "635f70e1fa3dab15784a0b45",
    "externalId": null,
    "state": "Open",
    "type": "CashRegister",
    "name": "7",
    "openDate": "2022-10-31T06:53:20.76Z",
    "issueDate": null,
    "closeDate": null,
    "closeInfo": null,
    "purchaseType": "WalkIn",
    "location":
    {
        "zoneName": "Bar",
        "tableName": "B7"
    },
    "customer":
    {
        "id": null,
        "externalId": null,
        "cardSerialNumber": "customer-card-serial-number",
        "firstName": null,
        "lastName": null,
        "fullName": "John Doe",
        "gender": null,
        "birthDate": null,
        "address": null,
        "deliveryAddress": null,
        "isCompany": false,
        "company": null,
        "phone": null,
        "email": null,
        "creditRate": null,
        "meta":
        {}
    },
    "originDeviceName": "P01",
    "employee":
    {
        "name": "Mr. Waiter",
        "userName": "1",
        "featureName": null
    },
    "items":
    [
        {
            "id": 1,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Cappucino",
                "description": null,
                "stockName": "S01",
                "code": 9,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.083333,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 2,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso Doppio",
                "description": null,
                "stockName": "S01",
                "code": 7,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.166667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 3,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso",
                "description": null,
                "stockName": "S01",
                "code": 1,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 1.416667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 4,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Mlieko",
                "description": null,
                "stockName": "S01",
                "code": 49,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 0.25,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        }
    ],
    "payments": [],
    "currencyLabel": "EUR",
    "discountRate": 5.0,
    "roundingAmount": null,
    "invoiceNumber": null,
    "paragonNumber": null,
    "isParagon": false,
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Batch tickets update

<mark style="color:purple;">`PATCH`</mark> `http://{server-address}/tickets`

Preforms batch update of one or more [tickets](/data-models.md#ticket). Collection of affected [tickets](/data-models.md#ticket) is returned.

**Required rights**

Please see [User rights required for creating and modifying ticket](/api-reference/tickets/ticket-operations-and-user-rights.md#creating-and-modifying-ticket) section.

**Required environments**

[Sale environment](/device-environments.md) required.

#### Path Parameters

| Name   | Type                | Description                         |
| ------ | ------------------- | ----------------------------------- |
| action | TicketsUpdateAction | Specifies ticket batch update mode. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successfully patched." %}

```javascript
{
    "id": "635f70e1fa3dab15784a0b45",
    "externalId": null,
    "state": "Open",
    "type": "CashRegister",
    "name": "7",
    "openDate": "2022-10-31T06:53:20.76Z",
    "issueDate": null,
    "closeDate": null,
    "closeInfo": null,
    "purchaseType": "WalkIn",
    "location":
    {
        "zoneName": "Bar",
        "tableName": "B7"
    },
    "customer":
    {
        "id": null,
        "externalId": null,
        "cardSerialNumber": "customer-card-serial-number",
        "firstName": null,
        "lastName": null,
        "fullName": "John Doe",
        "gender": null,
        "birthDate": null,
        "address": null,
        "deliveryAddress": null,
        "isCompany": false,
        "company": null,
        "phone": null,
        "email": null,
        "creditRate": null,
        "meta":
        {}
    },
    "originDeviceName": "P01",
    "employee":
    {
        "name": "Mr. Waiter",
        "userName": "1",
        "featureName": null
    },
    "items":
    [
        {
            "id": 1,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Cappucino",
                "description": null,
                "stockName": "S01",
                "code": 9,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.083333,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 2,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso Doppio",
                "description": null,
                "stockName": "S01",
                "code": 7,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.166667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 3,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso",
                "description": null,
                "stockName": "S01",
                "code": 1,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 1.416667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 4,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Mlieko",
                "description": null,
                "stockName": "S01",
                "code": 49,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 0.25,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        }
    ],
    "payments":
    [],
    "currencyLabel": "EUR",
    "discountRate": 5.0,
    "roundingAmount": null,
    "invoiceNumber": null,
    "paragonNumber": null,
    "isParagon": false,
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Delete ticket

<mark style="color:red;">`DELETE`</mark> `http://{server-address}/tickets/{id}`

**Required rights**

Please see [User rights required for deleting ticket](/api-reference/tickets/ticket-operations-and-user-rights.md#deleting-ticket) section.

**Required environments**

[Sale environment](/device-environments.md) required.

#### Path Parameters

| Name                                 | Type   | Description              |
| ------------------------------------ | ------ | ------------------------ |
| id<mark style="color:red;">\*</mark> | string | Unique ticket identifier |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successfuly deleted." %}

```javascript
{
    "id": "635f70e1fa3dab15784a0b45",
    "externalId": null,
    "state": "Open",
    "type": "CashRegister",
    "name": "7",
    "openDate": "2022-10-31T06:53:20.76Z",
    "issueDate": null,
    "closeDate": null,
    "closeInfo": null,
    "purchaseType": "WalkIn",
    "location":
    {
        "zoneName": "Bar",
        "tableName": "B7"
    },
    "customer":
    {
        "id": null,
        "externalId": null,
        "cardSerialNumber": "customer-card-serial-number",
        "firstName": null,
        "lastName": null,
        "fullName": "John Doe",
        "gender": null,
        "birthDate": null,
        "address": null,
        "deliveryAddress": null,
        "isCompany": false,
        "company": null,
        "phone": null,
        "email": null,
        "creditRate": null,
        "meta":
        {}
    },
    "originDeviceName": "P01",
    "employee":
    {
        "name": "Mr. Waiter",
        "userName": "1",
        "featureName": null
    },
    "items":
    [
        {
            "id": 1,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Cappucino",
                "description": null,
                "stockName": "S01",
                "code": 9,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.083333,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 2,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso Doppio",
                "description": null,
                "stockName": "S01",
                "code": 7,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.166667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 3,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso",
                "description": null,
                "stockName": "S01",
                "code": 1,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 1.416667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 4,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Mlieko",
                "description": null,
                "stockName": "S01",
                "code": 49,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 0.25,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        }
    ],
    "payments": [],
    "currencyLabel": "EUR",
    "discountRate": 5.0,
    "roundingAmount": null,
    "invoiceNumber": null,
    "paragonNumber": null,
    "isParagon": false,
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## RPC Actions

These API methods trigger specific actions on server. However, it's important to note that depending on the type of selected [fiscal device](/data-models.md#fiscal) or [order endpoint device](/data-models.md#orderendpoint), some methods may not be supported. Furthermore, if an action is attempted on an inactive [fiscal device](/data-models.md#fiscal) or [order endpoint device](/data-models.md#orderendpoint), it will lead to failure. In both scenarios, making API calls will generate an HTTP status code of 403.

## Close ticket

<mark style="color:green;">`POST`</mark> `http://{server-address}/tickets/{id}/close`

Fiscalizes specific ticket (prints receipt or sends email receipt)and changes it's state to *closed*. Request body contains `TicketCloseContext` class. [Ticket](/data-models.md#ticket) is returned in response body.

**Required rights**

Please see [User rights required for closing ticket](/api-reference/tickets/ticket-operations-and-user-rights.md#closing-ticket) section.

**Required environments**

[Sale environment](/device-environments.md) required.

#### Path Parameters

| Name                                 | Type   | Description               |
| ------------------------------------ | ------ | ------------------------- |
| id<mark style="color:red;">\*</mark> | string | Unique ticket identifier. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type               | Description        |
| ---------------------------------------- | ------------------ | ------------------ |
| (body)<mark style="color:red;">\*</mark> | TicketCloseContext | The close options. |

{% tabs %}
{% tab title="200: OK Ticket is successfully closed." %}

```json
{
    "id": "635f70e1fa3dab15784a0b45",
    "externalId": null,
    "state": "Closed",
    "type": "CashRegister",
    "name": "7",
    "openDate": "2022-10-31T06:53:20.76Z",
    "issueDate": null,
    "closeDate": "2022-10-31T07:05:43Z",
    "closeInfo":
    {
        "eKasa": null,
        "dailySalesReportNumber": 123,
        "number": 3,
        "fiscalMemorySerialNumber": "347...005",
        "fiscalName": "eKasa",
        "deviceName": "P01"
    },
    "purchaseType": "WalkIn",
    "location":
    {
        "zoneName": "Bar",
        "tableName": "B7"
    },
    "customer":
    {
        "id": null,
        "externalId": null,
        "cardSerialNumber": "customer-card-serial-number",
        "firstName": null,
        "lastName": null,
        "fullName": "John Doe",
        "gender": null,
        "birthDate": null,
        "address": null,
        "deliveryAddress": null,
        "isCompany": false,
        "company": null,
        "phone": null,
        "email": null,
        "creditRate": null,
        "meta":
        {}
    },
    "originDeviceName": "P01",
    "employee":
    {
        "name": "Mr. Waiter",
        "userName": "1",
        "featureName": null
    },
    "items":
    [
        {
            "id": 1,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Cappucino",
                "description": null,
                "stockName": "S01",
                "code": 9,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.083333,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 2,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso Doppio",
                "description": null,
                "stockName": "S01",
                "code": 7,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 2.166667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 3,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Espresso",
                "description": null,
                "stockName": "S01",
                "code": 1,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 1.416667,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        },
        {
            "id": 4,
            "externalId": null,
            "type": "Positive",
            "plu":
            {
                "name": "Mlieko",
                "description": null,
                "stockName": "S01",
                "code": 49,
                "articleCategoryLabel": "KAV",
                "vatInfo":
                {
                    "category": 1,
                    "rate": 20.0
                },
                "isDiscountAllowed": true,
                "isPriceFixed": true,
                "isSplittable": true,
                "orderEndpointNames":
                [
                    "Bar"
                ],
                "type": "Recipe",
                "specialRegulation": null,
                "isCashbackAllowed": true
            },
            "comment": null,
            "unitPrice":
            {
                "amount": 0.25,
                "currencyLabel": "EUR"
            },
            "quantity":
            {
                "amount": 1.0,
                "unit": "ks"
            },
            "discountRate": 0.0,
            "referenceFiscalTicketId": null,
            "voucherNumber": null,
            "isQuantityFixed": false,
            "courseNumber": null,
            "subItems": null
        }
    ],
    "payments":
    [
        {
            "paymentType":
            {
                "number": 2,
                "description": "Kreditná karta",
                "isChangeable": false,
                "category": "CreditCard"
            },
            "amount":
            {
                "amount": 6.73,
                "currencyLabel": "EUR",
                "domesticCurrencyLabel": "EUR",
                "exchangeRate": 1.0
            }
        }
    ],
    "currencyLabel": "EUR",
    "discountRate": 5.0,
    "roundingAmount":
    {
        "amount": 0.0,
        "currencyLabel": "EUR"
    },
    "invoiceNumber": null,
    "paragonNumber": null,
    "isParagon": false,
    "_v": 2
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Print preliminary ticket

<mark style="color:green;">`POST`</mark> `http://{server-address}/tickets/{id}/print_preliminary_ticket`

Prints *preliminary receipt* on specified [order endpoint](/data-models.md#orderendpoint).

A preliminary receipt, often referred to as a "pre-check" or "provisional bill," is a document provided to diners before they make the final payment for their meal. This receipt outlines the items ordered and their associated costs, offering customers an initial overview of their expenses. This lets customer review the details before the final bill is issued.

The ticket's state remains unchanged. This action can be executed on both opened and closed tickets.

**Required rights**

Please see [User rights required for ](/api-reference/tickets/ticket-operations-and-user-rights.md#closing-ticket)[printing preliminary ticket](/api-reference/tickets/ticket-operations-and-user-rights.md#printing-preliminary-ticket) section.

**Required environments**

[Sale environment](/device-environments.md) required.

#### Path Parameters

| Name   | Type                | Description                         |
| ------ | ------------------- | ----------------------------------- |
| action | TicketsUpdateAction | Specifies ticket batch update mode. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name   | Type                          | Description                                                                                                                                  |
| ------ | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| (body) | PrintPreliminaryTicketContext | The [`PrintPreliminaryTicketContext`](/data-models.md#printpreliminaryticketcontext) object containing preliminary receipt printing options. |

{% tabs %}
{% tab title="204: No Content Preliminary ticket successfully printed." %}
The response contains no content.
{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.portos.sk/api-reference/tickets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
