# Списки

## Схема списка

{% hint style="warning" %}
Как правильно сформировать запрос?! Смотрим в [основах](/dlya-razrabotchikov/dokumentaciya-i-rabota-s-api/osnovy.md)
{% endhint %}

## Получить списки (схемы)

<mark style="color:blue;">`GET`</mark> `https://app.cleverapp.pro/api/v1/getListSchemas`

Этот метод позволяет получить списки (схемы).

{% tabs %}
{% tab title="200: OK Запрос успешно обработан" %}

```javascript
{
  "data": [
    {
      "id": "5dee4800c2cc5a38ec797235",
      "fields": {
        "name": {
          "name": "Название",
          "type": "string",
          "is_required": true,
          "is_hidden": false,
          "is_encryptable": false
        },
        "quantity": {
          "name": "Количество",
          "type": "number",
          "is_required": false,
          "is_hidden": false,
          "is_encryptable": false
        },
        "is_vip": {
          "name": "VIP",
          "type": "bool",
          "is_required": true,
          "is_hidden": false,
          "is_encryptable": false
        },
        "contact": {
          "name": "Контакт",
          "type": "contact",
          "is_required": true,
          "is_hidden": false,
          "is_encryptable": false
        },
        "key": {
          "name": "Ключ",
          "type": "string",
          "is_required": true,
          "is_hidden": true,
          "is_encryptable": true
        }
      },
      "name": "Заказы",
      "is_menu": false,
      "created_at": "2019-12-09T13:11:28+00:00",
      "updated_at": "2019-12-09T13:11:28+00:00"
    }
  ],
  "links": {
    "first": "https:\/\/watbot.ru\/api\/v1\/getListSchemas?page=1",
    "last": "https:\/\/watbot.ru\/api\/v1\/getListSchemas?page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "path": "https:\/\/watbot.ru\/api\/v1\/getListSchemas",
    "per_page": 50,
    "to": 1,
    "total": 1
  }
}
```

{% endtab %}
{% endtabs %}

## Получить список (схему)

<mark style="color:blue;">`GET`</mark> `https://app.cleverapp.pro/api/v1/getListSchemas`

Этот метод позволяет получить списки (схемы).

{% tabs %}
{% tab title="200: OK Запрос успешно обработан" %}

```javascript
{
  "data": {
    "id": "5dee4800c2cc5a38ec797235",
    "fields": {
      "name": {
        "name": "Название",
        "type": "string",
        "is_required": true,
        "is_hidden": false,
        "is_encryptable": false
      },
      "quantity": {
        "name": "Количество",
        "type": "number",
        "is_required": false,
        "is_hidden": false,
        "is_encryptable": false
      },
      "is_vip": {
        "name": "VIP",
        "type": "bool",
        "is_required": true,
        "is_hidden": false,
        "is_encryptable": false
      },
      "contact": {
        "name": "Контакт",
        "type": "contact",
        "is_required": true,
        "is_hidden": false,
        "is_encryptable": false
      },
      "key": {
        "name": "Ключ",
        "type": "string",
        "is_required": true,
        "is_hidden": true,
        "is_encryptable": true
      }
    },
    "name": "Заказы",
    "is_menu": false,
    "created_at": "2019-12-09T13:11:28+00:00",
    "updated_at": "2019-12-09T13:11:28+00:00"
  }
}
```

{% endtab %}
{% endtabs %}

## Создать список (схему)

<mark style="color:green;">`POST`</mark> `https://app.cleverapp.pro/api/v1/createListSchema`

Этот метод позволяет создать список.

#### Request Body

| Name                                     | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                            |
| ---------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| is\_menu                                 | boolean | Отображать ссылку на список в меню в интерфейсе CleverApp                                                                                                                                                                                                                                                                                                                                              |
| name<mark style="color:red;">\*</mark>   | string  | Название списка.                                                                                                                                                                                                                                                                                                                                                                                       |
| bot\_id                                  | integer | ID бота, если вы хотите привязать список к боту.                                                                                                                                                                                                                                                                                                                                                       |
| fields<mark style="color:red;">\*</mark> | object  | **name** `string` - название поля **slug** `string` - уникальная строка поля **type** `string` - тип поля (string, number, boolean, contact, bot) - см. ниже. **is\_required** `boolean` - обязательность заполнения поля **is\_hidden** `boolean` - скрыть поле из интерфейса? **is\_encryptable** `boolean` - шифровать поле для хранения в БД? По таким поля нельзя делать фильтрацию и сортировку. |

{% tabs %}
{% tab title="200: OK Запрос успешно обработан" %}

```javascript
{
  "data": {
    "id": "5dee51518a7ab32ecf060265",
    "fields": {
      "name": {
        "name": "Название",
        "type": "string",
        "is_required": true,
        "is_hidden": false,
        "is_encryptable": false
      },
      "quantity": {
        "name": "Количество",
        "type": "number",
        "is_required": false,
        "is_hidden": false,
        "is_encryptable": false
      },
      "is_vip": {
        "name": "VIP",
        "type": "bool",
        "is_required": true,
        "is_hidden": false,
        "is_encryptable": false
      },
      "contact": {
        "name": "Контакт",
        "type": "contact",
        "is_required": true,
        "is_hidden": false,
        "is_encryptable": false
      },
      "key": {
        "name": "Ключ",
        "type": "string",
        "is_required": true,
        "is_hidden": true,
        "is_encryptable": true
      }
    },
    "name": "Заказы",
    "is_menu": true,
    "created_at": "2019-12-09T13:51:13+00:00",
    "updated_at": "2019-12-09T13:51:13+00:00"
  }
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Переданы некорректные данные" %}

```javascript
{
  "message": "The given data was invalid.",
  "errors": {
    "name": [
      "Поле Имя обязательно для заполнения."
    ],
    "fields": [
      "Поле fields обязательно для заполнения."
    ]
  }
}
```

{% endtab %}
{% endtabs %}

#### Типы поля `fields["type"]` <a href="#tipy-polya-fields-type" id="tipy-polya-fields-type"></a>

| Тип       | Значение       |
| --------- | -------------- |
| `string`  | строка/текст   |
| `number`  | число          |
| `boolean` | логический тип |
| `contact` | id контакта    |
| `bot`     | id бота        |

## Добавить новое поле в список (схему)

<mark style="color:green;">`POST`</mark> `https://app.cleverapp.pro/api/v1/addListSchemaField`

Этот метод позволяет добавить новое поле в список.

#### Request Body

| Name                                         | Type   | Description                                                                                           |
| -------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------- |
| field<mark style="color:red;">\*</mark>      | object | Смотрите метод **createListSchema** поле **fields**. Укажите только те поля, которые хотите обновить. |
| schema\_id<mark style="color:red;">\*</mark> | string | ID списка.                                                                                            |

{% tabs %}
{% tab title="201: Created Запрос успешно обработан" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Если в списке есть уже элементы, то созданное поле заполнится для них значением `null`
{% endhint %}

## Удалить поле списка (схемы)

<mark style="color:green;">`POST`</mark> `https://app.cleverapp.pro/api/v1/deleteListSchemaField`

Этот метод позволяет удалить поле списка.

#### Request Body

| Name                                         | Type   | Description |
| -------------------------------------------- | ------ | ----------- |
| slug<mark style="color:red;">\*</mark>       | string | Slug поля.  |
| schema\_id<mark style="color:red;">\*</mark> | string | ID списка.  |

{% tabs %}
{% tab title="204: No Content Запрос успешно обработан" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Удалить список (схему)

<mark style="color:green;">`POST`</mark> `https://app.cleverapp.pro/api/v1/deleteListSchema`

Этот метод позволяет удалить список.

#### Request Body

| Name                                         | Type   | Description |
| -------------------------------------------- | ------ | ----------- |
| schema\_id<mark style="color:red;">\*</mark> | string | ID списка.  |

{% tabs %}
{% tab title="204: No Content Запрос успешно обработан" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.cleverapp.pro/dlya-razrabotchikov/dokumentaciya-i-rabota-s-api/spiski.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
