Basic Script for Creating a Lead
Purpose: This instruction is intended for third-party developers integrating with "Brainysoft". After reading this article, a developer should be able to write code that creates a lead by passing only 2 values (Name and phone number). At the end of the article, there is a code example that should also help achieve the desired result.
This business scenario should be used when:
- there is very little information about a potential customer (lead)
- it is very difficult to obtain information about a potential customer (lead)
- you need to enter at least some information about a potential customer (lead) into the system for further work with them
In such cases, the most ideal and effective way is to use the lead creation described in this article.
Expected result: A lead object in the system.
In the interface, the result may look as follows:

Business scenario description in BPMN: this scenario is displayed under number 1

Method Signature
General description of working with the core web service method is described in the article "Nuances When Working with API" in the "Method" section.
POST /main/leadsPath parameters: none Query parameters: none
Request Body
The request body contains an object with the following structure:
| Property | Required | Data Type | Description |
| firstName | M | string[50] | First name. If you pass the full name, it will be saved. In this case, problems may occur later if the last name and patronymic are added. |
| mobilePhone | M | string[50] | Mobile phone number. Only digits are specified in international format. For example, for possible display in the interface as +7 (977) 620 07 77, you should pass 797762007777. |
Errors:
- NO_CLIENT_FIRST_NAME_ERROR - client first name not specified
- NO_MOBILE_PHONE_ERROR - phone number not specified
Request example:
POST /main/leads/{
"firstName": "Фридрих",
"mobilePhone": "797762007777"
}Method call result:
General description of the returned object structure is described in the article "Nuances When Working with API" in the "Method" section.
| Property | Description |
| data | Identifier of the created lead. |
Response example:
{
"status": "ok",
"timestamp": 1550653059521,
"data": 3692
}Code examples:
$requestBody = '{
"firstName":"Фридрих",
"mobilePhone":"797762007719"
}';
curl_setopt_array($curl_newLead, array(
CURLOPT_PORT => "443",
CURLOPT_URL => "https://{customer}-saas.brainysoft.ru:9025/bs-core/main/leads/",
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $requestBody
));PHP code example can be viewed and copied here.