# Редактирование шаблонов

## Редактирование шаблона

<mark style="color:orange;">`PUT`</mark> `https://direct.i-dgtl.ru/api/v1/templates/{template_id}`

Метод позволяет отредактировать некоторые параметры шаблона.

#### Path Parameters

| Name                                           | Type   | Description           |
| ---------------------------------------------- | ------ | --------------------- |
| template\_id<mark style="color:red;">\*</mark> | string | Идентификатор шаблона |

#### Headers

| Name                                            | Type   | Description        |
| ----------------------------------------------- | ------ | ------------------ |
| Authorization<mark style="color:red;">\*</mark> | string | `Basic {TOKEN_2}`  |
| Content-Type<mark style="color:red;">\*</mark>  | string | `application/json` |

#### Request Body

| Name     | Type   | Description                                                                                                                                                                                      |
| -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| dateFrom | string | <p>Новая дата начала действия шаблона. Редактирование допускается для SMS-шаблонов в статусах:<br><code>INTERNAL\_REVEW</code>  <br><code>EXTERNAL\_REVIEW</code>  <br><code>REJECTED</code></p> |
| pattern  | string | <p>Новый текст шаблона. Редактирование допускается для SMS-шаблонов в статусах:<br><code>INTERNAL\_REVIEW</code>  <br><code>REJECTED</code></p>                                                  |
| dateTo   | string | Дата окончания действия шаблонов. Допускается для SMS и VIBER-шаблонов в статусе `APPROVED`                                                                                                      |

{% tabs %}
{% tab title="200" %}

```
{
  "id": 1234,
  "channelType": "SMS",
  "templateType": "SERVICE",
  "pattern": "привет, %w",
  "dateFrom": "2020-07-07T21:00:00Z",
  "dateTo": "2020-10-10T00:00:00Z",
  "senderNameId": 1234,
  "senderName": "testsend",
  "brand": "BEELINE",
  "managerComment": "комментарий менеджера",
  "status": "CLOSED",
  "createdAt": "2020-06-01T21:00:00Z",
  "rejectedAt": "2020-06-07T21:00:00Z"
}
```

Возвращается объект отредактированного шаблона.
{% endtab %}

{% tab title="401" %}
Использование невалидного токена / отсутствие заголовка авторизации.

{% tabs %}
{% tab title="4012" %}

```
{
    "error": {
        "code": 4012,
        "msg": "Bad credentials"
    }
}
```

{% endtab %}

{% tab title="4010" %}

```
{
    "error": {
        "code": 4010,
        "msg": "Not Authenticated"
    }
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="403" %}
Использование неподходящего токена.

```
{
    "error": {
        "code": 4012,
        "msg": "Access Denied"
    }
}
```

{% endtab %}

{% tab title="422" %}
Попытка редактирования недоступных при данном статусе параметров или невалидный текст шаблона; ниже приведены несколько примеров ответа.

```
{
    "error": {
        "code": 4220,
        "msg": "Forbidden to edit dateTo now"
    }
}
-----------------------------------------------------------------------------
{
    "error": {
        "code": 4221,
        "msg": "Invalid pattern",
        "correct-example": "%w{1,2} pattern"
    }
}
```

{% 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://api.docs.direct.i-dgtl.ru/templates/put.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.
