# Введение

Mottor API - это программный интерфейс для доступа к функциям конструктора сайтов и интернет-магазинов Mottor.

## Что такое Mottor API

Это программный интерфейс для доступа к функциям конструктора сайтов и интернет-магазинов [Mottor](https://lpmotor.ru).


# Авторизация

Авторизуйтесь на Mottor API и получайте ID пользователя  на сайте Mottor

## Как получить доступ к Mottor API

Любой пользователь конструктора сайтов [Mottor](https://lpmotor.ru) уже имеет доступ к API. Для этого надо получить API-ключ и ID пользователя.

### Как получить ID пользователя

1. Зайти в [личный кабинет Mottor](https://lpmotor.ru/admin).
2. Нажать в правом верхнем углу на имя пользователя и скопировать значение `Ваш ID`

![](/files/-MgjIlcyVtNEcwCmq5FV)

### Как получить API-ключ

1. Зайти в [личный кабинет Mottor](https://lpmotor.ru/admin).
2. Зайти в раздел "[Профиль](https://lpmotor.ru/admin/profile/view/general)".
3. Скопировать значение из секции "API-ключ".

{% hint style="danger" %}
&#x20;**Не передавайте ключ посторонним людям!!!**

Запросы к API изменяют данные на ваших сайтах. Если доступ к ключу будет у посторонних лиц, они смогут управлять вашими сайтами.
{% endhint %}

{% hint style="info" %}
Если ключ попал в чужие руки, то в личном кабинете перейдите в профиль и в секции "API-ключ" сгенерируйте новый токен.
{% endhint %}

### Отправка запросов

Все запросы должны содержать в себе 2 заголовка:&#x20;

| Имя заголовка | Значение заголовка   |
| ------------- | -------------------- |
| X-Api-User-Id | id пользователя      |
| Authorization | "Bearer " + API-ключ |


# Ограничения

Ограничения на количество запросов с одного аккаунта

## Rate limits

Количество запросов с одного аккаунта не должно превышать 30 в минуту.

{% hint style="info" %}
&#x20;Если количество запросов все-таки превысило этот лимит, подождите одну минуту для последующего обращения к API
{% endhint %}


# Сайты

С помощью методов этого раздела вы можете:

* найти сайт и получить по нему подробную информаци
* получить страницы сайта и получить по каждой странице подрбную информацию


# Список сайтов

Список сайтов пользователя, в котором он является владельцем

<mark style="color:green;">`GET`</mark> `/v3/public/site`

**Заголовки**

<table><thead><tr><th width="374">Название</th><th>Значение</th></tr></thead><tbody><tr><td>Content-Type</td><td><code>application/json</code></td></tr><tr><td>Authorization</td><td>API-токен.  <code>Bearer &#x3C;token></code></td></tr><tr><td>X-Api-User-Id</td><td>ID пользователя</td></tr></tbody></table>

**Query параметры**

| Название | Тип     | Описание                                                          |
| -------- | ------- | ----------------------------------------------------------------- |
| `offset` | integer | С какого по счету элемента выдаётся список. По умолчанию - 0      |
| `limit`  | integer | Лимит выдаваемых сайтов. Значения от 1 до 100. По умолчанию - 100 |

**Ответ**

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

```json
{
  "count": 0,
  "sites": [
    {
      "id": 0,
      "title": "string"
    }
  ]
}
```

{% endtab %}

{% tab title="Ошибка" %}

```json
{  
  "title": "error message",
  "error": 0,
  "code": 0
}
```

{% endtab %}
{% endtabs %}


# Информация о сайте

Подробная информации о сайте по его id. Информация доступна только токену, который принадлежит владельцу сайта.

<mark style="color:green;">`GET`</mark> `/v3/public/site/{site_id}`

**Заголовки**

<table><thead><tr><th width="374">Название</th><th>Значение</th></tr></thead><tbody><tr><td>Content-Type</td><td><code>application/json</code></td></tr><tr><td>Authorization</td><td>API-токен.  <code>Bearer &#x3C;token></code></td></tr><tr><td>X-Api-User-Id</td><td>ID пользователя</td></tr></tbody></table>

**Параметры в пути метода**

| Name      | Type    | Description                             |
| --------- | ------- | --------------------------------------- |
| `site_id` | integer | ID сайта, для которого нужна информация |

**Ответ**

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

```json
{
  "id": 0,
  "title": "string",
  "home_page_id": 0,
  "domains": [
    "string"
  ],
  "is_published": true,
  "is_demo_enabled": true,
  "d_created": "2025-11-21T11:31:32.054Z",
  "d_updated": "2025-11-21T11:31:32.054Z"
}
```

{% endtab %}

{% tab title="Ошибка" %}

```json
{  
  "title": "error message",
  "error": 0,
  "code": 0
}
```

{% endtab %}
{% endtabs %}


# Список страниц

Список страниц сайта по его id. Информация доступна только токену, который принадлежит владельцу сайта.

<mark style="color:green;">`GET`</mark> `/v3/public/site/{site_id}/page`

**Заголовки**

<table><thead><tr><th width="374">Название</th><th>Значение</th></tr></thead><tbody><tr><td>Content-Type</td><td><code>application/json</code></td></tr><tr><td>Authorization</td><td>API-токен.  <code>Bearer &#x3C;token></code></td></tr><tr><td>X-Api-User-Id</td><td>ID пользователя</td></tr></tbody></table>

**Параметры в пути метода**

| Name      | Type    | Description                             |
| --------- | ------- | --------------------------------------- |
| `site_id` | integer | ID сайта, для которого нужна информация |

**Query параметры**

| Название | Тип     | Описание                                                        |
| -------- | ------- | --------------------------------------------------------------- |
| `offset` | integer | С какого по счету элемента выдаётся список. По умолчанию - 0    |
| `limit`  | integer | Лимит выдаваемых сайтов. Значения от 1 до 50. По умолчанию - 18 |

**Ответ**

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

```json
{
  "count": 0,
  "pages": [
    {
      "id": 0,
      "name": "string",
      "url_path": "string"
    }
  ]
}
```

{% endtab %}

{% tab title="Ошибка" %}

```json
{  
  "title": "error message",
  "error": 0,
  "code": 0
}
```

{% endtab %}
{% endtabs %}


# Информация о странице

Подробная информация о странице по id. Информация доступна только токену, который принадлежит владельцу сайта этой страницы.

<mark style="color:green;">`GET`</mark> `/v3/public/site/page/{page_id}`

**Заголовки**

<table><thead><tr><th width="374">Название</th><th>Значение</th></tr></thead><tbody><tr><td>Content-Type</td><td><code>application/json</code></td></tr><tr><td>Authorization</td><td>API-токен.  <code>Bearer &#x3C;token></code></td></tr><tr><td>X-Api-User-Id</td><td>ID пользователя</td></tr></tbody></table>

**Параметры в пути метода**

| Name      | Type    | Description                               |
| --------- | ------- | ----------------------------------------- |
| `page_id` | integer | ID страницы, для которой нужна информация |

**Response**

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

```json
{
  "id": 0,
  "name": "string",
  "url_path": "string",
  "is_home_page": true,
  "is_enabled": true,
  "is_demo": true,
  "in_archive": true,
  "is_head_overridden": true,
  "is_footer_overridden": true,
  "variant_name": "string",
  "d_created": "2025-11-25T16:49:16.384Z",
  "is_ab_test": true,
  "variants": [
    {
      "id": 0,
      "name": "string",
      "is_enabled": true,
      "is_demo": true,
      "in_archive": true,
      "is_head_overridden": true,
      "is_footer_overridden": true,
      "variant_name": "string",
      "d_created": "2025-11-25T16:49:16.384Z"
    }
  ]
}
```

{% endtab %}

{% tab title="Ошибка" %}

```json
{  
  "title": "error message",
  "error": 0,
  "code": 0
}
```

{% endtab %}
{% endtabs %}


# Заявки

Оставляйте заявки на доступ к функциям конструктора сайтов и интернет-магазинов Mottor

## Работа с заявками


# Работа с заявками

Работа с заявками. Получить, создать или удалить заявку. Как обновить статус заявки — всё это можно узнать  на нашем сайте

## Работа с заявками из корзины

## Список заявок

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/lead`

Получение списка заявок по фильтрам

#### Query Parameters

| Name             | Type   | Description                                                                                         |
| ---------------- | ------ | --------------------------------------------------------------------------------------------------- |
| offset           | string | С какого по счету элемента выдавать список. По умолчанию - 0                                        |
| limit            | string | Лимит выдаваемых сайтов. По умолчанию - 18                                                          |
| sort\_field      | string | Тип сортировки поля. По умолчанию - id                                                              |
| sort\_dir        | string | Сортировка по возрастанию или убыванию. Доступные значения - DESC,ASC. По умолчанию - DESC          |
| type\_id         | array  | Выбор типа заявки для показа. Список типов в таблице. По умолчанию показываются все типы            |
| status\_id       | array  | Статус заявки. Список статусов в таблице ниже. По умолчанию показываются заявки со всеми статусами. |
| page\_id         | string | ID страницы                                                                                         |
| site\_id         | string | ID сайта                                                                                            |
| d\_create\_start | string | Время создания заявки в формате  ISO8601.                                                           |
| d\_create\_end   | string | Время создания заявки в формате ISO8601.                                                            |
| search\_text     | string | Произвольный текст. ищет совпадения в имени, email и номере телефоне.                               |

#### Headers

| Name          | Type    | Description     |
| ------------- | ------- | --------------- |
| X-Api-User-Id | integer | ID пользователя |
| Authorization | string  | API-токен       |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
{
  "count": 0,
  "sum": 0,
  "limit": 0,
  "offset": 0,
  "leads": [
    {
      "id": 0,
      "page_id": 0,
      "name": "string",
      "phone": "string",
      "email": "string",
      "ip": "string",
      "ip_banned": 0,
      "is_del": 0,
      "type_id": 0,
      "status_id": 0,
      "f_expense": 0,
      "f_profit": 0,
      "kanban_position": 0,
      "d_created": "string",
      "page": {
        "id": 0,
        "user_id": 0,
        "name": "string",
        "url": "string",
        "site_id": 0,
        "is_enabled": true,
        "d_last_change": "string",
        "site": {
          "id": int,
          "title": "string",
          "subdomain": "string",
          "attached_domain": "string",
          "is_del": false
        },
        "is_base_variant": false,
        "is_variant": false,
        "variant_name": "string"
      },
      "cart": null,
      "total_price": 0
    }
  ]
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/lead?d_create_start=2020-08-09+00:00:00%2B05:00&sort_field[]=dCreated&sort_dir[]=ASC&status_id[]=1&limit=18&offset=0"
```

{% endtab %}

{% tab title="PHP CURL" %}

```php
<?php
$ch = curl_init();
$url = 'https://api.lpmotor.ru/v1/lead';
$params = [
    'd_create_start' => '2021-02-16T09:25:43+00:00',
    'd_create_end' => '2021-03-16T09:25:43+00:00',
    'status_id' => [1],
    'type_id' => [1],
];
$url .= '?' . http_build_query($params);

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'X-Api-User-Id: ' . $userId,
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$responseData = json_decode($result, true);

curl_close($ch);
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get(
    '/v1/lead',
    [
        'query' => [
            'd_create_start' => '2021-02-16T09:25:43+00:00',
            'd_create_end' => '2021-03-16T09:25:43+00:00',
            'status_id' => [1],
            'type_id' => [1],
        ]
    ]
);
$statusCode = $response->getStatusCode();
$responseData = json_decode((string)$response->getBody(), true);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 30000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/lead", {
    params: data
})
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});
```

{% endtab %}
{% endtabs %}

## Получить заявку

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/lead/{lead_id}`

#### Path Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| lead\_id | integer | ID заявки   |

#### Headers

| Name          | Type    | Description     |
| ------------- | ------- | --------------- |
| X-Api-User-Id | integer | ID пользователя |
| Authorization | string  | API-токен       |

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

```
{
  "id": int,
  "page_id": int,
  "name": "string",
  "phone": "string",
  "email": null,
  "ip": "string",
  "ip_banned": 0,
  "is_del": 0,
  "type_id": 2,
  "status_id": 1,
  "f_expense": 0,
  "f_profit": 0,
  "kanban_position": 0,
  "status": {
    "id": 1,
    "class": "new"
  },
  "type": {
    "id": 2,
    "class": "order"
  },
  "d_created": "string",
  "history": [
    {
      "id": 0,
      "typeId": null,
      "statusId": null,
      "message": "string",
      "d_created": "string"
    }
  ],
  "page": {
    "id": 0,
    "user_id": 0,
    "name": "string",
    "url": "string",
    "site_id": 0,
    "is_enabled": false,
    "d_last_change": "string",
    "site": {
      "id": 0,
      "title": "string",
      "subdomain": "string",
      "attached_domain": "string",
      "is_del": false
    },
    "is_base_variant": false,
    "is_variant": false,
    "variant_name": "string"
  },
  "cart": null,
  "total_price": 234
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/lead/<<lead_id>>"
```

{% endtab %}

{% tab title="PHP CURL" %}

```php
<?php
$ch = curl_init();
$url = 'https://api.lpmotor.ru/v1/lead/' . $leadId;

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'X-Api-User-Id: ' . $userId,
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$responseData = json_decode($result, true);

curl_close($ch);
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get('/v1/lead/' . $leadId);
$statusCode = $response->getStatusCode();
$responseData = json_decode((string)$response->getBody(), true);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 30000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/lead/" + leadId)
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});
```

{% endtab %}
{% endtabs %}

## Создать заявку

<mark style="color:green;">`POST`</mark> `https://api.lpmotor.ru/v1/lead`

#### Headers

| Name          | Type    | Description     |
| ------------- | ------- | --------------- |
| X-Api-User-Id | integer | ID пользователя |
| Authorization | string  | API-токен       |

#### Request Body

| Name       | Type   | Description          |
| ---------- | ------ | -------------------- |
| page\_id   | string | ID страницы          |
| status\_id | string | ID статуса заявки    |
| type\_id   | string | ID типа заявки       |
| ip         | string | IP пользователя      |
| name       | string | Имя пользователя     |
| email      | string | Email пользователя   |
| phone      | string | Телефон пользователя |
| comment    | string | Комментарий к заявке |
| f\_income  | string | Сумма сделки         |

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

```
{
  "id": int,
  "page_id": int,
  "name": "string",
  "phone": "string",
  "email": null,
  "ip": "string",
  "ip_banned": 0,
  "is_del": 0,
  "type_id": 2,
  "status_id": 1,
  "f_expense": 0,
  "f_profit": 0,
  "kanban_position": 0,
  "status": {
    "id": 1,
    "class": "new"
  },
  "type": {
    "id": 2,
    "class": "order"
  },
  "d_created": "string",
  "history": [
    {
      "id": 0,
      "typeId": null,
      "statusId": null,
      "message": "string",
      "d_created": "string"
    }
  ],
  "page": {
    "id": 0,
    "user_id": 0,
    "name": "string",
    "url": "string",
    "site_id": 0,
    "is_enabled": false,
    "d_last_change": "string",
    "site": {
      "id": 0,
      "title": "string",
      "subdomain": "string",
      "attached_domain": "string",
      "is_del": false
    },
    "is_base_variant": false,
    "is_variant": false,
    "variant_name": "string"
  },
  "cart": null,
  "total_price": 234
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X POST "https://api.lpmotor.ru/v1/lead" \
-d "{page_id: <<page_id>>, status_id: <<status_id>>, type_id: <<type_id>>}"
```

{% endtab %}

{% tab title="PHP CURL" %}

```php
<?php
$ch = curl_init();
$url = 'https://api.lpmotor.ru/v1/lead';
$data = [
    'page_id'   => $pageId,
    'status_id' => $statusId,
    'type_id'   => $typeId,
];

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'X-Api-User-Id: ' . $userId,
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$responseData = json_decode($result, true);

curl_close($ch);
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$data = [
    'page_id'   => $pageId,
    'status_id' => $statusId,
    'type_id'   => $type_id,
];
$response = $client->post(
    '/v1/lead',
    [
        'json' => $data,
    ]
);
$statusCode = $response->getStatusCode();
$responseData = json_decode((string)$response->getBody(), true);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 30000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.post("/v1/lead", {
    page_id  : pageId,
    status_id: statusId,
    type_id  : typeId
})
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});
```

{% endtab %}
{% endtabs %}

## Обновить статус заявки

<mark style="color:purple;">`PATCH`</mark> `https://api.lpmotor.ru/v1/lead/{lead_id}/status`

#### Path Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| lead\_id | integer | ID заявки   |

#### Headers

| Name          | Type    | Description     |
| ------------- | ------- | --------------- |
| X-Api-User-Id | integer | ID пользователя |
| Authorization | string  | API-токен       |

#### Request Body

| Name       | Type    | Description              |
| ---------- | ------- | ------------------------ |
| status\_id | integer | ID нового статуса заявки |

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

```
{
  "id": 0,
  "page_id": 0,
  "name": "string",
  "phone": "string",
  "email": "string",
  "ip": "string",
  "ip_banned": 0,
  "is_del": 0,
  "type_id": 0,
  "status_id": 0,
  "f_expense": 0,
  "f_profit": 0,
  "kanban_position": 0,
  "d_created": "string",
  "page": {
    "id": 0,
    "user_id": 0,
    "name": "string",
    "url": "string",
    "site_id": 0,
    "is_enabled": true,
    "d_last_change": "string",
    "site": {
      "id": int,
      "title": "string",
      "subdomain": "string",
      "attached_domain": "string",
      "is_del": false
    },
    "is_base_variant": false,
    "is_variant": false,
    "variant_name": "string"
  },
  "cart": null,
  "total_price": 0
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X PATCH "https://api.lpmotor.ru/v1/lead/<<lead_id>>/status" \
-d "{status_id: <<status_id>>}"
```

{% endtab %}

{% tab title="PHP CURL" %}

```php
<?php
$ch = curl_init();
$url = 'https://api.lpmotor.ru/v1/lead/' . $leadId. '/status';
$data = ['status_id' => $statusId];

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'X-Api-User-Id: ' . $userId,
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$responseData = json_decode($result, true);

curl_close($ch);
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$data = ['status_id' => $statusId];
$response = $client->patch(
    '/v1/lead/' . $leadId . '/status',
    [
        'json' => $data,
    ]
);
$statusCode = $response->getStatusCode();
$responseData = json_decode((string)$response->getBody(), true);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 30000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.patch("/v1/lead/" + leadId + "/status", {status_id: statusId})
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});
```

{% endtab %}
{% endtabs %}

## Удалить заявку

<mark style="color:red;">`DELETE`</mark> `https://api.lpmotor.ru/v1/lead/{lead_id}`

#### Path Parameters

| Name     | Type    | Description         |
| -------- | ------- | ------------------- |
| lead\_id | integer | ID удаляемой заявки |

#### Headers

| Name          | Type    | Description     |
| ------------- | ------- | --------------- |
| X-Api-User-Id | integer | ID пользователя |
| Authorization | string  | API-токен       |

{% tabs %}
{% tab title="204 Заявка успешно удалена" %}

```
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X DELETE "https://api.lpmotor.ru/v1/lead/<<lead_id>>"
```

{% endtab %}

{% tab title="PHP CURL" %}

```php
<?php
$ch = curl_init();
$url = 'https://api.lpmotor.ru/v1/lead/' . $leadId;

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'X-Api-User-Id: ' . $userId,
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->delete('/v1/lead/' . $leadId);
$statusCode = $response->getStatusCode();
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 30000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.delete("/v1/lead/" + leadId)
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});
```

{% endtab %}
{% endtabs %}


# Товары из корзины

Метод позволяет получить товары, добавленные пользователем вашего сайта в корзину.

## Работа с товарами из корзины

{% hint style="info" %}
Для этого метода вам нужно знать id корзины. Его можно получить из API [работа с заявками](/zayavki/leads).
{% endhint %}

### Описание

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/cart/{cartId}/product`

#### Path Parameters

| Name   | Type    | Description |
| ------ | ------- | ----------- |
| cartId | integer | ID корзины  |

#### Headers

| Name                                            | Type    | Description     |
| ----------------------------------------------- | ------- | --------------- |
| X-Api-User-Id<mark style="color:red;">\*</mark> | integer | ID пользователя |
| Authorization<mark style="color:red;">\*</mark> | string  | API токен       |

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

```javascript
[
  {
    "id": 0,
    "product_id": 0,
    "name": "string",
    "sku": "string",
    "price": "string",
    "amount": 0,
    "is_bonus": true,
    "discount": "string"
  }
]
```

{% endtab %}
{% endtabs %}

### Примеры

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/cart/<<cart_id>>/product"
```

{% endtab %}

{% tab title="PHP(CURL)" %}

```php
<?php
$ch = curl_init();
$url = 'https://api.lpmotor.ru/v1/cart/' . $cartId. '/product';

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'X-Api-User-Id: ' . $userId,
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$responseData = json_decode($result, true);

curl_close($ch);
```

{% endtab %}

{% tab title="PHP(Guzzle)" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get('/v1/cart/' . $cartId. '/product');
$statusCode = $response->getStatusCode();
$responseData = json_decode((string)$response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript(Axios)" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 30000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/cart/" + cartId + "/product")
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});
```

{% endtab %}
{% endtabs %}


# Товары

В этом разделе собраны все методы, которые позволяют управлять товарами на сайте.

## Настройки товаров


# Импорт

Метод API, который позволяет загрузить свои товары в конструктор из файла в формате csv или в формате YML(Yandex Markup Language)

## Импорт товаров

### Описание

<mark style="color:green;">`POST`</mark> `https://api.lpmotor.ru/v1/shop/product/import`

#### Headers

| Name                                            | Type    | Description |
| ----------------------------------------------- | ------- | ----------- |
| Authorization<mark style="color:red;">\*</mark> | string  |             |
| X-Api-User-Id<mark style="color:red;">\*</mark> | integer |             |

#### Request Body

| Name                                         | Type    | Description                                            |
| -------------------------------------------- | ------- | ------------------------------------------------------ |
| site\_id<mark style="color:red;">\*</mark>   | integer | ID сайта                                               |
| data\_file<mark style="color:red;">\*</mark> | string  | Контент файла. Данные должны быть кодированы в base64. |
| file\_type<mark style="color:red;">\*</mark> | String  | Тип файла. Поддерживаемые значения: **csv, yml**       |

{% tabs %}
{% tab title="201: Created " %}

```javascript
{
  "job_id": 0
}
```

{% endtab %}
{% endtabs %}

### Примеры

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

```bash
export products_csv=$(cat products.csv | base64)
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X POST "https://api.lpmotor.ru/v1/shop/product/import" \ 
-d "{\"data_file\": \"${products_csv}\",\"site_id\":11111,\"file_type\":\"csv\"}"
```

{% endtab %}

{% tab title="PHP(CURL)" %}

```php
<?php

$data = [
    'site_id': 11111,
    'file_type': "csv",
    'data_file': base64_encode(file_get_contents('products.csv')),
];

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.lpmotor.ru/v1/shop/product/import');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'X-Api-User-Id: ' . $userId,
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
```

{% endtab %}

{% tab title="PHP(Guzzle)" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->post(
    '/v1/shop/product/import',
    [
        'json' => [
            'data_file' => base64_encode(file_get_contents('products.csv')),
            'site_id' => $siteId,
            'file_type' => 'csv',
        ],
    ]
);
$statusCode = $response->getStatusCode();
```

{% endtab %}
{% endtabs %}


# Экспорт

Метод API, который позволяет выгрузить товары из конструктора в формате CSV или в формате YML(Yandex Markup Language)

## Экспорт товаров

{% hint style="warning" %}
Этот метод временно отключен и находится в доработке
{% endhint %}

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/shop/product/site/{site_id}.{file_type}`

#### Path Parameters

| Name                                         | Type    | Description                                                   |
| -------------------------------------------- | ------- | ------------------------------------------------------------- |
| site\_id<mark style="color:red;">\*</mark>   | integer | ID сайта                                                      |
| file\_type<mark style="color:red;">\*</mark> | string  | Тип файла для выгрузки. Поддерживаемые значения: **csv, yml** |

#### Headers

| Name                                            | Type   | Description     |
| ----------------------------------------------- | ------ | --------------- |
| Authorization<mark style="color:red;">\*</mark> | string | API токен       |
| X-Api-User-Id<mark style="color:red;">\*</mark> | string | ID пользователя |

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

```
{
    "data": "base64_encoded_string"
}
```

{% endtab %}

{% tab title="403 " %}

```
{
    "title": "user can`t assess to edit this site",
    "error": 8,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/shop/product/site/11111.csv" 
```

{% endtab %}

{% tab title="PHP CURL" %}

```php
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.lpmotor.ru/v1/shop/product/site/' . $siteId . '.csv');
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'X-Api-User-Id: ' . $userId,
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$siteList = json_decode($result, true);

curl_close($ch);
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get(
    '/v1/shop/product/site/' . $siteId . '.csv'
);
$statusCode = $response->getStatusCode();
$productsAsFile = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/shop/product/site/" + siteId + ".csv");
```

{% endtab %}
{% endtabs %}

#### Пример запроса


# Информация о товаре

Метод API, по которому можно получить подробную информацию о товаре

## Инфорация о товаре

### Описание

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/shop/product/{product_id}`

#### Path Parameters

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| product\_id<mark style="color:red;">\*</mark> | integer | ID товара   |

#### Headers

| Name                                            | Type    | Description     |
| ----------------------------------------------- | ------- | --------------- |
| Authorization<mark style="color:red;">\*</mark> | string  | API токен       |
| X-Api-User-Id<mark style="color:red;">\*</mark> | integer | ID пользователя |

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

```javascript
{
  "id": 0,
  "sku": "string",
  "name": "string",
  "description": "string",
  "price": 0,
  "is_visible": true,
  "quantity": 0,
  "weight": 0,
  "length": 0,
  "width": 0,
  "height": 0,
  "categories": [
    {
      "id": 0
    }
  ],
  "param_group_id": 0,
  "variants": [
    null
  ],
  "parent_id": 0,
  "old_price": 0,
  "short_description": "string",
  "description_url": "string",
  "image_list": [
    {
      "id": 0,
      "url": "string",
      "status_id": 0
    }
  ],
  "params": [
    {
      "id": 0,
      "type_id": 0,
      "name": "string",
      "unit": "string",
      "is_visible": true,
      "values": [
        {
          "id": 0,
          "label": "string",
          "value": "string",
          "is_visible": true,
          "image_status_id": 0,
          "image_url": "string"
        }
      ]
    }
  ],
  "modifiers": [
    {
      "id": 0,
      "type": 0,
      "name": "string",
      "price": "string",
      "max_count": 0,
      "default": true,
      "image": {
        "id": 0,
        "url": "string",
        "status_id": 0
      },
      "is_visible": true,
      "extra": [
        null
      ]
    }
  ]
}
```

{% endtab %}
{% endtabs %}

### Примеры

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/shop/product/12345" 
```

{% endtab %}

{% tab title="PHP(CURL)" %}

```php
<?php
$ch = curl_init();

$productId = 12345;
curl_setopt($ch, CURLOPT_URL, 'https://api.lpmotor.ru/v1/shop/product/'. $productId);
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'Authorization: Bearer ' . $apiKey,
        'Content-type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$bodyArray = json_decode($result, true);

```

{% endtab %}

{% tab title="PHP(Guzzle)" %}

```php
<?php
$productId = 12345;
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get(
    '/v1/shop/product/' . $productId
);
$statusCode = $response->getStatusCode();
$products = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript(Axios)" %}

```php
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 30000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/shop/product/" + productId);
```

{% endtab %}
{% endtabs %}


# Создать товар

В этом разделе описан API метод для создания товара.

## Создание товара

### Описание

<mark style="color:green;">`POST`</mark> `https://api.lpmotor.ru/v1/shop/product`

#### Headers

| Name                                            | Type    | Description     |
| ----------------------------------------------- | ------- | --------------- |
| X-Api-User-Id<mark style="color:red;">\*</mark> | integer | ID пользователя |
| Authorization<mark style="color:red;">\*</mark> | string  | API токен       |

#### Request Body

| Name                                          | Type    | Description               |
| --------------------------------------------- | ------- | ------------------------- |
| short\_description                            | string  | короткое описание товара  |
| description                                   | string  | полное описание товара    |
| name<mark style="color:red;">\*</mark>        | string  | название товара           |
| sku                                           | string  | sku                       |
| site\_id<mark style="color:red;">\*</mark>    | integer | id сайта                  |
| description\_url                              | string  | ссылка на описание товара |
| price<mark style="color:red;">\*</mark>       | float   | цена                      |
| old\_price                                    | float   | предыдущая цена           |
| is\_visible<mark style="color:red;">\*</mark> | boolean | флаг видимости товара     |
| quantity                                      | integer | количество товара         |
| weight                                        | integer | вес                       |
| length                                        | integer | длина                     |
| width                                         | integer | ширина                    |
| height                                        | integer | высота                    |

{% tabs %}
{% tab title="201: Created " %}

```javascript
{
  "id": 0,
  "sku": "string",
  "name": "string",
  "description": "string",
  "price": 0,
  "is_visible": true,
  "quantity": 0,
  "weight": 0,
  "length": 0,
  "width": 0,
  "height": 0,
  "categories": [
    {
      "id": 0
    }
  ],
  "param_group_id": 0,
  "variants": [
    null
  ],
  "parent_id": 0,
  "old_price": 0,
  "short_description": "string",
  "description_url": "string",
  "image_list": [
    {
      "id": 0,
      "url": "string",
      "status_id": 0
    }
  ],
  "params": [
    {
      "id": 0,
      "type_id": 0,
      "name": "string",
      "unit": "string",
      "is_visible": true,
      "values": [
        {
          "id": 0,
          "label": "string",
          "value": "string",
          "is_visible": true,
          "image_status_id": 0,
          "image_url": "string"
        }
      ]
    }
  ],
  "modifiers": [
    {
      "id": 0,
      "type": 0,
      "name": "string",
      "price": "string",
      "max_count": 0,
      "default": true,
      "image": {
        "id": 0,
        "url": "string",
        "status_id": 0
      },
      "is_visible": true,
      "extra": [
        null
      ]
    }
  ]
}
```

{% endtab %}
{% endtabs %}

### Примеры

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X POST "https://api.lpmotor.ru/v1/shop/product" \
-d "{\"site_id\": 11111, \"name\": \"product name\", \"price\": 109.99, \"is_visible\": true}
```

{% endtab %}

{% tab title="PHP(CURL)" %}

```php
<?php
$ch = curl_init();
$url = 'https://api.lpmotor.ru/v1/shop/product';
$data = [
    'site_id'    => $siteId,
    'name'       => 'product name',
    'price'      => 109.99,
    'is_visible' => true,
];

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'X-Api-User-Id: ' . $userId,
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$responseData = json_decode($result, true);

curl_close($ch);
```

{% endtab %}

{% tab title="PHP(Guzzle)" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);

$data = [
    'site_id'    => $siteId,
    'name'       => 'product name',
    'price'      => 109.99,
    'is_visible' => true,
];

$response = $client->post(
    '/v1/shop/product',
    [
        'json' => $data,
    ]
);
$statusCode = $response->getStatusCode();
$responseData = json_decode((string)$response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript(Axios)" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 30000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.post("/v1/shop/product", {
    site_id    : 11111,
    name       : "products name",
    price      : 109.99,
    is_visible : true,
})
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});
```

{% endtab %}
{% endtabs %}


# Доставки

Получение списка доставок. Как создать, изменить или удалить доставки. Всё покажем с примерами на нашем сайте

## Работа с доставками

## Получение списка доставок

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/delivery/site/{site_id}`

#### Path Parameters

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| site\_id | string | ID сайта    |

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

{% tabs %}
{% tab title="200 Для доставок, у которых template\_id от 1 до 4, в ответе будет "internal\_info": null" %}

```
[
  {
    "id": 0,
    "template_id": 0,
    "site_id": 0,
    "title": "string",
    "price": "string",
    "free_start_from": "string",
    "creator_id": 0,
    "d_created": "2021-08-04T15:28:46.655Z",
    "d_updated": "2021-08-04T15:28:46.655Z",
    "enabled": true,
    "deleted": true,
    "points": [
      {
        "id": 0,
        "title": "string",
        "price": "string",
        "free_start_from": "string",
        "country": "string",
        "city": "string",
        "zip": "string",
        "street": "string",
        "building_number": "string",
        "office_number": "string",
        "floor": 0,
        "comment": "string",
        "enabled": true,
        "deleted": true
      }
    ],
    "regions": [
      {
        "id": 0,
        "title": "string",
        "price": "string",
        "free_start_from": "string",
        "comment": "string",
        "enabled": true,
        "deleted": true,
        "coordinates": [[0, 0],[0, 0],[0, 0]]
      }
    ],
    "additional_fields": [
      {
        "id": 0,
        "name": "string",
        "label": "string",
        "parent_id": "string"
      }
    ],
    "cities": [
      {
        "id": 0,
        "city_type": "string",
        "city": "string"
      }
    ],
    "pos": 0,
    "internal_info": {
      "tariff_code": 0,
      "from_city_code": 0,
      "pvz_code": "string",
      "sender_address": "string",
      "company_name": "string",
      "sender_name": "string",
      "sender_email": "string",
      "sender_phone": "string",
      "medium_width": 0,
      "medium_length": 0,
      "medium_height": 0,
      "medium_weight": 0,
      "calculation_type": "string",
      "added_value": 0,
      "need_create_order": true
    }
  }
]
```

{% endtab %}

{% tab title="403 Could not find a cake matching this query." %}

```
{
    "title": "user hasnt access to delivery",
    "error": 24,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/delivery/site/11111"
```

{% endtab %}

{% tab title="PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get(
    '/v1/delivery/site/' . $siteId
);
$statusCode = $response->getStatusCode();
$deliveries = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/delivery/site/" + siteId);
```

{% endtab %}
{% endtabs %}

## Создание доставки

<mark style="color:green;">`POST`</mark> `https://api.lpmotor.ru/v1/delivery`

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

#### Request Body

| Name                               | Type    | Description                                                                                                                                                             |
| ---------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| template\_id                       | integer | ID шаблона доставки. Возможные значения: *1* - универсальный, *2* - самовывоз, *3* - курьером, *4* - курьером с автоматическим подсчетом стоимости, *5* - через ТК CDEK |
| title                              | string  | Название доставки                                                                                                                                                       |
| site\_id                           | integer | ID сайта                                                                                                                                                                |
| price                              | number  | Стоимость доставки. **По умолчанию: 0**                                                                                                                                 |
| free\_start\_from                  | number  | Минимальная стоимость заказа, начиная с которой доставка будет бесплатной. **По умолчанию: 0**                                                                          |
| enabled                            | boolean | Флаг доступности доставки                                                                                                                                               |
| regions                            | array   | Районы доставки. Обязателен для шаблонов *3* и *4*                                                                                                                      |
| regions\[].title                   | string  | Название района доставки                                                                                                                                                |
| regions\[].price                   | number  | Стоимость доставки. **По умолчанию: 0**                                                                                                                                 |
| regions\[].free\_start\_from       | number  | Минимальная стоимость заказа, начиная с которой доставка будет бесплатной. **По умолчанию: 0**                                                                          |
| regions\[].comment                 | string  | Подсказка для доставки. **По умолчанию: null**                                                                                                                          |
| regions\[].enabled                 | boolean | Флаг доступности доставки                                                                                                                                               |
| regions\[].coordinates             | array   | Массив координат точек, определяющих район доставки. **По умолчанию: null**                                                                                             |
| points                             | array   | Точки самовывоза. Обязателен для шаблона *2*                                                                                                                            |
| points\[].title                    | string  | Название точки самовывоза                                                                                                                                               |
| points\[].price                    | number  | Стоимость доставки. **По умолчанию: 0**                                                                                                                                 |
| points\[].free\_start\_from        | number  | Минимальная стоимость заказа, начиная с которой доставка будет бесплатной. **По умолчанию: 0**                                                                          |
| points\[].enabled                  | boolean | Флаг доступности доставки                                                                                                                                               |
| points\[].comment                  | string  | Подсказка для доставки. **По умолчанию: null**                                                                                                                          |
| additional\_fields                 | array   | Дополнительные поля для доставки                                                                                                                                        |
| additional\_fields\[].id           | integer | ID дополнительного поля. Возможные значения: *1* - поле Адрес, *2* - поле с обязательным вводом адреса, *3* - поле Комментарий                                          |
| cities                             | array   | Города, в которых доступна доставка                                                                                                                                     |
| cities\[].id                       | integer | ID города                                                                                                                                                               |
| internal\_info                     | object  | Дополнительные данные для доставки. Обязателен для шаблона *5*                                                                                                          |
| internal\_info.tariff\_code        | integer | Код тарифа в CDEK                                                                                                                                                       |
| internal\_info.from\_city\_code    | integer | Код города, из которого будет осуществлена доставка                                                                                                                     |
| internal\_info.pvz\_code           | string  | Код ПВЗ, на который будет доставлен заказ отправителем                                                                                                                  |
| internal\_info.sender\_address     | string  | Адрес отправителя                                                                                                                                                       |
| internal\_info.company\_name       | string  | Название компании отправителя                                                                                                                                           |
| internal\_info.sender\_name        | string  | Имя отправителя                                                                                                                                                         |
| internal\_info.sender\_email       | string  | Электронный адрес отправителя                                                                                                                                           |
| internal\_info.sender\_phone       | string  | Телефон отправителя                                                                                                                                                     |
| internal\_info.medium\_width       | integer | Средняя ширина товара                                                                                                                                                   |
| internal\_info.medium\_length      | integer | Средняя длина товара                                                                                                                                                    |
| internal\_info.medium\_height      | integer | Средняя высота товара                                                                                                                                                   |
| internal\_info.medium\_weight      | integer | Средний вес товара                                                                                                                                                      |
| internal\_info.calculation\_type   | string  | Тип стоимости доставки. Возможные значения: *CALCULATION* - расчет стоимости через CDEK, *FIX\_PRICE* - фиксированная стоимость доставки                                |
| internal\_info.added\_value        | number  | Добавочная стоимость к текущей стоимости доставки                                                                                                                       |
| internal\_info.need\_create\_order | boolean | Флаг автоматического создания доставки в CDEK                                                                                                                           |

{% tabs %}
{% tab title="201 Для доставок, у которых template\_id от 1 до 4, в ответе будет "internal\_info": null " %}

```
{
  "id": 0,
  "template_id": 0,
  "site_id": 0,
  "title": "string",
  "price": "string",
  "free_start_from": "string",
  "creator_id": 0,
  "d_created": "2021-08-06T11:49:34.828Z",
  "d_updated": "2021-08-06T11:49:34.828Z",
  "enabled": true,
  "deleted": true,
  "points": [
    {
      "id": 0,
      "title": "string",
      "price": "string",
      "free_start_from": "string",
      "country": "string",
      "city": "string",
      "zip": "string",
      "street": "string",
      "building_number": "string",
      "office_number": "string",
      "floor": 0,
      "comment": "string",
      "enabled": true,
      "deleted": true
    }
  ],
  "regions": [
    {
      "id": 0,
      "title": "string",
      "price": "string",
      "free_start_from": "string",
      "comment": "string",
      "enabled": true,
      "deleted": true,
      "coordinates": [[0, 0],[0, 0],[0, 0]]
    }
  ],
  "additional_fields": [
    {
      "id": 0,
      "name": "string",
      "label": "string",
      "parent_id": "string"
    }
  ],
  "cities": [
    {
      "id": 0,
      "city_type": "string",
      "city": "string"
    }
  ],
  "pos": 0,
  "internal_info": {
    "tariff_code": 0,
    "from_city_code": 0,
    "pvz_code": "string",
    "sender_address": "string",
    "company_name": "string",
    "sender_name": "string",
    "sender_email": "string",
    "sender_phone": "string",
    "medium_width": 0,
    "medium_length": 0,
    "medium_height": 0,
    "medium_weight": 0,
    "calculation_type": "string",
    "added_value": 0,
    "need_create_order": true
  }
}
```

{% endtab %}

{% tab title="400 " %}

```
{
    "title": "cant create delivery",
    "error": 26,
    "code": 400
}
```

{% endtab %}

{% tab title="403 " %}

```
{
    "title": "user hasnt access to delivery",
    "error": 24,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X POST "https://api.lpmotor.ru/v1/delivery" \ 
-d '{"template_id":2,"title":"delivery name","site_id":11111,"enabled":true,"regions":[],"points":[{"title":"test point","comment":"this is comment","enabled":true}],"additional_fields":[{"id":1},{"id":2}]}'
```

{% endtab %}

{% tab title="PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->post(
    '/v1/delivery',
    [
        'json' => [
            'template_id' => 2,
            'site_id' => $siteId,
            'title' => 'my delivery',
            'enabled' => true,
            'regions' => [],
            'points' => [
                [
                    'title' => 'test point',
                    'comment' => 'this is comment',
                    'enabled' => true
                ],
            ],
            'additional_fields' => [
                ['id' => 1],
                ['id' => 2],
            ],
        ],
    ]
);
$statusCode = $response->getStatusCode();
$delivery = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.post('/v1/delivery', {
    "template_id": 1,
    "title": "delivery name",
    "site_id": 11111,
    "enabled": true,
    "regions": [],
    "points": [
        {
            "title": "test point",
            "comment": "this is comment",
            "enabled": true
        }
    ],
    "additional_fields": [
        {
            "id": 1
        },
        {
            "id": 2
        }
    ]
});
```

{% endtab %}
{% endtabs %}

## Получение доставки по ID

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/delivery/{delivery_id}`

#### Path Parameters

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| delivery\_id | string | ID доставки |

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

{% tabs %}
{% tab title="200 Для доставок, у которых template\_id от 1 до 4, в ответе будет "internal\_info": null" %}

```
{
  "id": 0,
  "template_id": 0,
  "site_id": 0,
  "title": "string",
  "price": "string",
  "free_start_from": "string",
  "creator_id": 0,
  "d_created": "2021-08-06T13:13:39.239Z",
  "d_updated": "2021-08-06T13:13:39.239Z",
  "enabled": true,
  "deleted": true,
  "points": [
    {
      "id": 0,
      "title": "string",
      "price": "string",
      "free_start_from": "string",
      "country": "string",
      "city": "string",
      "zip": "string",
      "street": "string",
      "building_number": "string",
      "office_number": "string",
      "floor": 0,
      "comment": "string",
      "enabled": true,
      "deleted": true
    }
  ],
  "regions": [
    {
      "id": 0,
      "title": "string",
      "price": "string",
      "free_start_from": "string",
      "comment": "string",
      "enabled": true,
      "deleted": true,
      "coordinates": [[0, 0],[0, 0],[0, 0]]
    }
  ],
  "additional_fields": [
    {
      "id": 0,
      "name": "string",
      "label": "string",
      "parent_id": "string"
    }
  ],
  "cities": [
    {
      "id": 0,
      "city_type": "string",
      "city": "string"
    }
  ],
  "pos": 0,
  "internal_info": {
    "tariff_code": 0,
    "from_city_code": 0,
    "pvz_code": "string",
    "sender_address": "string",
    "company_name": "string",
    "sender_name": "string",
    "sender_email": "string",
    "sender_phone": "string",
    "medium_width": 0,
    "medium_length": 0,
    "medium_height": 0,
    "medium_weight": 0,
    "calculation_type": "string",
    "added_value": 0,
    "need_create_order": true
  }
}
```

{% endtab %}

{% tab title="403 " %}

```
{
    "title": "user hasnt access to delivery",
    "error": 24,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/delivery/1" 
```

{% endtab %}

{% tab title="PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get(
    '/v1/delivery/' . $deliveryId
);
$statusCode = $response->getStatusCode();
$delivery = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/delivery/" + deliveryId);
```

{% endtab %}
{% endtabs %}

## Изменение доставки

<mark style="color:orange;">`PUT`</mark> `https://api.lpmotor.ru/v1/delivery`

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

#### Request Body

| Name                               | Type    | Description                                                                                                                              |
| ---------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| id                                 | integer | ID доставки                                                                                                                              |
| title                              | string  | Название доставки                                                                                                                        |
| price                              | number  | Стоимость доставки. **По умолчанию: 0**                                                                                                  |
| free\_start\_from                  | number  | Минимальная стоимость заказа, начиная с которой доставка будет бесплатной. **По умолчанию: 0**                                           |
| enabled                            | boolean | Флаг доступности доставки                                                                                                                |
| pos                                | integer | Позиция доставки в списке                                                                                                                |
| regions                            | array   | Районы доставки. Обязателен для шаблонов *3* и *4*                                                                                       |
| regions\[].id                      | integer | ID района доставки                                                                                                                       |
| regions\[].title                   | string  | Название района доставки                                                                                                                 |
| regions\[].price                   | number  | Стоимость доставки. **По умолчанию: 0**                                                                                                  |
| regions\[].free\_start\_from       | number  | Минимальная стоимость доставки, начиная с которой доставка будет бесплатной. **По умолчанию: 0**                                         |
| regions\[].comment                 | string  | Подсказка для доставки. **По умолчанию: null**                                                                                           |
| regions\[].enabled                 | boolean | Флаг доступности района доставки                                                                                                         |
| regions\[].coordinates             | array   | Массив координат точек, определяющих район доставки. **По умолчанию: null**                                                              |
| points                             | array   | Точки самовывоза. Обязателен для шаблона *2*                                                                                             |
| points\[].id                       | integer | ID точки самовывоза                                                                                                                      |
| points\[].title                    | string  | Название точки самовывоза                                                                                                                |
| points\[].price                    | number  | Стоимость доставки. **По умолчанию: 0**                                                                                                  |
| points\[].free\_start\_from        | number  | Минимальная стоимость заказа, начиная с которой доставка будет бесплатной. **По умолчанию: 0**                                           |
| points\[].enabled                  | boolean | Флаг доступности доставки                                                                                                                |
| points\[].comment                  | string  | Подсказка для доставки. **По умолчанию: null**                                                                                           |
| additional\_fields                 | array   | Дополнительные поля для доставки                                                                                                         |
| additional\_fields\[].id           | integer | ID дополнительного поля. Возможные значения: *1* - поле Адрес, *2* - поле с обязательным вводом адреса, *3* - поле Комментарий           |
| cities                             | array   | Города, в которых доступна доставка                                                                                                      |
| cities\[].id                       | integer | ID города                                                                                                                                |
| internal\_info                     | object  | Дополнительные данные для доставки. Обязателен для шаблона *5*                                                                           |
| internal\_info.tariff\_code        | integer | Код тарифа в CDEK                                                                                                                        |
| internal\_info.from\_city\_code    | integer | Код города, из которого будет осуществлена доставка                                                                                      |
| internal\_info.pvz\_code           | string  | Код ПВЗ, в который будет доставлен заказ отправителем                                                                                    |
| internal\_info.sender\_address     | string  | Адрес отправителя                                                                                                                        |
| internal\_info.company\_name       | string  | Название компании отправителя                                                                                                            |
| internal\_info.sender\_name        | string  | Имя отправителя                                                                                                                          |
| internal\_info.sender\_email       | string  | Электронный адрес отправителя                                                                                                            |
| internal\_info.sender\_phone       | string  | Телефон отправителя                                                                                                                      |
| internal\_info.medium\_width       | integer | Средняя ширина товара                                                                                                                    |
| internal\_info.medium\_length      | integer | Средняя длина товара                                                                                                                     |
| internal\_info.medium\_height      | integer | Средняя высота товара                                                                                                                    |
| internal\_info.medium\_weight      | integer | Средний вес товара                                                                                                                       |
| internal\_info.calculation\_type   | string  | Тип стоимости доставки. Возможные значения: *CALCULATION* - расчет стоимости через CDEK, *FIX\_PRICE* - фиксированная стоимость доставки |
| internal\_info.added\_value        | number  | Добавочная стоимость к текущей стоимости доставки                                                                                        |
| internal\_info.need\_create\_order | boolean | Флаг автоматического создания доставки в CDEK                                                                                            |

{% tabs %}
{% tab title="201 Для доставок, у которых template\_id от 1 до 4, в ответе будет "internal\_info": null " %}

```
{
  "id": 0,
  "title": "string",
  "price": 0,
  "free_start_from": 0,
  "enabled": true,
  "pos": 0,
  "regions": [
    {
      "id": 0,
      "title": "string",
      "price": 0,
      "free_start_from": 0,
      "comment": "string",
      "enabled": true,
      "coordinates": [
        [
          0, 0
        ]
      ]
    }
  ],
  "points": [
    {
      "id": 0,
      "title": "string",
      "price": 0,
      "free_start_from": 0,
      "country": "string",
      "city": "string",
      "zip": "string",
      "street": "string",
      "building_number": "string",
      "office_number": "string",
      "floor": 0,
      "comment": "string",
      "enabled": true
    }
  ],
  "additional_fields": [
    {
      "id": 0
    }
  ],
  "cities": [
    {
      "id": 0
    }
  ],
  "internal_info": {
    "tariff_code": 0,
    "from_city_code": 0,
    "pvz_code": "string",
    "sender_address": "string",
    "company_name": "string",
    "sender_name": "string",
    "sender_email": "string",
    "sender_phone": "string",
    "medium_width": 0,
    "medium_length": 0,
    "medium_height": 0,
    "medium_weight": 0,
    "calculation_type": "string",
    "added_value": 0,
    "need_create_order": true
  }
}
```

{% endtab %}

{% tab title="403 " %}

```
{
    "title": "user hasnt access to delivery",
    "error": 24,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X PUT "https://api.lpmotor.ru/v1/delivery" \ 
-d '{"id":1,"title":"new delivery name","enabled":false,"pos":1,"points":[],"regions":[{"id":1,"title":"new region name","enabled":true}]}'
```

{% endtab %}

{% tab title="PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->put(
    '/v1/delivery',
    [
        'json' => [
            'id' => 1,
            'title' => 'my delivery',
            'enabled' => true,
            'pos' => 1,
            'regions' => [
                [
                    'id' => 1,
                    'title' => 'test point',
                    'comment' => 'this is comment',
                    'enabled' => true
                ],
            ],
        ],
    ]
);
$statusCode = $response->getStatusCode();
$delivery = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.put('/v1/delivery', {
    "id": 1,
    "title": "delivery name",
    "pos": 1,
    "enabled": true,
    "regions": [
        {
            "id": 1,
            "title": "test point",
            "comment": "this is comment",
            "enabled": true
        }
    ],
});
```

{% endtab %}
{% endtabs %}

## Удаление доставки

<mark style="color:red;">`DELETE`</mark> `https://api.lpmotor.ru/v1/delivery/{delivery_id}`

#### Path Parameters

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| delivery\_id | string | ID доставки |

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

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

```
```

{% endtab %}

{% tab title="403 " %}

```
{
    "title": "user hasnt access to delivery",
    "error": 24,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X DELETE "https://api.lpmotor.ru/v1/delivery/1" 
```

{% endtab %}

{% tab title="PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->delete(
    '/v1/delivery/1'
);
$statusCode = $response->getStatusCode();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.delete("/v1/delivery/1");
```

{% endtab %}
{% endtabs %}


# Промокоды

Получение списка промокодов. Создание, изменение или удаление промокодов. Всё покажем с примерами на нашем сайте

## Работа с промокодами

## Получение списка промокодов

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/promo`

This endpoint allows you to get free cakes.

#### Query Parameters

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| site\_id | string | ID сайта    |

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
[
  {
    "id": 0,
    "code": "string",
    "pos": 0,
    "is_enabled": true,
    "bonus_type": 0,
    "bonus_amount": 0,
    "bonus_amount_is_in_percentages": true,
    "time_limit_is_enabled": true,
    "d_on": "2021-08-04T13:57:37.243Z",
    "d_off": "2021-08-04T13:57:37.243Z",
    "quantity_limit_is_enabled": true,
    "quantity_limit": 0,
    "promo_used_count": 0,
    "is_valid": true
  }
]
```

{% endtab %}

{% tab title="403 Could not find a cake matching this query." %}

```
{
    "title": "user cant view site",
    "error": 30,
    "code": 403
}Пример запроса
 curl -X GET "Пример запроса
 curl -X GET "
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/promo?site_id=11111" 
```

{% endtab %}

{% tab title="PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get(
    '/v1/promo',
    [
        'query' => [
            'site_id' => $siteId,
        ]
    ]
);
$statusCode = $response->getStatusCode();
$promoCodes = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/promo", {
    params: {
        site_id: 11111,
    },
});
```

{% endtab %}
{% endtabs %}

## Создание промокода

<mark style="color:green;">`POST`</mark> `https://api.lpmotor.ru/v1/promo`

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

#### Request Body

| Name                               | Type    | Description                                                                                                                            |
| ---------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| site\_id                           | integer | ID сайта                                                                                                                               |
| code                               | string  | Код длиной от 2 до 15 символов. Может состоять только из букв латинского алфавита и цифр                                               |
| is\_enabled                        | boolean | Флаг действия промокода. **По умолчанию: false**                                                                                       |
| bonus\_type                        | integer | Тип действия промокода. Поддерживаемые значения: *2* - на стоимость основных товаров, *3* - на стоимость доставки. **По умолчанию: 2** |
| bonus\_amount                      | number  | Сумма скидки. **По умолчанию: 0.01**                                                                                                   |
| bonus\_amount\_is\_in\_percentages | boolean | Тип скидки. *true* - в процентах, *false* - фиксированная. **По умолчанию: false**                                                     |
| time\_limit\_is\_enabled           | boolean | Флаг ограничения срока действия промокода. **По умолчанию: false**                                                                     |
| d\_on                              | string  | Дата начала действия промокода. **По умолчанию: null**                                                                                 |
| d\_off                             | string  | Дата окончания действия промокода. **По умолчанию: null**                                                                              |
| quantity\_limit\_is\_enabled       | boolean | Флаг ограничения количества использований промокода. **По умолчанию: false**                                                           |
| quantity\_limit                    | integer | Количество использований промокода. **По умолчанию: 0**                                                                                |
| personal\_limit\_is\_enabled       | boolean | Флаг повторного использования промокода одним пользователем. **По умолчанию: false**                                                   |

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

```
{
  "code": "string",
  "is_enabled": true,
  "bonus_type": 0,
  "bonus_amount": 0,
  "bonus_amount_is_in_percentages": true,
  "time_limit_is_enabled": true,
  "d_on": "2021-08-04T14:36:22.614Z",
  "d_off": "2021-08-04T14:36:22.614Z",
  "quantity_limit_is_enabled": true,
  "quantity_limit": 0,
  "personal_limit_is_enabled": true
}
```

{% endtab %}

{% tab title="403 " %}

```
{
    "title": "user cant view site",
    "error": 30,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X POST "https://api.lpmotor.ru/v1/promo" \ 
-d '{"user_id":123,"site_id":11111,"code":"mypromocode"}'
```

{% endtab %}

{% tab title="PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->post(
    '/v1/promo',
    [
        'json' => [
            'user_id' => $userId,
            'site_id' => $siteId,
            'code' => 'mypromocode',
        ],
    ]
);
$statusCode = $response->getStatusCode();
$promoCode = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.post('/v1/promo', {
    user_id: 123,
    site_id: 11111,
    code: 'mypromocode',
});
```

{% endtab %}
{% endtabs %}

## Получение промокода по ID

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/promo/{promo_id}`

#### Path Parameters

| Name      | Type   | Description  |
| --------- | ------ | ------------ |
| promo\_id | string | ID промокода |

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

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

```
{
  "code": "string",
  "is_enabled": true,
  "bonus_type": 0,
  "bonus_amount": 0,
  "bonus_amount_is_in_percentages": true,
  "time_limit_is_enabled": true,
  "d_on": "2021-08-04T14:39:18.248Z",
  "d_off": "2021-08-04T14:39:18.248Z",
  "quantity_limit_is_enabled": true,
  "quantity_limit": 0,
  "personal_limit_is_enabled": true
}
```

{% endtab %}

{% tab title="403 " %}

```
{
    "title": "user cant view promo",
    "error": 40,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/promo/1" 
```

{% endtab %}

{% tab title="PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get(
    '/v1/promo/' . $promoId
);
$statusCode = $response->getStatusCode();
$promoCode = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/promo/" + promoId);
```

{% endtab %}
{% endtabs %}

## Изменение промокода

<mark style="color:orange;">`PUT`</mark> `https://api.lpmotor.ru/v1/promo/{promo_id}`

#### Path Parameters

| Name      | Type   | Description  |
| --------- | ------ | ------------ |
| promo\_id | string | ID промокода |

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

#### Request Body

| Name                               | Type    | Description                                                                                                                            |
| ---------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| code                               | string  | Код длиной от 2 до 15 символов. Может состоять только из символов латиницы и цифр                                                      |
| is\_enabled                        | boolean | Флаг действия промокода. **По умолчанию: false**                                                                                       |
| bonus\_type                        | integer | Тип действия промокода. Поддерживаемые значения: *2* - на стоимость основных товаров, *3* - на стоимость доставки. **По умолчанию: 2** |
| bonus\_amount                      | number  | Сумма скидки. **По умолчанию: 0.01**                                                                                                   |
| bonus\_amount\_is\_in\_percentages | boolean | Тип скидки. *true* - в процентах, *false* - фиксированная. **По умолчанию: false**                                                     |
| time\_limit\_is\_enabled           | boolean | Флаг ограничения срока действия промокода. **По умолчанию: false**                                                                     |
| d\_on                              | string  | Дата начала действия промокода. **По умолчанию: null**                                                                                 |
| d\_off                             | string  | Дата окончания действия промокода. **По умолчанию: null**                                                                              |
| quantity\_limit\_is\_enabled       | boolean | Флаг ограничения количества использований промокода. **По умолчанию: false**                                                           |
| quantity\_limit                    | integer | Количество использований промокода. **По умолчанию: 0**                                                                                |
| personal\_limit\_is\_enabled       | boolean | Флаг повторного использования промокода одним пользователем. **По умолчанию: false**                                                   |

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

```
{
  "code": "string",
  "is_enabled": true,
  "bonus_type": 0,
  "bonus_amount": 0,
  "bonus_amount_is_in_percentages": true,
  "time_limit_is_enabled": true,
  "d_on": "2021-08-04T14:43:46.897Z",
  "d_off": "2021-08-04T14:43:46.897Z",
  "quantity_limit_is_enabled": true,
  "quantity_limit": 0,
  "personal_limit_is_enabled": true
}
```

{% endtab %}

{% tab title="403 " %}

```
{
    "title": "user cant view promo",
    "error": 40,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X PUT "https://api.lpmotor.ru/v1/promo/1" \ 
-d '{"code":"newpromocode"}'
```

{% endtab %}

{% tab title="PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->put(
    '/v1/promo/1',
    [
        'json' => [
            'code' => 'newpromocode',
        ],
    ]
);
$statusCode = $response->getStatusCode();
$promoCode = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.post('/v1/promo/1', {
    code: 'newpromocode',
});
```

{% endtab %}
{% endtabs %}

## Удаление промокода

<mark style="color:red;">`DELETE`</mark> `https://api.lpmotor.ru/v1/promo/{promo_id}`

#### Path Parameters

| Name      | Type   | Description  |
| --------- | ------ | ------------ |
| promo\_id | string | ID промокода |

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

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

```
```

{% endtab %}

{% tab title="403 " %}

```
{
    "title": "user cant view promo",
    "error": 40,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X DELETE "https://api.lpmotor.ru/v1/promo/1" 
```

{% endtab %}

{% tab title="PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->delete(
    '/v1/promo/1'
);
$statusCode = $response->getStatusCode();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.delete("/v1/promo/1");
```

{% endtab %}
{% endtabs %}

## Получение статистики использования промокода

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/promo/{promo_id}/statistics`

#### Path Parameters

| Name      | Type   | Description  |
| --------- | ------ | ------------ |
| promo\_id | string | ID промокода |

#### Headers

| Name          | Type   | Description     |
| ------------- | ------ | --------------- |
| X-Api-User-Id | string | ID пользователя |
| Authorization | string | API-токен       |

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

```
[
  {
    "id": 0,
    "promo_id": 0,
    "lead_id": 0,
    "bonus_type_id": 0,
    "bonus_amount": 0,
    "bonus_amount_is_in_percentages": 0,
    "order_price": 0,
    "order_quantity": 0,
    "discount_amount": 0,
    "promo": {
      "code": "string"
    },
    "d_lead_created": "2021-08-04T15:02:13.184Z",
    "currency": "string"
  }
]
```

{% endtab %}

{% tab title="403 " %}

```
{
    "title": "user cant view site",
    "error": 30,
    "code": 403
}
```

{% endtab %}
{% endtabs %}

#### Пример запроса

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

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/promo/1/statistics"
```

{% endtab %}

{% tab title=" PHP CURL" %}

```
```

{% endtab %}

{% tab title="PHP Guzzle" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get(
    '/v1/promo/1/statistics'
);
$statusCode = $response->getStatusCode();
$statistics = json_decode((string) $response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 60000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/promo/1/statistics");
```

{% endtab %}
{% endtabs %}


# Ошибки

Определение формат ошибок и описание в случае возникновения ошибок API

В случае возникновения ошибок API в ответ придет сообщение в формате:

```javascript
{
  "title": "Description is here",
  "error": 0,
  "code": 404
}
```

| Параметр | Описание                      |
| -------- | ----------------------------- |
| title    | Краткое описание ошибки       |
| error    | Номер ошибки в системе Mottor |
| code     | Статус код http               |

### Список ошибок

| Номер | Статус код | Описание                                        |
| ----- | ---------- | ----------------------------------------------- |
| 0     | 500        | unknown error                                   |
| 1     | 403        | user hasn't any enabled tariff                  |
| 2     | 403        | site limit is exceeded                          |
| 3     | 403        | domain limit is exceeded                        |
| 4     | 403        | page limit is exceeded                          |
| 8     | 403        | user can't access to edit this site             |
| 10    | 400        | file or data is invalid                         |
| 12    | 404        | domain not found                                |
| 13    | 409        | domain already exists                           |
| 15    | 403        | current user doesn't have access for edit page  |
| 16    | 400        | site is not published                           |
| 17    | 404        | can't find user                                 |
| 18    | 402        | user need pay for certificate                   |
| 19    | 400        | can't create certificate                        |
| 20    | 404        | can't find certificate                          |
| 21    | 404        | domain has not relation with site               |
| 23    | 404        | can't find delivery                             |
| 24    | 403        | user hasn't access to delivery                  |
| 25    | 404        | can't find delivery template                    |
| 26    | 400        | can't create delivery                           |
| 27    | 400        | can't create self tmp access                    |
| 28    | 403        | user hasn't access to page                      |
| 29    | 404        | page not found                                  |
| 30    | 403        | user can't view site                            |
| 31    | 403        | current user is not support                     |
| 32    | 404        | site not found                                  |
| 33    | 404        | site project not found                          |
| 34    | 403        | user is not owner of site                       |
| 37    | 409        | promo already redeemed                          |
| 38    | 404        | lead not found                                  |
| 39    | 409        | promo already exists                            |
| 40    | 403        | user can't view promo                           |
| 41    | 404        | promo not found                                 |
| 42    | 403        | domain not found by certificate id              |
| 43    | 401        | auth token is wrong                             |
| 44    | 401        | auth token not sent                             |
| 46    | 400        | json body is wrong                              |
| 48    | 429        | wrong lead id                                   |
| 49    | 404        | redeemed promo not found                        |
| 50    | 404        | invoice not found                               |
| 51    | 404        | currency not found                              |
| 52    | 404        | site module not found                           |
| 53    | 404        | module not found                                |
| 54    | 404        | cart pay variant not found                      |
| 55    | 400        | delivery is not valid                           |
| 56    | 404        | delivery region not found                       |
| 57    | 400        | invalid delivery address                        |
| 58    | 400        | attached domain is invalid                      |
| 59    | 409        | domain in use                                   |
| 60    | 400        | can't create domain cause is not on our servers |
| 61    | 400        | can't create domain cause site is not attached  |
| 62    | 409        | site has custom domain                          |
| 63    | 400        | domain is not on this site                      |
| 64    | 404        | shop category not found                         |
| 65    | 400        | can't read favicon                              |
| 66    | 400        | wrong favicon mime type                         |
| 67    | 400        | wrong favicon extension                         |
| 69    | 400        | can't read manifest icon                        |
| 70    | 404        | manifest not found                              |
| 71    | 429        | api request limit exceeds                       |
| 72    | 400        | can't create user                               |
| 75    | 429        | wrong cart id                                   |
| 76    | 404        | cart not found                                  |
| 77    | 404        | param group not found                           |
| 78    | 409        | param duplicate                                 |
| 79    | 400        | invalid file                                    |
| 83    | 404        | param value not found                           |
| 6638  | 400        | wrong temp access id or sign or limit           |
| 6639  | 400        | wrong client id in db                           |
| 85    | 400        | wrong cdek tariff code                          |
| 7852  | 400        | can't delete pay variant                        |
| 7854  | 409        | demo mode already enabled                       |
| 7855  | 409        | demo mode already disabled                      |
| 86    | 403        | cdek authorization error                        |
| 7846  | 400        | cdek bad request                                |
| 7826  | 400        | can't attach tariff. user already has tariff    |
| 7835  | 400        | can't find price for current tariff and period  |
| 7837  | 400        | insufficient balance                            |
| 7843  | 404        | tariff not found                                |
| 7857  | 400        | delivery internal info not found                |
| 7860  | 404        | lead extra not found                            |
| 7861  | 404        | personal data not found                         |
| 7862  | 400        | don't need create order in CDEK                 |
| 7884  | 404        | product variant not found                       |
| 7885  | 403        | product variant does not belong to the site     |
| 7902  | 404        | param not found                                 |
| 7909  | 404        | page folder not found                           |


# 20.11.2025

Изменения от 20.11.2025г.

## Новая версия методов в разделе "Сайты".

Добавили новые методы:

* список доступных сайтов `GET /v3/public/site`
* подробная информация о сайте `GET /v3/public/site/{site_id}` &#x20;

Методы `GET /v1/site` и `GET /v1/site/{site_id}` объявляются устаревшим. В новых релизах они будут удалены.


# 25.11.2025

Изменения от 25.11.2025г.

## Новая версия методов в разделе "Сайты".

Добавили новые методы:

* список доступных страниц сайта `GET /v3/public/site/{site_id}/page`
* подробная информация о странице `GET /v3/public/site/page/{page_id}` &#x20;

Метод `/v1/site/{site_id}/page` объявляется устаревшим. В новых релизах он будет удалён.


