# Production order

Production orders

::: 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 /production-order/create

Create a new production order with its line items.

**Required permission:** `production` · [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/production-order/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "organization_id": "string",
  "date": "2025-05-01T12:00:00Z",
  "items": [
    {
      "product_id": "string",
      "tech_map_id": "string",
      "amount": 0
    }
  ]
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/production-order/create', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "organization_id": "string",
    "date": "2025-05-01T12:00:00Z",
    "items": [
      {
        "product_id": "string",
        "tech_map_id": "string",
        "amount": 0
      }
    ]
  }),
})
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/production-order/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "organization_id": "string",
        "date": "2025-05-01T12:00:00Z",
        "items": [
            {
                "product_id": "string",
                "tech_map_id": "string",
                "amount": 0,
            },
        ],
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "organization_id": "string",
  "date": "2025-05-01T12:00:00Z",
  "items": [
    {
      "product_id": "string",
      "tech_map_id": "string",
      "amount": 0
    }
  ]
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/production-order/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 |
|---|---|---|---|
| `organization_id` | `string` | Yes | Organization ObjectId the production order belongs to |
| `date` | `string (date-time)` | Yes | Production order date (ISO 8601) |
| `code` | `string` | No | Optional human-readable order code |
| `note` | `string` | No | Optional free-text note |
| `items` | `object[]` | Yes | Line items — each references a product and a tech-map |
| `items[].product_id` | `string` | Yes | Product ObjectId to be produced |
| `items[].tech_map_id` | `string` | Yes | Technical map (recipe/BOM) ObjectId to use |
| `items[].amount` | `number` | Yes | Planned production quantity |

```json
{
  "organization_id": "string",
  "date": "2025-05-01T12:00:00Z",
  "code": "string",
  "note": "string",
  "items": [
    {
      "product_id": "string",
      "tech_map_id": "string",
      "amount": 0
    }
  ]
}
```

**Response**

| Field | Type | Description |
|---|---|---|
| `organization_id` | `string` | Organization ObjectId the production order belongs to |
| `date` | `string (date-time)` | Production order date (ISO 8601) |
| `code` | `string` | Optional human-readable order code |
| `note` | `string` | Optional free-text note |
| `items` | `object[]` | Line items — each references a product and a tech-map |
| `items[].product_id` | `string` | Product ObjectId to be produced |
| `items[].tech_map_id` | `string` | Technical map (recipe/BOM) ObjectId to use |
| `items[].amount` | `number` | Planned production quantity |
| `_id` | `string` | Production order ObjectId |
| `status` | `string` | Current production order state |
| `is_deleted` | `boolean` | Soft-delete flag |
| `created_at` | `string (date-time)` | Creation timestamp (ISO 8601) |
| `updated_at` | `string (date-time)` | Last update timestamp (ISO 8601) |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "organization_id": "string",
    "date": "2025-05-01T12:00:00Z",
    "code": "string",
    "note": "string",
    "items": [
      {
        "product_id": "string",
        "tech_map_id": "string",
        "amount": 0
      }
    ],
    "_id": "string",
    "status": "string",
    "is_deleted": false,
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z"
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## GET /production-order/get-by-id/{id}

Fetch a single production order by ObjectId.

**Required permission:** `production` · [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/production-order/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/production-order/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/production-order/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/production-order/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 | Production-order ObjectId |

**Request body**

No request body.

**Response**

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

## POST /production-order/get-paging

Paginated list of production orders, filterable by organization.

**Required permission:** `production` · [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/production-order/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/production-order/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/production-order/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/production-order/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` |
| `organization_id` | `string` | No | Filter by organization ObjectId |
| `search` | `string` | No | Free-text search. |
| `updated_at` | `string (date-time)` | No | Only records updated at or after this time. |

```json
{
  "page": 1,
  "limit": 20,
  "organization_id": "string",
  "search": "string",
  "updated_at": "2025-05-01T12:00:00Z"
}
```

**Response**

| Field | Type | Description |
|---|---|---|
| `total` | `number` |  |
| `list` | `object[]` |  |
| `list[].organization_id` | `string` | Organization ObjectId the production order belongs to |
| `list[].date` | `string (date-time)` | Production order date (ISO 8601) |
| `list[].code` | `string` | Optional human-readable order code |
| `list[].note` | `string` | Optional free-text note |
| `list[].items` | `object[]` | Line items — each references a product and a tech-map |
| `list[].items[].product_id` | `string` | Product ObjectId to be produced |
| `list[].items[].tech_map_id` | `string` | Technical map (recipe/BOM) ObjectId to use |
| `list[].items[].amount` | `number` | Planned production quantity |
| `list[]._id` | `string` | Production order ObjectId |
| `list[].status` | `string` | Current production order state |
| `list[].is_deleted` | `boolean` | Soft-delete flag |
| `list[].created_at` | `string (date-time)` | Creation timestamp (ISO 8601) |
| `list[].updated_at` | `string (date-time)` | Last update timestamp (ISO 8601) |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "list": [
      {
        "organization_id": "string",
        "date": "2025-05-01T12:00:00Z",
        "code": "string",
        "note": "string",
        "items": [],
        "_id": "string",
        "status": "string",
        "is_deleted": false,
        "created_at": "2025-05-01T12:00:00Z",
        "updated_at": "2025-05-01T12:00:00Z"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## PUT /production-order/update/{id}

Update an existing production order and its line items.

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

**Example request**

::: code-group

```bash [curl]
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/production-order/update/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "organization_id": "string",
  "date": "2025-05-01T12:00:00Z",
  "items": [
    {
      "product_id": "string",
      "tech_map_id": "string",
      "amount": 0
    }
  ]
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/production-order/update/6712f0a9c4d1e87b3a0f9911', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "organization_id": "string",
    "date": "2025-05-01T12:00:00Z",
    "items": [
      {
        "product_id": "string",
        "tech_map_id": "string",
        "amount": 0
      }
    ]
  }),
})
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/production-order/update/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "organization_id": "string",
        "date": "2025-05-01T12:00:00Z",
        "items": [
            {
                "product_id": "string",
                "tech_map_id": "string",
                "amount": 0,
            },
        ],
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "organization_id": "string",
  "date": "2025-05-01T12:00:00Z",
  "items": [
    {
      "product_id": "string",
      "tech_map_id": "string",
      "amount": 0
    }
  ]
}
JSON;

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

:::

**Path parameters**

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | `string` | Yes | Production-order ObjectId |

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `organization_id` | `string` | Yes | Organization ObjectId the production order belongs to |
| `date` | `string (date-time)` | Yes | Production order date (ISO 8601) |
| `code` | `string` | No | Optional human-readable order code |
| `note` | `string` | No | Optional free-text note |
| `items` | `object[]` | Yes | Replacement line items for the order |
| `items[].product_id` | `string` | Yes | Product ObjectId to be produced |
| `items[].tech_map_id` | `string` | Yes | Technical map (recipe/BOM) ObjectId to use |
| `items[].amount` | `number` | Yes | Planned production quantity |

```json
{
  "organization_id": "string",
  "date": "2025-05-01T12:00:00Z",
  "code": "string",
  "note": "string",
  "items": [
    {
      "product_id": "string",
      "tech_map_id": "string",
      "amount": 0
    }
  ]
}
```

**Response**

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

## DELETE /production-order/delete/{id}

Soft-delete a production order by ObjectId.

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

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

**Example request**

::: code-group

```bash [curl]
curl -X DELETE 'https://api.bito.uz/integration-api/integration/api/v2/production-order/delete/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/production-order/delete/6712f0a9c4d1e87b3a0f9911', {
  method: 'DELETE',
  headers: { 'api-key': process.env.BITO_API_KEY },
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "DELETE",
    "https://api.bito.uz/integration-api/integration/api/v2/production-order/delete/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/production-order/delete/6712f0a9c4d1e87b3a0f9911');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    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 | Production-order ObjectId |

**Request body**

No request body.

**Response**

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

---

*This page is generated from the OpenAPI spec.*
