# Конфигурация WA

## Получить список конфигураций

<mark style="color:green;">`POST`</mark> `https://controller.touch-api.com/api/getConfigList`

#### Request Body

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| token<mark style="color:red;">\*</mark> | String |             |

## Получить конфигурацию

<mark style="color:green;">`POST`</mark> `https://controller.touch-api.com/api/getConfig`

#### Request Body

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| token<mark style="color:red;">\*</mark> | String |             |
| login<mark style="color:red;">\*</mark> | String |             |
| name<mark style="color:red;">\*</mark>  | String |             |

## Установить конфигурацию

<mark style="color:green;">`POST`</mark> `https://controller.touch-api.com/api/setConfig`

#### Request Body

| Name                                     | Type   | Description |
| ---------------------------------------- | ------ | ----------- |
| token<mark style="color:red;">\*</mark>  | String |             |
| login<mark style="color:red;">\*</mark>  | String |             |
| name<mark style="color:red;">\*</mark>   | String |             |
| config<mark style="color:red;">\*</mark> | Object |             |

**Config** позволяет настроить дополнительные параметры, такие как:

1. включение/отключение вебхуков на смену состояния (запуск, потеря соединения, конфликт)
2. реакция на открытие другого окна WhatsApp Web ("Использовать здесь")

| config name                | property name                       | type                     | meaning                                             | default                 |
| -------------------------- | ----------------------------------- | ------------------------ | --------------------------------------------------- | ----------------------- |
| services                   | stateHook                           | boolean                  | хуки на изменение состояния (п.1)                   | false                   |
| conflict                   | takeover                            | boolean                  | нажимать ли кнопку "Использовать здесь"             | false                   |
| <p><br></p><p>conflict</p> | <p><br></p><p>takeoverTimeoutMs</p> | <p><br></p><p>number</p> | задержка перед нажатием кнопки "Использовать здесь" | <p><br></p><p>10000</p> |

#### Пример вебхука при смене состояния:

```
{
  state: {
    current: {
      message: 'Account started successfully & is connected to phone now',
      value: 5
    },
    previous: {
      message: 'Account just started to start',
      value: 0
    }
  },
  time: 1597481788993000000,
  login: '380999999999',
  phone: '380999999999'
}

```

#### Пример входящего вебхука

```
{
  "from":"79999999999", 
  "to":"7998888888",
  "text":"text ", // текст сообщения
  "content": [
    {
      "type":"delivered", //статус доставки сообщения
      //возможные статусы
      //has_seen прочитано 
      //server отправлено на сервер
      //delivered доставлено получателю
      "src":"" //ссылка на медиа файл
    }
  ],
  "time":1637138181000000,
  "thread":"79999999999@c.us",
  "item":"99F39D2154F84418EAF0B4EDD3AFD90A",
  "source":"whatsapp"
}
```


---

# 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://docs.touch-api.com/reference/opisanie-api/whatsapp/konfiguraciya-wa.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.
