# Open ticket

::: info
Har bir javob umumiy konvertda qaytadi — `code`, `message`, `messages`, `status_code`, `time` — foydali yuk esa `data` ichida. Quyidagi jadvallar faqat `data` ichini tavsiflaydi.
:::

## POST /open-ticket/create

Create an open ticket (a held order / table bill) with its draft receipt and products.

**Kerakli ruxsat:** `open_ticket_create` · [ruxsatlar qanday ishlaydi](https://docs.bito.uz/api/permissions.md)

**So‘rov namunasi**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/open-ticket/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "organization_id": "string",
  "receipt": {
    "organization_id": "string",
    "warehouse_id": "string",
    "customer_id": "string",
    "responsible_id": "string",
    "currency_id": "string",
    "price_id": "string",
    "note": "string",
    "products": [
      {
        "product_id": null,
        "warehouse_id": null,
        "amount": null,
        "price": null,
        "box_count": null,
        "note": null,
        "price_id": null,
        "box_amount": null,
        "real_price": null,
        "total_price": null,
        "taxes": null,
        "discounts": null,
        "is_marked": null,
        "marks": null,
        "expiration_date": null,
        "total_to_pay": null,
        "materials": null,
        "used_measure": null
      }
    ],
    "uuid": "string",
    "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "delivery_date": "2025-05-01T12:00:00Z",
    "delivery_address": {
      "long": 0,
      "lat": 0,
      "human_address": {
        "address": null,
        "city": null,
        "state": null,
        "zip": null
      },
      "bearing": 0
    },
    "discounts": [
      {
        "is_custom": null,
        "_id": null,
        "value": null,
        "name": null,
        "apply_type": null
      }
    ],
    "calc_tax_after_discount": false,
    "calc_sale_discount_after_product": true,
    "total_to_pay": 0,
    "sold_at": "2025-05-01T12:00:00Z",
    "mediator_id": "64b7f4d9e2b3b6a0b7c5d7ff"
  }
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/open-ticket/create', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "name": "string",
    "organization_id": "string",
    "receipt": {
      "organization_id": "string",
      "warehouse_id": "string",
      "customer_id": "string",
      "responsible_id": "string",
      "currency_id": "string",
      "price_id": "string",
      "note": "string",
      "products": [
        {
          "product_id": null,
          "warehouse_id": null,
          "amount": null,
          "price": null,
          "box_count": null,
          "note": null,
          "price_id": null,
          "box_amount": null,
          "real_price": null,
          "total_price": null,
          "taxes": null,
          "discounts": null,
          "is_marked": null,
          "marks": null,
          "expiration_date": null,
          "total_to_pay": null,
          "materials": null,
          "used_measure": null
        }
      ],
      "uuid": "string",
      "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "delivery_date": "2025-05-01T12:00:00Z",
      "delivery_address": {
        "long": 0,
        "lat": 0,
        "human_address": {
          "address": null,
          "city": null,
          "state": null,
          "zip": null
        },
        "bearing": 0
      },
      "discounts": [
        {
          "is_custom": null,
          "_id": null,
          "value": null,
          "name": null,
          "apply_type": null
        }
      ],
      "calc_tax_after_discount": false,
      "calc_sale_discount_after_product": true,
      "total_to_pay": 0,
      "sold_at": "2025-05-01T12:00:00Z",
      "mediator_id": "64b7f4d9e2b3b6a0b7c5d7ff"
    }
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/open-ticket/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "name": "string",
        "organization_id": "string",
        "receipt": {
            "organization_id": "string",
            "warehouse_id": "string",
            "customer_id": "string",
            "responsible_id": "string",
            "currency_id": "string",
            "price_id": "string",
            "note": "string",
            "products": [
                {
                    "product_id": None,
                    "warehouse_id": None,
                    "amount": None,
                    "price": None,
                    "box_count": None,
                    "note": None,
                    "price_id": None,
                    "box_amount": None,
                    "real_price": None,
                    "total_price": None,
                    "taxes": None,
                    "discounts": None,
                    "is_marked": None,
                    "marks": None,
                    "expiration_date": None,
                    "total_to_pay": None,
                    "materials": None,
                    "used_measure": None,
                },
            ],
            "uuid": "string",
            "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
            "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d7ff",
            "delivery_date": "2025-05-01T12:00:00Z",
            "delivery_address": {
                "long": 0,
                "lat": 0,
                "human_address": {
                    "address": None,
                    "city": None,
                    "state": None,
                    "zip": None,
                },
                "bearing": 0,
            },
            "discounts": [
                {
                    "is_custom": None,
                    "_id": None,
                    "value": None,
                    "name": None,
                    "apply_type": None,
                },
            ],
            "calc_tax_after_discount": False,
            "calc_sale_discount_after_product": True,
            "total_to_pay": 0,
            "sold_at": "2025-05-01T12:00:00Z",
            "mediator_id": "64b7f4d9e2b3b6a0b7c5d7ff",
        },
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "name": "string",
  "organization_id": "string",
  "receipt": {
    "organization_id": "string",
    "warehouse_id": "string",
    "customer_id": "string",
    "responsible_id": "string",
    "currency_id": "string",
    "price_id": "string",
    "note": "string",
    "products": [
      {
        "product_id": null,
        "warehouse_id": null,
        "amount": null,
        "price": null,
        "box_count": null,
        "note": null,
        "price_id": null,
        "box_amount": null,
        "real_price": null,
        "total_price": null,
        "taxes": null,
        "discounts": null,
        "is_marked": null,
        "marks": null,
        "expiration_date": null,
        "total_to_pay": null,
        "materials": null,
        "used_measure": null
      }
    ],
    "uuid": "string",
    "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "delivery_date": "2025-05-01T12:00:00Z",
    "delivery_address": {
      "long": 0,
      "lat": 0,
      "human_address": {
        "address": null,
        "city": null,
        "state": null,
        "zip": null
      },
      "bearing": 0
    },
    "discounts": [
      {
        "is_custom": null,
        "_id": null,
        "value": null,
        "name": null,
        "apply_type": null
      }
    ],
    "calc_tax_after_discount": false,
    "calc_sale_discount_after_product": true,
    "total_to_pay": 0,
    "sold_at": "2025-05-01T12:00:00Z",
    "mediator_id": "64b7f4d9e2b3b6a0b7c5d7ff"
  }
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/open-ticket/create');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `name` | `string` | Ha | Display name of the open ticket |
| `organization_id` | `string` | Ha | Organization ObjectId the ticket belongs to |
| `booking_table_id` | `string` | Yo‘q | Booking table (seat/table) ObjectId, if the ticket is tied to a table |
| `comment` | `string` | Yo‘q | Optional free-text comment |
| `receipt` | `object` | Ha |  |
| `receipt.organization_id` | `string` | Ha |  |
| `receipt.warehouse_id` | `string` | Ha |  |
| `receipt.customer_id` | `string` | Yo‘q |  |
| `receipt.responsible_id` | `string` | Yo‘q |  |
| `receipt.currency_id` | `string` | Ha |  |
| `receipt.price_id` | `string` | Yo‘q |  |
| `receipt.note` | `string` | Yo‘q |  |
| `receipt.products` | `object[]` | Ha |  |
| `receipt.products[].product_id` | `string` | Ha |  |
| `receipt.products[].warehouse_id` | `string` | Ha |  |
| `receipt.products[].amount` | `number` | Ha |  |
| `receipt.products[].price` | `number` | Yo‘q |  |
| `receipt.products[].box_count` | `number` | Yo‘q |  |
| `receipt.products[].note` | `string` | Yo‘q |  |
| `receipt.products[].price_id` | `string` | Yo‘q |  |
| `receipt.products[].box_amount` | `number` | Yo‘q |  |
| `receipt.products[].real_price` | `number` | Ha |  |
| `receipt.products[].total_price` | `number` | Yo‘q |  |
| `receipt.products[].taxes` | `object[]` | Yo‘q |  |
| `receipt.products[].discounts` | `object[]` | Yo‘q |  |
| `receipt.products[].is_marked` | `boolean` | Yo‘q | Standart: `false` |
| `receipt.products[].marks` | `string[]` | Yo‘q |  |
| `receipt.products[].expiration_date` | `string (date-time)` | Yo‘q |  |
| `receipt.products[].total_to_pay` | `number` | Yo‘q |  |
| `receipt.products[].materials` | `object[]` | Yo‘q |  |
| `receipt.products[].used_measure` | `object` | Yo‘q |  |
| `receipt.uuid` | `string` | Yo‘q |  |
| `receipt.contract_id` | `string` | Yo‘q |  |
| `receipt.customer_assistant_id` | `string` | Yo‘q |  |
| `receipt.delivery_date` | `string (date-time)` | Yo‘q |  |
| `receipt.delivery_address` | `object` | Yo‘q |  |
| `receipt.delivery_address.long` | `number` | Yo‘q |  |
| `receipt.delivery_address.lat` | `number` | Yo‘q |  |
| `receipt.delivery_address.human_address` | `object` | Yo‘q |  |
| `receipt.delivery_address.bearing` | `number` | Yo‘q |  |
| `receipt.discounts` | `object[]` | Yo‘q |  |
| `receipt.discounts[].is_custom` | `boolean` | Ha |  |
| `receipt.discounts[]._id` | `string` | Yo‘q |  |
| `receipt.discounts[].value` | `number` | Ha |  |
| `receipt.discounts[].name` | `string` | Yo‘q |  |
| `receipt.discounts[].apply_type` | `string` | Ha | Mumkin qiymatlar: `percent`, `cash` |
| `receipt.calc_tax_after_discount` | `boolean` | Yo‘q | Standart: `false` |
| `receipt.calc_sale_discount_after_product` | `boolean` | Yo‘q | Standart: `true` |
| `receipt.total_to_pay` | `number` | Yo‘q |  |
| `receipt.sold_at` | `string (date-time)` | Yo‘q |  |
| `receipt.mediator_id` | `string` | Yo‘q |  |

```json
{
  "name": "string",
  "organization_id": "string",
  "booking_table_id": "string",
  "comment": "string",
  "receipt": {
    "organization_id": "string",
    "warehouse_id": "string",
    "customer_id": "string",
    "responsible_id": "string",
    "currency_id": "string",
    "price_id": "string",
    "note": "string",
    "products": [
      {
        "product_id": null,
        "warehouse_id": null,
        "amount": null,
        "price": null,
        "box_count": null,
        "note": null,
        "price_id": null,
        "box_amount": null,
        "real_price": null,
        "total_price": null,
        "taxes": null,
        "discounts": null,
        "is_marked": null,
        "marks": null,
        "expiration_date": null,
        "total_to_pay": null,
        "materials": null,
        "used_measure": null
      }
    ],
    "uuid": "string",
    "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "delivery_date": "2025-05-01T12:00:00Z",
    "delivery_address": {
      "long": 0,
      "lat": 0,
      "human_address": {
        "address": null,
        "city": null,
        "state": null,
        "zip": null
      },
      "bearing": 0
    },
    "discounts": [
      {
        "is_custom": null,
        "_id": null,
        "value": null,
        "name": null,
        "apply_type": null
      }
    ],
    "calc_tax_after_discount": false,
    "calc_sale_discount_after_product": true,
    "total_to_pay": 0,
    "sold_at": "2025-05-01T12:00:00Z",
    "mediator_id": "64b7f4d9e2b3b6a0b7c5d7ff"
  }
}
```

**Javob**

| Maydon | Tur | Tavsif |
|---|---|---|
| `_id` | `string` |  |
| `name` | `string` |  |
| `organization_id` | `string` |  |
| `uuid` | `string` |  |
| `booking_table_id` | `string` |  |
| `receipt` | `object` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "name": "string",
    "organization_id": "string",
    "uuid": "string",
    "booking_table_id": "string",
    "receipt": {}
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## PUT /open-ticket/update

Update an existing open ticket and its draft receipt.

**Kerakli ruxsat:** `open_ticket` · [ruxsatlar qanday ishlaydi](https://docs.bito.uz/api/permissions.md)

**So‘rov namunasi**

::: code-group

```bash [curl]
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/open-ticket/update' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "organization_id": "string",
  "receipt": {
    "organization_id": "string",
    "warehouse_id": "string",
    "customer_id": "string",
    "responsible_id": "string",
    "currency_id": "string",
    "price_id": "string",
    "note": "string",
    "products": [
      {
        "product_id": null,
        "warehouse_id": null,
        "amount": null,
        "price": null,
        "box_count": null,
        "note": null,
        "price_id": null,
        "box_amount": null,
        "real_price": null,
        "total_price": null,
        "taxes": null,
        "discounts": null,
        "is_marked": null,
        "marks": null,
        "expiration_date": null,
        "total_to_pay": null,
        "materials": null,
        "used_measure": null
      }
    ],
    "uuid": "string",
    "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "delivery_date": "2025-05-01T12:00:00Z",
    "delivery_address": {
      "long": 0,
      "lat": 0,
      "human_address": {
        "address": null,
        "city": null,
        "state": null,
        "zip": null
      },
      "bearing": 0
    },
    "discounts": [
      {
        "is_custom": null,
        "_id": null,
        "value": null,
        "name": null,
        "apply_type": null
      }
    ],
    "calc_tax_after_discount": false,
    "calc_sale_discount_after_product": true,
    "total_to_pay": 0,
    "sold_at": "2025-05-01T12:00:00Z",
    "mediator_id": "64b7f4d9e2b3b6a0b7c5d7ff"
  },
  "_id": "string"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/open-ticket/update', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "organization_id": "string",
    "receipt": {
      "organization_id": "string",
      "warehouse_id": "string",
      "customer_id": "string",
      "responsible_id": "string",
      "currency_id": "string",
      "price_id": "string",
      "note": "string",
      "products": [
        {
          "product_id": null,
          "warehouse_id": null,
          "amount": null,
          "price": null,
          "box_count": null,
          "note": null,
          "price_id": null,
          "box_amount": null,
          "real_price": null,
          "total_price": null,
          "taxes": null,
          "discounts": null,
          "is_marked": null,
          "marks": null,
          "expiration_date": null,
          "total_to_pay": null,
          "materials": null,
          "used_measure": null
        }
      ],
      "uuid": "string",
      "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "delivery_date": "2025-05-01T12:00:00Z",
      "delivery_address": {
        "long": 0,
        "lat": 0,
        "human_address": {
          "address": null,
          "city": null,
          "state": null,
          "zip": null
        },
        "bearing": 0
      },
      "discounts": [
        {
          "is_custom": null,
          "_id": null,
          "value": null,
          "name": null,
          "apply_type": null
        }
      ],
      "calc_tax_after_discount": false,
      "calc_sale_discount_after_product": true,
      "total_to_pay": 0,
      "sold_at": "2025-05-01T12:00:00Z",
      "mediator_id": "64b7f4d9e2b3b6a0b7c5d7ff"
    },
    "_id": "string"
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "PUT",
    "https://api.bito.uz/integration-api/integration/api/v2/open-ticket/update",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "organization_id": "string",
        "receipt": {
            "organization_id": "string",
            "warehouse_id": "string",
            "customer_id": "string",
            "responsible_id": "string",
            "currency_id": "string",
            "price_id": "string",
            "note": "string",
            "products": [
                {
                    "product_id": None,
                    "warehouse_id": None,
                    "amount": None,
                    "price": None,
                    "box_count": None,
                    "note": None,
                    "price_id": None,
                    "box_amount": None,
                    "real_price": None,
                    "total_price": None,
                    "taxes": None,
                    "discounts": None,
                    "is_marked": None,
                    "marks": None,
                    "expiration_date": None,
                    "total_to_pay": None,
                    "materials": None,
                    "used_measure": None,
                },
            ],
            "uuid": "string",
            "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
            "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d7ff",
            "delivery_date": "2025-05-01T12:00:00Z",
            "delivery_address": {
                "long": 0,
                "lat": 0,
                "human_address": {
                    "address": None,
                    "city": None,
                    "state": None,
                    "zip": None,
                },
                "bearing": 0,
            },
            "discounts": [
                {
                    "is_custom": None,
                    "_id": None,
                    "value": None,
                    "name": None,
                    "apply_type": None,
                },
            ],
            "calc_tax_after_discount": False,
            "calc_sale_discount_after_product": True,
            "total_to_pay": 0,
            "sold_at": "2025-05-01T12:00:00Z",
            "mediator_id": "64b7f4d9e2b3b6a0b7c5d7ff",
        },
        "_id": "string",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "organization_id": "string",
  "receipt": {
    "organization_id": "string",
    "warehouse_id": "string",
    "customer_id": "string",
    "responsible_id": "string",
    "currency_id": "string",
    "price_id": "string",
    "note": "string",
    "products": [
      {
        "product_id": null,
        "warehouse_id": null,
        "amount": null,
        "price": null,
        "box_count": null,
        "note": null,
        "price_id": null,
        "box_amount": null,
        "real_price": null,
        "total_price": null,
        "taxes": null,
        "discounts": null,
        "is_marked": null,
        "marks": null,
        "expiration_date": null,
        "total_to_pay": null,
        "materials": null,
        "used_measure": null
      }
    ],
    "uuid": "string",
    "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "delivery_date": "2025-05-01T12:00:00Z",
    "delivery_address": {
      "long": 0,
      "lat": 0,
      "human_address": {
        "address": null,
        "city": null,
        "state": null,
        "zip": null
      },
      "bearing": 0
    },
    "discounts": [
      {
        "is_custom": null,
        "_id": null,
        "value": null,
        "name": null,
        "apply_type": null
      }
    ],
    "calc_tax_after_discount": false,
    "calc_sale_discount_after_product": true,
    "total_to_pay": 0,
    "sold_at": "2025-05-01T12:00:00Z",
    "mediator_id": "64b7f4d9e2b3b6a0b7c5d7ff"
  },
  "_id": "string"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/open-ticket/update');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `name` | `string` | Yo‘q | Display name of the open ticket |
| `organization_id` | `string` | Ha | Organization ObjectId the ticket belongs to |
| `booking_table_id` | `string` | Yo‘q | Booking table (seat/table) ObjectId, if the ticket is tied to a table |
| `comment` | `string` | Yo‘q | Optional free-text comment |
| `receipt` | `object` | Ha |  |
| `receipt.organization_id` | `string` | Ha |  |
| `receipt.warehouse_id` | `string` | Ha |  |
| `receipt.customer_id` | `string` | Yo‘q |  |
| `receipt.responsible_id` | `string` | Yo‘q |  |
| `receipt.currency_id` | `string` | Ha |  |
| `receipt.price_id` | `string` | Yo‘q |  |
| `receipt.note` | `string` | Yo‘q |  |
| `receipt.products` | `object[]` | Ha |  |
| `receipt.products[].product_id` | `string` | Ha |  |
| `receipt.products[].warehouse_id` | `string` | Ha |  |
| `receipt.products[].amount` | `number` | Ha |  |
| `receipt.products[].price` | `number` | Yo‘q |  |
| `receipt.products[].box_count` | `number` | Yo‘q |  |
| `receipt.products[].note` | `string` | Yo‘q |  |
| `receipt.products[].price_id` | `string` | Yo‘q |  |
| `receipt.products[].box_amount` | `number` | Yo‘q |  |
| `receipt.products[].real_price` | `number` | Ha |  |
| `receipt.products[].total_price` | `number` | Yo‘q |  |
| `receipt.products[].taxes` | `object[]` | Yo‘q |  |
| `receipt.products[].discounts` | `object[]` | Yo‘q |  |
| `receipt.products[].is_marked` | `boolean` | Yo‘q | Standart: `false` |
| `receipt.products[].marks` | `string[]` | Yo‘q |  |
| `receipt.products[].expiration_date` | `string (date-time)` | Yo‘q |  |
| `receipt.products[].total_to_pay` | `number` | Yo‘q |  |
| `receipt.products[].materials` | `object[]` | Yo‘q |  |
| `receipt.products[].used_measure` | `object` | Yo‘q |  |
| `receipt.uuid` | `string` | Yo‘q |  |
| `receipt.contract_id` | `string` | Yo‘q |  |
| `receipt.customer_assistant_id` | `string` | Yo‘q |  |
| `receipt.delivery_date` | `string (date-time)` | Yo‘q |  |
| `receipt.delivery_address` | `object` | Yo‘q |  |
| `receipt.delivery_address.long` | `number` | Yo‘q |  |
| `receipt.delivery_address.lat` | `number` | Yo‘q |  |
| `receipt.delivery_address.human_address` | `object` | Yo‘q |  |
| `receipt.delivery_address.bearing` | `number` | Yo‘q |  |
| `receipt.discounts` | `object[]` | Yo‘q |  |
| `receipt.discounts[].is_custom` | `boolean` | Ha |  |
| `receipt.discounts[]._id` | `string` | Yo‘q |  |
| `receipt.discounts[].value` | `number` | Ha |  |
| `receipt.discounts[].name` | `string` | Yo‘q |  |
| `receipt.discounts[].apply_type` | `string` | Ha | Mumkin qiymatlar: `percent`, `cash` |
| `receipt.calc_tax_after_discount` | `boolean` | Yo‘q | Standart: `false` |
| `receipt.calc_sale_discount_after_product` | `boolean` | Yo‘q | Standart: `true` |
| `receipt.total_to_pay` | `number` | Yo‘q |  |
| `receipt.sold_at` | `string (date-time)` | Yo‘q |  |
| `receipt.mediator_id` | `string` | Yo‘q |  |
| `_id` | `string` | Ha |  |
| `uuid` | `string` | Yo‘q |  |

```json
{
  "name": "string",
  "organization_id": "string",
  "booking_table_id": "string",
  "comment": "string",
  "receipt": {
    "organization_id": "string",
    "warehouse_id": "string",
    "customer_id": "string",
    "responsible_id": "string",
    "currency_id": "string",
    "price_id": "string",
    "note": "string",
    "products": [
      {
        "product_id": null,
        "warehouse_id": null,
        "amount": null,
        "price": null,
        "box_count": null,
        "note": null,
        "price_id": null,
        "box_amount": null,
        "real_price": null,
        "total_price": null,
        "taxes": null,
        "discounts": null,
        "is_marked": null,
        "marks": null,
        "expiration_date": null,
        "total_to_pay": null,
        "materials": null,
        "used_measure": null
      }
    ],
    "uuid": "string",
    "contract_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "delivery_date": "2025-05-01T12:00:00Z",
    "delivery_address": {
      "long": 0,
      "lat": 0,
      "human_address": {
        "address": null,
        "city": null,
        "state": null,
        "zip": null
      },
      "bearing": 0
    },
    "discounts": [
      {
        "is_custom": null,
        "_id": null,
        "value": null,
        "name": null,
        "apply_type": null
      }
    ],
    "calc_tax_after_discount": false,
    "calc_sale_discount_after_product": true,
    "total_to_pay": 0,
    "sold_at": "2025-05-01T12:00:00Z",
    "mediator_id": "64b7f4d9e2b3b6a0b7c5d7ff"
  },
  "_id": "string",
  "uuid": "string"
}
```

**Javob**

Javob tuzilishi quyidagi bilan bir xil: [POST /open-ticket/create](#post-open-ticket-create).

## POST /open-ticket/get-paging

Paginated list of open tickets, filterable by organization.

**Kerakli ruxsat:** `open_ticket` · [ruxsatlar qanday ishlaydi](https://docs.bito.uz/api/permissions.md)

**So‘rov namunasi**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/open-ticket/get-paging' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "page": 1,
  "limit": 20
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/open-ticket/get-paging', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "page": 1,
    "limit": 20
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/open-ticket/get-paging",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "page": 1,
        "limit": 20,
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "page": 1,
  "limit": 20
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/open-ticket/get-paging');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `page` | `number` | Ha | Standart: `1` |
| `limit` | `number` | Ha | Standart: `20` |
| `organization_id` | `string` | Yo‘q | Filter by organization ObjectId |
| `responsible_id` | `string` | Yo‘q |  |
| `customer_id` | `string` | Yo‘q |  |
| `date_from` | `string (date-time)` | Yo‘q | Start of the date range. |
| `date_to` | `string (date-time)` | Yo‘q | End of the date range. |
| `search` | `string` | Yo‘q | Free-text search. |

```json
{
  "page": 1,
  "limit": 20,
  "organization_id": "string",
  "responsible_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "customer_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "date_from": "2025-05-01T12:00:00Z",
  "date_to": "2025-05-01T12:00:00Z",
  "search": "string"
}
```

**Javob**

| Maydon | Tur | Tavsif |
|---|---|---|
| `total` | `number` |  |
| `list` | `object[]` |  |
| `list[]._id` | `string` |  |
| `list[].name` | `string` |  |
| `list[].organization_id` | `string` |  |
| `list[].uuid` | `string` |  |
| `list[].booking_table_id` | `string` |  |
| `list[].receipt` | `object` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "list": [
      {
        "_id": "string",
        "name": "string",
        "organization_id": "string",
        "uuid": "string",
        "booking_table_id": "string",
        "receipt": {}
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## GET /open-ticket/get-by-id/{id}

Fetch a single open ticket by ObjectId.

**Kerakli ruxsat:** `open_ticket` · [ruxsatlar qanday ishlaydi](https://docs.bito.uz/api/permissions.md)

**So‘rov namunasi**

::: code-group

```bash [curl]
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/open-ticket/get-by-id/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/open-ticket/get-by-id/6712f0a9c4d1e87b3a0f9911', {
  method: 'GET',
  headers: { 'api-key': process.env.BITO_API_KEY },
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "GET",
    "https://api.bito.uz/integration-api/integration/api/v2/open-ticket/get-by-id/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
)
print(res.json())
```

```php [PHP]
<?php
$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/open-ticket/get-by-id/6712f0a9c4d1e87b3a0f9911');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY')],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**Yo‘l parametrlari**

| Parametr | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `id` | `string` | Ha | Open-ticket ObjectId |

**So‘rov tanasi**

So‘rov tanasi talab qilinmaydi.

**Javob**

Javob tuzilishi quyidagi bilan bir xil: [POST /open-ticket/create](#post-open-ticket-create).

## POST /open-ticket/delete-many

Soft-delete multiple open tickets by their ObjectIds.

**Kerakli ruxsat:** `open_ticket` · [ruxsatlar qanday ishlaydi](https://docs.bito.uz/api/permissions.md)

**So‘rov namunasi**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/open-ticket/delete-many' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "ids": [
    "string"
  ]
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/open-ticket/delete-many', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "ids": [
      "string"
    ]
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/open-ticket/delete-many",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "ids": [
            "string",
        ],
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "ids": [
    "string"
  ]
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/open-ticket/delete-many');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `ids` | `string[]` | Ha | Open-ticket ObjectIds to delete |

```json
{
  "ids": [
    "string"
  ]
}
```

**Javob**

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": "ok",
  "time": "2025-05-01T12:00:00Z"
}
```

---

*Bu sahifa OpenAPI spetsifikatsiyasidan yaratilgan.*
