# Task

::: 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 /task/create

Create a task. attached_to selects which FK array is required (trade_uuids/trade_ids, order_ids, customer_ids, supplier_ids, employee_ids).

**Required permission:** `tasks` · [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/task/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "type_id": "67b486d242ed76693cd2cc59",
  "date": "2023-10-01T12:00:00Z",
  "responsible_id": "67b486d242ed76693cd2cc59"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/task/create', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "type_id": "67b486d242ed76693cd2cc59",
    "date": "2023-10-01T12:00:00Z",
    "responsible_id": "67b486d242ed76693cd2cc59"
  }),
})
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/task/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "type_id": "67b486d242ed76693cd2cc59",
        "date": "2023-10-01T12:00:00Z",
        "responsible_id": "67b486d242ed76693cd2cc59",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "type_id": "67b486d242ed76693cd2cc59",
  "date": "2023-10-01T12:00:00Z",
  "responsible_id": "67b486d242ed76693cd2cc59"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/task/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` | No |  |
| `type_id` | `string` | Yes | Task-type id (see /task-type/get-paging) |
| `date` | `string (date-time)` | Yes | Date the task is scheduled for. When time_type=range, the value is rewritten to start_of_day(date)+start_time using the boss's UTC offset. |
| `time_type` | `string` | No | One of: `full_day`, `range`. Default: `"full_day"` |
| `start_time` | `string` | No | Required when time_type=range. 24h HH:MM. |
| `end_time` | `string` | No | Required when time_type=range. 24h HH:MM. |
| `responsible_id` | `string` | Yes |  |
| `description` | `string` | No |  |
| `attached_to` | `string` | No | One of: `trade`, `order`, `customer`, `supplier`, `employee` |
| `trade_uuids` | `string[]` | No | Used when attached_to=trade. Preferred over trade_ids; first non-empty wins. |
| `trade_ids` | `string[]` | No | Used when attached_to=trade. |
| `order_ids` | `string[]` | No | Required when attached_to=order. |
| `customer_ids` | `string[]` | No | Required when attached_to=customer. |
| `supplier_ids` | `string[]` | No | Required when attached_to=supplier. |
| `employee_ids` | `string[]` | No | Required when attached_to=employee. |

```json
{
  "organization_id": "67b486d242ed76693cd2cc59",
  "type_id": "67b486d242ed76693cd2cc59",
  "date": "2023-10-01T12:00:00Z",
  "time_type": "full_day",
  "start_time": "09:00",
  "end_time": "10:30",
  "responsible_id": "67b486d242ed76693cd2cc59",
  "description": "string",
  "attached_to": "trade",
  "trade_uuids": [
    "string"
  ],
  "trade_ids": [
    "67b486d242ed76693cd2cc59"
  ],
  "order_ids": [
    "67b486d242ed76693cd2cc59"
  ],
  "customer_ids": [
    "67b486d242ed76693cd2cc59"
  ],
  "supplier_ids": [
    "67b486d242ed76693cd2cc59"
  ],
  "employee_ids": [
    "67b486d242ed76693cd2cc59"
  ]
}
```

**Response**

| Field | Type | Description |
|---|---|---|
| `_id` | `string` |  |
| `created_at` | `string (date-time)` |  |
| `updated_at` | `string (date-time)` |  |
| `type_id` | `string` |  |
| `type` | `object` |  |
| `type._id` | `string` |  |
| `type.name` | `string` |  |
| `type.icon` | `string` |  |
| `type.svg` | `string` |  |
| `type.color` | `string` |  |
| `organization_id` | `string` |  |
| `date` | `string (date-time)` |  |
| `time_type` | `string` | One of: `full_day`, `range` |
| `start_time` | `string` |  |
| `end_time` | `string` |  |
| `created_by` | `string` |  |
| `created_by_info` | `object` |  |
| `created_by_info._id` | `string` |  |
| `created_by_info.full_name` | `string` |  |
| `created_by_info.phone_number` | `string` |  |
| `responsible_id` | `string` |  |
| `responsible` | `object` |  |
| `responsible._id` | `string` |  |
| `responsible.full_name` | `string` |  |
| `responsible.phone_number` | `string` |  |
| `description` | `string` |  |
| `attached_to` | `string` | One of: `trade`, `order`, `customer`, `supplier`, `employee` |
| `trade_ids` | `string[]` |  |
| `order_ids` | `string[]` |  |
| `customer_ids` | `string[]` |  |
| `supplier_ids` | `string[]` |  |
| `employee_ids` | `string[]` |  |
| `purchase_ids` | `string[]` |  |
| `state` | `string` | One of: `created`, `completed` |
| `result_comment` | `string` |  |
| `is_postponed` | `boolean` |  |
| `postponed_id` | `string` | On a postponed clone, points back to the original task. |
| `completed_at` | `string (date-time)` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "67b486d242ed76693cd2cc59",
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z",
    "type_id": "67b486d242ed76693cd2cc59",
    "type": {
      "_id": "string",
      "name": "string",
      "icon": "string",
      "svg": "string",
      "color": "string"
    },
    "organization_id": "67b486d242ed76693cd2cc59",
    "date": "2025-05-01T12:00:00Z",
    "time_type": "full_day",
    "start_time": "09:00",
    "end_time": "10:30",
    "created_by": "67b486d242ed76693cd2cc59",
    "created_by_info": {
      "_id": "string",
      "full_name": "string",
      "phone_number": "string"
    },
    "responsible_id": "67b486d242ed76693cd2cc59",
    "responsible": {
      "_id": "string",
      "full_name": "string",
      "phone_number": "string"
    },
    "description": "string",
    "attached_to": "trade",
    "trade_ids": [
      "string"
    ],
    "order_ids": [
      "string"
    ],
    "customer_ids": [
      "string"
    ],
    "supplier_ids": [
      "string"
    ],
    "employee_ids": [
      "string"
    ],
    "purchase_ids": [
      "string"
    ],
    "state": "created",
    "result_comment": "string",
    "is_postponed": false,
    "postponed_id": "67b486d242ed76693cd2cc59",
    "completed_at": "2025-05-01T12:00:00Z"
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## PUT /task/update

Update a task. Rejects when state=completed. Only the creator or boss/additional-boss can update.

**Required permission:** `tasks` · [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/task/update' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "_id": "67b486d242ed76693cd2cc59"
}'
```

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

```php [PHP]
<?php
$body = <<<'JSON'
{
  "_id": "67b486d242ed76693cd2cc59"
}
JSON;

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

:::

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `_id` | `string` | Yes |  |
| `organization_id` | `string` | No |  |
| `type_id` | `string` | No |  |
| `date` | `string (date-time)` | No |  |
| `time_type` | `string` | No | One of: `full_day`, `range` |
| `start_time` | `string` | No | Required when `time_type` is `range`. |
| `end_time` | `string` | No | Required when `time_type` is `range`. |
| `responsible_id` | `string` | No |  |
| `description` | `string` | No |  |
| `attached_to` | `string` | No | One of: `trade`, `order`, `customer`, `supplier`, `employee` |
| `trade_uuids` | `string[]` | No |  |
| `trade_ids` | `string[]` | No |  |
| `order_ids` | `string[]` | No |  |
| `customer_ids` | `string[]` | No |  |
| `supplier_ids` | `string[]` | No |  |
| `employee_ids` | `string[]` | No |  |

```json
{
  "_id": "67b486d242ed76693cd2cc59",
  "organization_id": "67b486d242ed76693cd2cc59",
  "type_id": "67b486d242ed76693cd2cc59",
  "date": "2023-10-01T12:00:00Z",
  "time_type": "full_day",
  "start_time": "09:00",
  "end_time": "10:30",
  "responsible_id": "67b486d242ed76693cd2cc59",
  "description": "string",
  "attached_to": "trade",
  "trade_uuids": [
    "string"
  ],
  "trade_ids": [
    "string"
  ],
  "order_ids": [
    "string"
  ],
  "customer_ids": [
    "string"
  ],
  "supplier_ids": [
    "string"
  ],
  "employee_ids": [
    "string"
  ]
}
```

**Response**

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

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

Get a task by _id.

**Required permission:** `tasks` · [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/task/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/task/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/task/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/task/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 /task/create](#post-task-create).

## GET /task/paging

Paginated task list. By default hides completed tasks unless `state` is set or `date_type=completed_at`. `time` and `times` filter by date-buckets (overdue/today/tomorrow/week/month/future) using the boss's UTC offset.

**Required permission:** `tasks` · [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/task/paging?page=PAGE&limit=LIMIT' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/task/paging?page=PAGE&limit=LIMIT', {
  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/task/paging?page=PAGE&limit=LIMIT",
    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/task/paging?page=PAGE&limit=LIMIT');
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 |
|---|---|---|---|
| `page` | `integer` | Yes | Default: `1` |
| `limit` | `integer` | Yes | Default: `20` |
| `updated_at` | `string (date-time)` | No | Sync cursor — only returns rows with updated_at &gt;= this value. |
| `search` | `string` | No |  |
| `time` | `string` | No | One of: `overdue`, `today`, `tomorrow`, `week`, `month`, `future` |
| `times` | `string[]` | No |  |
| `date_type` | `string` | No | One of: `created_at`, `date`, `completed_at` |
| `responsible_id` | `string` | No |  |
| `type_id` | `string` | No |  |
| `type_ids` | `string[]` | No |  |
| `attached_to` | `string` | No | One of: `trade`, `order`, `customer`, `supplier`, `employee` |
| `state` | `string` | No | One of: `created`, `completed` |
| `trade_id` | `string` | No |  |
| `order_id` | `string` | No |  |
| `customer_id` | `string` | No |  |
| `supplier_id` | `string` | No |  |
| `employee_id` | `string` | No |  |
| `purchase_id` | `string` | No |  |
| `organization_id` | `string` | No |  |

**Request body**

No request body.

**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` |  |
| `created_at` | `string (date-time)` |  |
| `updated_at` | `string (date-time)` |  |
| `type_id` | `string` |  |
| `type` | `object` |  |
| `type._id` | `string` |  |
| `type.name` | `string` |  |
| `type.icon` | `string` |  |
| `type.svg` | `string` |  |
| `type.color` | `string` |  |
| `organization_id` | `string` |  |
| `date` | `string (date-time)` |  |
| `time_type` | `string` | One of: `full_day`, `range` |
| `start_time` | `string` |  |
| `end_time` | `string` |  |
| `created_by` | `string` |  |
| `created_by_info` | `object` |  |
| `created_by_info._id` | `string` |  |
| `created_by_info.full_name` | `string` |  |
| `created_by_info.phone_number` | `string` |  |
| `responsible_id` | `string` |  |
| `responsible` | `object` |  |
| `responsible._id` | `string` |  |
| `responsible.full_name` | `string` |  |
| `responsible.phone_number` | `string` |  |
| `description` | `string` |  |
| `attached_to` | `string` | One of: `trade`, `order`, `customer`, `supplier`, `employee` |
| `trade_ids` | `string[]` |  |
| `order_ids` | `string[]` |  |
| `customer_ids` | `string[]` |  |
| `supplier_ids` | `string[]` |  |
| `employee_ids` | `string[]` |  |
| `purchase_ids` | `string[]` |  |
| `state` | `string` | One of: `created`, `completed` |
| `result_comment` | `string` |  |
| `is_postponed` | `boolean` |  |
| `postponed_id` | `string` | On a postponed clone, points back to the original task. |
| `completed_at` | `string (date-time)` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "data": [
      {
        "_id": "67b486d242ed76693cd2cc59",
        "created_at": "2025-05-01T12:00:00Z",
        "updated_at": "2025-05-01T12:00:00Z",
        "type_id": "67b486d242ed76693cd2cc59",
        "type": {
          "_id": "string",
          "name": "string",
          "icon": "string",
          "svg": "string",
          "color": "string"
        },
        "organization_id": "67b486d242ed76693cd2cc59",
        "date": "2025-05-01T12:00:00Z",
        "time_type": "full_day",
        "start_time": "09:00",
        "end_time": "10:30",
        "created_by": "67b486d242ed76693cd2cc59",
        "created_by_info": {
          "_id": "string",
          "full_name": "string",
          "phone_number": "string"
        },
        "responsible_id": "67b486d242ed76693cd2cc59",
        "responsible": {
          "_id": "string",
          "full_name": "string",
          "phone_number": "string"
        },
        "description": "string",
        "attached_to": "trade",
        "trade_ids": [
          "string"
        ],
        "order_ids": [
          "string"
        ],
        "customer_ids": [
          "string"
        ],
        "supplier_ids": [
          "string"
        ],
        "employee_ids": [
          "string"
        ],
        "purchase_ids": [
          "string"
        ],
        "state": "created",
        "result_comment": "string",
        "is_postponed": false,
        "postponed_id": "67b486d242ed76693cd2cc59",
        "completed_at": "2025-05-01T12:00:00Z"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## DELETE /task/delete/{id}

Soft-delete a task (sets is_deleted=true). Rejects when state=completed.

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

**Example request**

::: code-group

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

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/task/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/task/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/task/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 |  |

**Request body**

No request body.

**Response**

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

## GET /task/get-deleted

Returns ids of tasks deleted on or after `deleted_at` (also matches updated_at >= deleted_at).

**Required permission:** `tasks` · [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/task/get-deleted?deleted_at=DELETED_AT' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/task/get-deleted?deleted_at=DELETED_AT', {
  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/task/get-deleted?deleted_at=DELETED_AT",
    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/task/get-deleted?deleted_at=DELETED_AT');
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 |
|---|---|---|---|
| `deleted_at` | `string (date-time)` | Yes |  |

**Request body**

No request body.

**Response**

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

## PUT /task/complete

Mark a task as completed. Set is_postponed=true with postponed_date to clone the task at a future date (the original is marked completed; the clone has postponed_id pointing back to it).

**Required permission:** `tasks` · [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/task/complete' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "_id": "67b486d242ed76693cd2cc59"
}'
```

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

```php [PHP]
<?php
$body = <<<'JSON'
{
  "_id": "67b486d242ed76693cd2cc59"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/task/complete');
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 |  |
| `result_comment` | `string` | No |  |
| `is_postponed` | `boolean` | No | Default: `false` |
| `postponed_date` | `string (date-time)` | No | Required when is_postponed=true. Must be in the future. The original task is marked completed and a clone with postponed_id pointing to the original is created at this date. |

```json
{
  "_id": "67b486d242ed76693cd2cc59",
  "result_comment": "string",
  "is_postponed": false,
  "postponed_date": "2023-10-01T12:00:00Z"
}
```

**Response**

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

## PUT /task/move

Move a task into a time-frame bucket. Sets `date` to the bucket's start (today/tomorrow/week/month) or month_end+1s for future. `overdue` is rejected.

**Required permission:** `tasks` · [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/task/move' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "_id": "67b486d242ed76693cd2cc59",
  "time": "today"
}'
```

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

```php [PHP]
<?php
$body = <<<'JSON'
{
  "_id": "67b486d242ed76693cd2cc59",
  "time": "today"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/task/move');
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 |  |
| `time` | `string` | Yes | Target time-frame bucket. overdue is rejected.. One of: `today`, `tomorrow`, `week`, `month`, `future` |

```json
{
  "_id": "67b486d242ed76693cd2cc59",
  "time": "today"
}
```

**Response**

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

---

*This page is generated from the OpenAPI spec.*
