# Sms template

SMS message templates

::: 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 /sms-template/create

Create a new SMS template for the tenant.

**Kerakli ruxsat:** `sms_template` · [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/sms-template/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "content": "string"
}'
```

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

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

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/sms-template/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 |
|---|---|---|---|
| `content` | `string` | Ha | <span v-pre>SMS message body text. System variables: {name}, {phone_number}, {balance}. A customer custom field is referenced as {{&lt;field name&gt;}} (e.g. {{Mijoz mamlakati}}; case, spaces and underscores are ignored) and is stored as {{cf.&lt;custom_field_id&gt;}}, so renaming the field does not break the template. {{cf.&lt;custom_field_id&gt;}} is accepted as-is. A {{...}} that names no customer custom field is rejected with error code 116002.</span> |

```json
{
  "content": "string"
}
```

**Javob**

| Maydon | Tur | Tavsif |
|---|---|---|
| `_id` | `string` | SMS template ObjectId |
| `account_id` | `string` | Tenant identifier (immutable, injected server-side) |
| `content` | `string` | <span v-pre>SMS message body text. Customer custom-field variables are returned as {{cf.&lt;custom_field_id&gt;}}.</span> |
| `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) |
| `created_by` | `string` | ObjectId of the user who created this template |
| `updated_by` | `string` | ObjectId of the user who last updated this template |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "account_id": "string",
    "content": "string",
    "is_deleted": false,
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z",
    "created_by": "string",
    "updated_by": "string"
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## GET /sms-template/get-by-id/{id}

Fetch a single SMS template by ObjectId.

**Kerakli ruxsat:** `sms_template` · [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/sms-template/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/sms-template/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/sms-template/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/sms-template/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 | SMS template ObjectId |

**So‘rov tanasi**

So‘rov tanasi talab qilinmaydi.

**Javob**

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

## POST /sms-template/get-paging

Paginated list of SMS templates scoped to the tenant.

**Kerakli ruxsat:** `sms_template` · [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/sms-template/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/sms-template/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/sms-template/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/sms-template/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` |

```json
{
  "page": 1,
  "limit": 20
}
```

**Javob**

| Maydon | Tur | Tavsif |
|---|---|---|
| `total` | `number` |  |
| `list` | `object[]` |  |
| `list[]._id` | `string` | SMS template ObjectId |
| `list[].account_id` | `string` | Tenant identifier (immutable, injected server-side) |
| `list[].content` | `string` | <span v-pre>SMS message body text. Customer custom-field variables are returned as {{cf.&lt;custom_field_id&gt;}}.</span> |
| `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) |
| `list[].created_by` | `string` | ObjectId of the user who created this template |
| `list[].updated_by` | `string` | ObjectId of the user who last updated this template |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "list": [
      {
        "_id": "string",
        "account_id": "string",
        "content": "string",
        "is_deleted": false,
        "created_at": "2025-05-01T12:00:00Z",
        "updated_at": "2025-05-01T12:00:00Z",
        "created_by": "string",
        "updated_by": "string"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## PUT /sms-template/update/{id}

Update an existing SMS template by ObjectId.

**Kerakli ruxsat:** `sms_template` · [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/sms-template/update/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "content": "string"
}'
```

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

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

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

:::

**Yo‘l parametrlari**

| Parametr | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `id` | `string` | Ha | SMS template ObjectId |

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `content` | `string` | Ha | <span v-pre>SMS message body text. System variables: {name}, {phone_number}, {balance}. A customer custom field is referenced as {{&lt;field name&gt;}} (e.g. {{Mijoz mamlakati}}; case, spaces and underscores are ignored) and is stored as {{cf.&lt;custom_field_id&gt;}}, so renaming the field does not break the template. {{cf.&lt;custom_field_id&gt;}} is accepted as-is. A {{...}} that names no customer custom field is rejected with error code 116002.</span> |

```json
{
  "content": "string"
}
```

**Javob**

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

## DELETE /sms-template/delete/{id}

Soft-delete an SMS template by ObjectId (sets is_deleted=true).

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

**So‘rov namunasi**

::: code-group

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

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

:::

**Yo‘l parametrlari**

| Parametr | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `id` | `string` | Ha | SMS template ObjectId |

**So‘rov tanasi**

So‘rov tanasi talab qilinmaydi.

**Javob**

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

---

*Bu sahifa OpenAPI spetsifikatsiyasidan yaratilgan.*
