# Invoice

::: info
Every response arrives in the shared envelope — `code`, `message`, `messages`, `status_code`, `time` — with the payload in `data`. The tables below describe what is inside `data`.
:::

## POST /invoice/create

This method allows adding invoice into the account.

**Required permission:** `invoice` · [how permissions work](https://docs.bito.uz/en/api/permissions.md)

**Example request**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/invoice/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "payment_type_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "organization_id": "64b7f4d9e2b3b6a0b7c5d800",
  "currency_id": "64b7f4d9e2b3b6a0b7c5d809",
  "to_be_paid": 100,
  "payment_date": "2024-07-20T10:30:00Z"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/invoice/create', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "payment_type_id": "64b7f4d9e2b3b6a0b7c5d7ff",
    "organization_id": "64b7f4d9e2b3b6a0b7c5d800",
    "currency_id": "64b7f4d9e2b3b6a0b7c5d809",
    "to_be_paid": 100,
    "payment_date": "2024-07-20T10:30:00Z"
  }),
})
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/invoice/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "payment_type_id": "64b7f4d9e2b3b6a0b7c5d7ff",
        "organization_id": "64b7f4d9e2b3b6a0b7c5d800",
        "currency_id": "64b7f4d9e2b3b6a0b7c5d809",
        "to_be_paid": 100,
        "payment_date": "2024-07-20T10:30:00Z",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "payment_type_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "organization_id": "64b7f4d9e2b3b6a0b7c5d800",
  "currency_id": "64b7f4d9e2b3b6a0b7c5d809",
  "to_be_paid": 100,
  "payment_date": "2024-07-20T10:30:00Z"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/invoice/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);
```

:::

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `user_type` | `string` | No | One of: `supplier`, `employee`, `customer`, `person`, `other` |
| `payment_type_id` | `string` | Yes |  |
| `organization_id` | `string` | Yes |  |
| `customer_id` | `string` | No | Required when `user_type` is `customer`. |
| `customer_assistant_id` | `string` | No |  |
| `supplier_id` | `string` | No | Required when `user_type` is `supplier`. |
| `supplier_assistant_id` | `string` | No |  |
| `employee_id` | `string` | No | Required when `user_type` is `employee`. |
| `employee_assistant_id` | `string` | No |  |
| `person_id` | `string` | No | Required when `user_type` is `person`. |
| `person_assistant_id` | `string` | No |  |
| `currency_id` | `string` | Yes |  |
| `to_be_paid` | `number` | Yes |  |
| `payment_date` | `string (date-time)` | Yes |  |
| `description` | `string` | No |  |
| `exchange_balance` | `boolean` | No |  |
| `month` | `string (date-time)` | No |  |

```json
{
  "user_type": "customer",
  "payment_type_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "organization_id": "64b7f4d9e2b3b6a0b7c5d800",
  "customer_id": "64b7f4d9e2b3b6a0b7c5d801",
  "customer_assistant_id": "64b7f4d9e2b3b6a0b7c5d802",
  "supplier_id": "64b7f4d9e2b3b6a0b7c5d803",
  "supplier_assistant_id": "64b7f4d9e2b3b6a0b7c5d804",
  "employee_id": "64b7f4d9e2b3b6a0b7c5d805",
  "employee_assistant_id": "64b7f4d9e2b3b6a0b7c5d806",
  "person_id": "64b7f4d9e2b3b6a0b7c5d807",
  "person_assistant_id": "64b7f4d9e2b3b6a0b7c5d808",
  "currency_id": "64b7f4d9e2b3b6a0b7c5d809",
  "to_be_paid": 100,
  "payment_date": "2024-07-20T10:30:00Z",
  "description": "Invoice description",
  "exchange_balance": false,
  "month": "2025-05-01T12:00:00Z"
}
```

**Response**

| Field | Type | Description |
|---|---|---|
| `_id` | `string` |  |
| `number` | `string` |  |
| `type` | `string` |  |
| `state` | `string` |  |
| `can_be_canceled` | `boolean` |  |
| `balance_changes` | `object[]` |  |
| `balance_changes[]._id` | `string` |  |
| `balance_changes[].currency_id` | `string` |  |
| `balance_changes[].amount` | `number` |  |
| `balance_changes[].value` | `number` |  |
| `balance_changes[].user_type` | `string` |  |
| `organization` | `object` |  |
| `organization._id` | `string` |  |
| `organization.name` | `string` |  |
| `payment_type` | `object` |  |
| `payment_type._id` | `string` |  |
| `payment_type.name` | `string` |  |
| `user_type` | `string` |  |
| `is_refund` | `boolean` |  |
| `date` | `string (date-time)` |  |
| `customer` | `object` |  |
| `customer._id` | `string` |  |
| `customer.name` | `string` |  |
| `supplier` | `object` |  |
| `supplier._id` | `string` |  |
| `supplier.name` | `string` |  |
| `employee` | `object` |  |
| `employee._id` | `string` |  |
| `employee.full_name` | `string` |  |
| `person` | `object` |  |
| `person._id` | `string` |  |
| `person.name` | `string` |  |
| `person.full_name` | `string` |  |
| `write_off` | `object` |  |
| `write_off._id` | `string` |  |
| `write_off.number` | `string` |  |
| `income` | `object` |  |
| `income._id` | `string` |  |
| `income.number` | `string` |  |
| `purchase` | `object` |  |
| `purchase._id` | `string` |  |
| `purchase.number` | `string` |  |
| `revision` | `object` |  |
| `revision._id` | `string` |  |
| `revision.type` | `string` |  |
| `revision.balance_type` | `string` |  |
| `revision.number` | `string` |  |
| `purchase_return` | `object` |  |
| `purchase_return._id` | `string` |  |
| `purchase_return.number` | `string` |  |
| `trade` | `object` |  |
| `trade._id` | `string` |  |
| `trade.number` | `string` |  |
| `trade.is_refund` | `boolean` |  |
| `to_be_paid` | `number` |  |
| `paid` | `number` |  |
| `paid_by_balance` | `number` |  |
| `paid_by_cashback` | `number` |  |
| `to_be_refunded` | `number` |  |
| `refunded` | `number` |  |
| `currency_id` | `string` |  |
| `payment_date` | `integer` |  |
| `created_by` | `object` |  |
| `created_by._id` | `string` |  |
| `created_by.full_name` | `string` |  |
| `created_at` | `string (date-time)` |  |
| `extra_cost` | `object` |  |
| `extra_cost._id` | `string` |  |
| `extra_cost.name` | `string` |  |
| `extra_cost.amount` | `number` |  |
| `attachments` | `string[]` |  |
| `description` | `string` |  |
| `transactions` | `string[]` |  |
| `responsible_id` | `string` |  |
| `responsible` | `object` |  |
| `responsible._id` | `string` |  |
| `responsible.full_name` | `string` |  |
| `customer_assistant` | `object` |  |
| `customer_assistant._id` | `string` |  |
| `customer_assistant.name` | `string` |  |
| `customer_assistant.type` | `string` |  |
| `supplier_assistant` | `object` |  |
| `supplier_assistant._id` | `string` |  |
| `supplier_assistant.name` | `string` |  |
| `supplier_assistant.type` | `string` |  |
| `employee_assistant` | `object` |  |
| `employee_assistant._id` | `string` |  |
| `employee_assistant.name` | `string` |  |
| `employee_assistant.type` | `string` |  |
| `person_assistant` | `object` |  |
| `person_assistant._id` | `string` |  |
| `person_assistant.name` | `string` |  |
| `person_assistant.type` | `string` |  |
| `supplier_assistant_hierarchy` | `string` |  |
| `customer_assistant_hierarchy` | `string` |  |
| `employee_assistant_hierarchy` | `string` |  |
| `person_assistant_hierarchy` | `string` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "number": "string",
    "type": "string",
    "state": "string",
    "can_be_canceled": false,
    "balance_changes": [
      {
        "_id": "string",
        "currency_id": "string",
        "amount": 0,
        "value": 0,
        "user_type": "string"
      }
    ],
    "organization": {
      "_id": "string",
      "name": "string"
    },
    "payment_type": {
      "_id": "string",
      "name": "string"
    },
    "user_type": "string",
    "is_refund": false,
    "date": "2025-05-01T12:00:00Z",
    "customer": {
      "_id": "string",
      "name": "string"
    },
    "supplier": {
      "_id": "string",
      "name": "string"
    },
    "employee": {
      "_id": "string",
      "full_name": "string"
    },
    "person": {
      "_id": "string",
      "name": "string",
      "full_name": "string"
    },
    "write_off": {
      "_id": "string",
      "number": "string"
    },
    "income": {
      "_id": "string",
      "number": "string"
    },
    "purchase": {
      "_id": "string",
      "number": "string"
    },
    "revision": {
      "_id": "string",
      "type": "string",
      "balance_type": "string",
      "number": "string"
    },
    "purchase_return": {
      "_id": "string",
      "number": "string"
    },
    "trade": {
      "_id": "string",
      "number": "string",
      "is_refund": false
    },
    "to_be_paid": 0,
    "paid": 0,
    "paid_by_balance": 0,
    "paid_by_cashback": 0,
    "to_be_refunded": 0,
    "refunded": 0,
    "currency_id": "string",
    "payment_date": 0,
    "created_by": {
      "_id": "string",
      "full_name": "string"
    },
    "created_at": "2025-05-01T12:00:00Z",
    "extra_cost": {
      "_id": "string",
      "name": "string",
      "amount": 0
    },
    "attachments": [
      "string"
    ],
    "description": "string",
    "transactions": [
      "string"
    ],
    "responsible_id": "string",
    "responsible": {
      "_id": "string",
      "full_name": "string"
    },
    "customer_assistant": {
      "_id": "string",
      "name": "string",
      "type": "string"
    },
    "supplier_assistant": {
      "_id": "string",
      "name": "string",
      "type": "string"
    },
    "employee_assistant": {
      "_id": "string",
      "name": "string",
      "type": "string"
    },
    "person_assistant": {
      "_id": "string",
      "name": "string",
      "type": "string"
    },
    "supplier_assistant_hierarchy": "string",
    "customer_assistant_hierarchy": "string",
    "employee_assistant_hierarchy": "string",
    "person_assistant_hierarchy": "string"
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## GET /invoice/get-by-id/{id}

Get invoice using its _id

**Required permission:** `invoice` · [how permissions work](https://docs.bito.uz/en/api/permissions.md)

**Example request**

::: code-group

```bash [curl]
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/invoice/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/invoice/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/invoice/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/invoice/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);
```

:::

**Path parameters**

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | `string` | Yes |  |

**Request body**

No request body.

**Response**

Same response shape as [POST /invoice/create](#post-invoice-create).

## PUT /invoice/set-state

setState invoice

**Required permission:** `invoice_update` · [how permissions work](https://docs.bito.uz/en/api/permissions.md)

An app that cancels documents should request `invoice_cancel` as well.

**Example request**

::: code-group

```bash [curl]
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/invoice/set-state' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "state": "canceled",
  "_id": "64b7f4d9e2b3b6a0b7c5d80a"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/invoice/set-state', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "state": "canceled",
    "_id": "64b7f4d9e2b3b6a0b7c5d80a"
  }),
})
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/invoice/set-state",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "state": "canceled",
        "_id": "64b7f4d9e2b3b6a0b7c5d80a",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "state": "canceled",
  "_id": "64b7f4d9e2b3b6a0b7c5d80a"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/invoice/set-state');
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);
```

:::

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `_id` | `string` | Yes |  |
| `state` | `string` | Yes | One of: `canceled`, `pending`, `done`, `rejected` |
| `with_transactions` | `boolean` | No |  |

```json
{
  "_id": "64b7f4d9e2b3b6a0b7c5d80a",
  "state": "canceled",
  "with_transactions": true
}
```

**Response**

Same response shape as [POST /invoice/create](#post-invoice-create).

## POST /invoice/get-paging

Get invoice by paging

**Required permission:** `invoice` · [how permissions work](https://docs.bito.uz/en/api/permissions.md)

**Example request**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/invoice/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/invoice/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/invoice/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/invoice/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);
```

:::

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `page` | `number` | Yes | Default: `1` |
| `limit` | `number` | Yes | Default: `20` |
| `is_fully_paid` | `boolean` | No |  |
| `type` | `string` | No | One of: `income`, `expense`, `transfer`, `exchange`, `exchange_method`, `nothing` |
| `trade_id` | `string` | No |  |
| `customer_id` | `string` | No |  |
| `supplier_id` | `string` | No |  |
| `employee_id` | `string` | No |  |
| `person_id` | `string` | No |  |
| `date_from` | `string (date-time)` | No |  |
| `date_to` | `string (date-time)` | No |  |
| `search` | `string` | No |  |
| `organization_id` | `string` | No |  |
| `payment_type_id` | `string` | No |  |
| `payment_type_ids` | `string[]` | No |  |
| `is_main` | `boolean` | No |  |
| `is_installment_plan` | `boolean` | No |  |
| `states` | `string[]` | No |  |
| `paid_states` | `string[]` | No |  |

```json
{
  "page": 1,
  "limit": 20,
  "is_fully_paid": true,
  "type": "income",
  "trade_id": "64b7f4d9e2b3b6a0b7c5d80a",
  "customer_id": "64b7f4d9e2b3b6a0b7c5d80b",
  "supplier_id": "64b7f4d9e2b3b6a0b7c5d80c",
  "employee_id": "64b7f4d9e2b3b6a0b7c5d80d",
  "person_id": "64b7f4d9e2b3b6a0b7c5d80e",
  "date_from": "2024-07-20T10:30:00Z",
  "date_to": "2024-07-21T10:30:00Z",
  "search": "search",
  "organization_id": "64b7f4d9e2b3b6a0b7c5d80f",
  "payment_type_id": "64b7f4d9e2b3b6a0b7c5d810",
  "payment_type_ids": [
    "64b7f4d9e2b3b6a0b7c5d811",
    "64b7f4d9e2b3b6a0b7c5d812"
  ],
  "is_main": true,
  "is_installment_plan": false,
  "states": [
    "canceled",
    "pending"
  ],
  "paid_states": [
    "string"
  ]
}
```

**Response**

`data.total` is the total number of records and `data.data[]` holds the current page. The table below describes one record.

| Field | Type | Description |
|---|---|---|
| `_id` | `string` |  |
| `number` | `string` |  |
| `type` | `string` |  |
| `state` | `string` |  |
| `can_be_canceled` | `boolean` |  |
| `balance_changes` | `object[]` |  |
| `balance_changes[]._id` | `string` |  |
| `balance_changes[].currency_id` | `string` |  |
| `balance_changes[].amount` | `number` |  |
| `balance_changes[].value` | `number` |  |
| `balance_changes[].user_type` | `string` |  |
| `organization` | `object` |  |
| `organization._id` | `string` |  |
| `organization.name` | `string` |  |
| `payment_type` | `object` |  |
| `payment_type._id` | `string` |  |
| `payment_type.name` | `string` |  |
| `payment_type_id` | `string` |  |
| `user_type` | `string` |  |
| `is_refund` | `boolean` |  |
| `date` | `string (date-time)` |  |
| `parent_id` | `string` |  |
| `customer_id` | `string` |  |
| `customer` | `object` |  |
| `customer._id` | `string` |  |
| `customer.name` | `string` |  |
| `supplier_id` | `string` |  |
| `supplier` | `object` |  |
| `supplier._id` | `string` |  |
| `supplier.name` | `string` |  |
| `employee_id` | `string` |  |
| `employee` | `object` |  |
| `employee._id` | `string` |  |
| `employee.full_name` | `string` |  |
| `person_id` | `string` |  |
| `person` | `object` |  |
| `person._id` | `string` |  |
| `person.name` | `string` |  |
| `person.full_name` | `string` |  |
| `write_off_id` | `string` |  |
| `write_off` | `object` |  |
| `write_off._id` | `string` |  |
| `write_off.number` | `string` |  |
| `income_id` | `string` |  |
| `income` | `object` |  |
| `income._id` | `string` |  |
| `income.number` | `string` |  |
| `revision_id` | `string` |  |
| `revision` | `object` |  |
| `revision._id` | `string` |  |
| `revision.type` | `string` |  |
| `revision.balance_type` | `string` |  |
| `revision.number` | `string` |  |
| `to_be_paid` | `number` |  |
| `paid` | `number` |  |
| `paid_by_balance` | `number` |  |
| `paid_by_cashback` | `number` |  |
| `to_be_refunded` | `number` |  |
| `refunded` | `number` |  |
| `currency_id` | `string` |  |
| `currency` | `object` |  |
| `currency.uuid` | `number` |  |
| `currency.name` | `string` |  |
| `currency.code` | `string` |  |
| `currency.value` | `number` |  |
| `currency.round_type` | `string` | One of: `floor`, `ceil`, `round` |
| `currency.precision` | `number` |  |
| `currency.is_main` | `boolean` |  |
| `currency.country_id` | `string` |  |
| `currency.symbol` | `string` |  |
| `currency.side` | `string` | One of: `start`, `end` |
| `purchase_id` | `string` |  |
| `purchase_return_id` | `string` |  |
| `trade_id` | `string` |  |
| `payment_date` | `integer` |  |
| `created_by` | `object` |  |
| `created_by._id` | `string` |  |
| `created_by.full_name` | `string` |  |
| `created_at` | `string (date-time)` |  |
| `extra_cost` | `object` |  |
| `extra_cost._id` | `string` |  |
| `extra_cost.name` | `string` |  |
| `extra_cost.amount` | `number` |  |
| `attachments` | `string[]` |  |
| `description` | `string` |  |
| `plan_items` | `object[]` |  |
| `customer_assistant` | `object` |  |
| `customer_assistant._id` | `string` |  |
| `customer_assistant.name` | `string` |  |
| `customer_assistant.type` | `string` |  |
| `supplier_assistant` | `object` |  |
| `supplier_assistant._id` | `string` |  |
| `supplier_assistant.name` | `string` |  |
| `supplier_assistant.type` | `string` |  |
| `employee_assistant` | `object` |  |
| `employee_assistant._id` | `string` |  |
| `employee_assistant.name` | `string` |  |
| `employee_assistant.type` | `string` |  |
| `person_assistant` | `object` |  |
| `person_assistant._id` | `string` |  |
| `person_assistant.name` | `string` |  |
| `person_assistant.type` | `string` |  |
| `supplier_assistant_hierarchy` | `string` |  |
| `customer_assistant_hierarchy` | `string` |  |
| `employee_assistant_hierarchy` | `string` |  |
| `person_assistant_hierarchy` | `string` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "data": [
      {
        "_id": "string",
        "number": "string",
        "type": "string",
        "state": "string",
        "can_be_canceled": false,
        "balance_changes": [
          {
            "_id": "string",
            "currency_id": "string",
            "amount": 0,
            "value": 0,
            "user_type": "string"
          }
        ],
        "organization": {
          "_id": "string",
          "name": "string"
        },
        "payment_type": {
          "_id": "string",
          "name": "string"
        },
        "payment_type_id": "string",
        "user_type": "string",
        "is_refund": false,
        "date": "2025-05-01T12:00:00Z",
        "parent_id": "string",
        "customer_id": "string",
        "customer": {
          "_id": "string",
          "name": "string"
        },
        "supplier_id": "string",
        "supplier": {
          "_id": "string",
          "name": "string"
        },
        "employee_id": "string",
        "employee": {
          "_id": "string",
          "full_name": "string"
        },
        "person_id": "string",
        "person": {
          "_id": "string",
          "name": "string",
          "full_name": "string"
        },
        "write_off_id": "string",
        "write_off": {
          "_id": "string",
          "number": "string"
        },
        "income_id": "string",
        "income": {
          "_id": "string",
          "number": "string"
        },
        "revision_id": "string",
        "revision": {
          "_id": "string",
          "type": "string",
          "balance_type": "string",
          "number": "string"
        },
        "to_be_paid": 0,
        "paid": 0,
        "paid_by_balance": 0,
        "paid_by_cashback": 0,
        "to_be_refunded": 0,
        "refunded": 0,
        "currency_id": "string",
        "currency": {
          "uuid": 0,
          "name": "string",
          "code": "string",
          "value": 0,
          "round_type": "floor",
          "precision": 0,
          "is_main": false,
          "country_id": "string",
          "symbol": "string",
          "side": "start"
        },
        "purchase_id": "string",
        "purchase_return_id": "string",
        "trade_id": "string",
        "payment_date": 0,
        "created_by": {
          "_id": "string",
          "full_name": "string"
        },
        "created_at": "2025-05-01T12:00:00Z",
        "extra_cost": {
          "_id": "string",
          "name": "string",
          "amount": 0
        },
        "attachments": [
          "string"
        ],
        "description": "string",
        "plan_items": [
          {}
        ],
        "customer_assistant": {
          "_id": "string",
          "name": "string",
          "type": "string"
        },
        "supplier_assistant": {
          "_id": "string",
          "name": "string",
          "type": "string"
        },
        "employee_assistant": {
          "_id": "string",
          "name": "string",
          "type": "string"
        },
        "person_assistant": {
          "_id": "string",
          "name": "string",
          "type": "string"
        },
        "supplier_assistant_hierarchy": "string",
        "customer_assistant_hierarchy": "string",
        "employee_assistant_hierarchy": "string",
        "person_assistant_hierarchy": "string"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## GET /invoice/get-initial-payment/by-trade-id

Get the initial payment for a trade. Returns the prepayment / down-payment invoice tied to a trade.

**Required permission:** `invoice` · [how permissions work](https://docs.bito.uz/en/api/permissions.md)

**Example request**

::: code-group

```bash [curl]
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/invoice/get-initial-payment/by-trade-id?trade_id=64b7f4d9e2b3b6a0b7c5d80a' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/invoice/get-initial-payment/by-trade-id?trade_id=64b7f4d9e2b3b6a0b7c5d80a', {
  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/invoice/get-initial-payment/by-trade-id?trade_id=64b7f4d9e2b3b6a0b7c5d80a",
    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/invoice/get-initial-payment/by-trade-id?trade_id=64b7f4d9e2b3b6a0b7c5d80a');
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);
```

:::

**Query parameters**

| Parameter | Type | Required | Description |
|---|---|---|---|
| `trade_id` | `string` | Yes |  |

**Request body**

No request body.

**Response**

Same response shape as [POST /invoice/create](#post-invoice-create).

---

*This page is generated from the OpenAPI spec.*
