addLeads method¶
Uploads information about new deals. The response returns an array of IDs of the saved deals and/or an array of IDs of the deals that were not uploaded, with a description of the reason. Method: POST Format: JSON URL: https://api.r7k12.com/{{TOKEN}}/addLeads Parameters: Table 1 Content-type: application/json Table 1
| Name | Value | Required | Description |
| id | string | Yes | Unique deal ID in the CRM system |
| name | string | No | Deal name in the CRM system (no more than 500 characters). |
| dateCreate | unix time | Yes | Deal creation date in UNIX format |
| status | string | Yes | ID of the deal status in the CRM system. To process deals correctly, upload the statuses using the setStatuses method |
| dateChangeStatus | string | No | Status change date in Y-m-d format |
| type | string | No | Inquiry type (Form/Ringostat/Tilda, etc.) |
| r7k12id | string | No | Unique R7K12 visit ID (or visit source) |
| price | float | No | Deal amount |
| cost | float | No | Deal cost of goods |
| clientId | string | No | Client ID in the CRM |
| manager | string | No | ID of the manager responsible for the deal |
| shop | string | No | Store the deal belongs to |
| appealUrl | string | No | Full URL of the page from which the order was placed. Example: https://magazine.com/page1/product5/?c=1#block=1 |
| appeals | integer | No | Number of inquiries for the deal |
| appealId | string | No | Inquiry ID obtained with the getAppeals method |
| number | integer | No | Sequence number of the deal for the contact |
| products | array[object] | No | Array of products related to the deal (described in Table 2). |
| payment | array[object] | No | Payments for the deal (described in Table 3) |
| fields | object | No | Additional deal fields |
Table 2
| Name | Value | Required | Description |
| id | string | Yes | Unique product ID |
| name | string | Yes | Product name |
| price | float | Yes | Price per product unit |
| quantity | integer | Yes | Quantity |
Table 3
| Name | Value | Required | Description |
| id | string | Yes | Unique payment ID |
| sum | float | Yes | Payment amount |
| status | integer | Yes | Payment status (1 - payment completed, -1 - payment canceled) |
| date | string | Yes | Payment date. Format YYYY-MM-DD |
Request body example:¶
[
{
"id":"1",
"name":"Сделка №1",
"dateCreate": 1508746231,
"status":"57667454",
"dateChangeStatus":"2017-10-21",
"type":"Form",
"r7k12id": "14154465",
"price":80.6,
"cost":70,
"clientId":"876",
"manager": 5,
"products": [
{
"id": "1",
"name": "Продукт 1",
"price": 0,
"quantity": 1
},
{
"id": "2",
"name": "Продукт 2",
"price": 124.6,
"quantity": 2
}
],
"payment": [
{
"id": "6458erg",
"sum": 50,
"status": 1,
"date": "2018-04-16"
},
{
"id": "jf94ksm",
"sum": 100,
"status": 1,
"date": "2018-04-20"
}
],
"fields": {
"1": "fields 1",
"45": "fields 3"
}
},
{
"id":"2",
"name":"Сделка №2",
"dateCreate": 1508746531,
"status":"7454",
"r7k12id": "site_offline"
},
{
"id":"3",
"name":"Сделка №3",
"dateCreate": 1509746531,
"status":"744"
}
]
Response example:
{
"upload" : [1,2,3],
"notUpload" : [
{
"id" : 4,
"message" : "Не указан параметр 'dateСreate'"
},
{
"id" : 5,
"message" : "Сделка с указанным идентификатором уже существует"
},
{
"id" : 6,
"message" : "Не удалось загрузить сделку. Указана некорректная дата создания сделки"
}
]
}
Script example (PHP):
define('TOKEN','XXXXXXXXX');
@file_get_contents(
'https://api.r7k12.com/'.TOKEN.'/addLeads',
0,
stream_context_create(
[
'http' => [
'method' => "POST",
'header' => "Content-Type: application/json\r\n",
'content' => json_encode(
[
[
'id' => '1',
'name' => 'Сделка №1',
'dateCreate' => 1508746231,
'status' => '57667454',
'type' => 'Form',
'r7k12id' => '14154465',
'price' => 80.6,
'cost' => 70,
'clientId' => '876',
'manager' => '5',
'shop' => 'магазин',
'products' => [
[
'id' => '1',
'name' => 'Продукт 1',
'price' => 0,
'quantity' => 1
],
[
'id' => '2',
'name' => 'Продукт 2',
'price' => 124.6,
'quantity' => 2
]
],
'fields' => [
'1' => 'fields 1',
'45' => 'fields 3'
]
],
[
'id' => '2',
'name' => 'Сделка №2',
'dateCreate' => 1508746531,
'status' => '7454',
'r7k12id' => 'site_offline',
],
[
'id' => '3',
'name' => 'Сделка №3',
'dateCreate' => 1509746531,
'status' => '744',
]
]
)
]
]
)
);