Create a new contact crm.contact.add
Scope:
crmWho can execute the method: any user with "add|import" access permission for contacts
Method Development Stopped
The method crm.contact.add continues to function, but there is a more relevant alternative crm.item.add.
The method crm.contact.add creates a new contact.
Method Parameters
|
Name |
Description |
|
fields |
Object format:
where:
The list of available fields is described below. An incorrect field in |
|
params |
Object containing a set of additional parameters. The structure and possible values are described below |
Parameter fields
|
Name |
Description |
|
HONORIFIC |
Salutation. The list of available salutation types can be obtained using the method Default — the first available salutation type |
|
NAME |
First name |
|
SECOND_NAME |
Middle name |
|
LAST_NAME |
Last name |
|
PHOTO |
Photo |
|
BIRTHDATE |
Date of birth |
|
TYPE_ID |
Contact type. The list of available contact types can be obtained using the method Default — the first available contact type |
|
SOURCE_ID |
Source. The list of available source types can be obtained using the method Default — the first available source type |
|
SOURCE_DESCRIPTION |
Additional information about the source |
|
POST |
Position |
|
COMMENTS |
Comment. Supports BB codes |
|
OPENED |
Is it available to everyone? Possible values:
Default |
|
EXPORT |
Is the contact included in the export? Possible values:
Default |
|
ASSIGNED_BY_ID |
Identifier of the user responsible for the element. Default — the identifier of the user calling the method |
|
COMPANY_ID |
Identifier of the main company for the contact. The list of companies can be obtained using the method |
|
COMPANY_IDS |
Array of identifiers of companies to which the contact is linked. The list of companies can be obtained using the method |
|
UTM_SOURCE |
Advertising system (Google Ads, etc.) |
|
UTM_MEDIUM |
Traffic type. Possible values:
|
|
UTM_CAMPAIGN |
Advertising campaign designation |
|
UTM_CONTENT |
Campaign content. For example, for contextual ads |
|
UTM_TERM |
Campaign search condition. For example, keywords for contextual advertising |
|
TRACE |
Information for Sales Intelligence |
|
PHONE |
Phone |
|
EMAIL |
|
|
WEB |
Website |
|
Messenger |
|
|
LINK |
Links. Service field |
|
UF_... |
Custom fields. For example, Depending on the account settings, contacts may have a set of custom fields of specific types. You can add a custom field to a contact using the method crm.contact.userfield.add |
|
PARENT_ID_... |
Relationship fields. If there are SPAs related to contacts in the account, there is a field for each such SPA that stores the relationship between that SPA and the contact. The field itself stores the identifier of the element of that SPA. For example, the field |
Fields for linking with external data sources
If the contact is created by an external system, then:
- the field
ORIGINATOR_IDstores the string identifier of that system - the field
ORIGIN_IDstores the string identifier of the contact in that external system - the field
ORIGIN_VERSIONstores the version of the contact data in that external system
|
Name |
Description |
|
ORIGINATOR_ID |
Identifier of the external system that is the source of data about this contact |
|
ORIGIN_ID |
Version of the contact data in the external system. Used to protect data from accidental overwriting by the external system. If the data was imported and not changed in the external system, such data can be edited in CRM without fear that the next export will overwrite the data |
|
ORIGIN_VERSION |
Original version |
Import
The fields are available for filling when the parameter IMPORT = 'Y' is passed in the params parameter.
|
Name |
Description |
|
DATE_CREATE |
Creation date. Available when Cannot be earlier than the creation date of the last created contact |
|
DATE_MODIFY |
Modification date. Available when |
|
CREATED_BY_ID |
Created by. Available when |
|
MODIFY_BY_ID |
Modified by. Available when |
Deprecated fields
Address fields in the contact are deprecated and are only used in compatibility mode. To work with the address, use requisites.
|
Name |
Description |
|
ADDRESS |
Address |
|
ADDRESS_2 |
Second line of the address |
|
ADDRESS_CITY |
City |
|
ADDRESS_POSTAL_CODE |
Postal code |
|
ADDRESS_REGION |
Region |
|
ADDRESS_PROVINCE |
Province |
|
ADDRESS_COUNTRY |
Country |
|
ADDRESS_COUNTRY_CODE |
Country code |
|
ADDRESS_LOC_ADDR_ID |
Location address identifier |
Parameter params
|
Name |
Description |
|
REGISTER_SONET_EVENT |
Should the event of adding a contact be registered in the live feed? Possible values:
Default |
|
IMPORT |
Is import mode enabled? Possible values:
To pass the value Default |
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"FIELDS":{"HONORIFIC":"HNR_RU_1","NAME":"John","SECOND_NAME":"Nicholas","LAST_NAME":"Mitchell","PHOTO":{"fileData":"**put_photo_data_here**"},"BIRTHDATE":"11.11.2001","TYPE_ID":"PARTNER","SOURCE_ID":"WEB","SOURCE_DESCRIPTION":"*Additional information about the source*","POST":"Administrator","COMMENTS":"**put_comment_here**","OPENED":"Y","EXPORT":"N","ASSIGNED_BY_ID":6,"COMPANY_ID":12,"COMPANY_IDS":[12,13,15],"UTM_SOURCE":"google","UTM_MEDIUM":"CPC","UTM_CAMPAIGN":"summer_sale","UTM_CONTENT":"header_banner","UTM_TERM":"discount","PHONE":[{"VALUE":"+12333333555","VALUE_TYPE":"WORK"},{"VALUE":"+15599888666","VALUE_TYPE":"HOME"}],"EMAIL":[{"VALUE":"mitchell@example.mailing","VALUE_TYPE":"MAILING"},{"VALUE":"mitchell@example.work","VALUE_TYPE":"WORK"}],"UF_CRM_1720697698689":"Example value of a custom field with type \"String\"","PARENT_ID_1224":12}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.contact.add
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"FIELDS":{"HONORIFIC":"HNR_RU_1","NAME":"John","SECOND_NAME":"Nicholas","LAST_NAME":"mitchell","PHOTO":{"fileData":"**put_photo_data_here**"},"BIRTHDATE":"11.11.2001","TYPE_ID":"PARTNER","SOURCE_ID":"WEB","SOURCE_DESCRIPTION":"*Additional information about the source*","POST":"Administrator","COMMENTS":"**put_comment_here**","OPENED":"Y","EXPORT":"N","ASSIGNED_BY_ID":6,"COMPANY_ID":12,"COMPANY_IDS":[12,13,15],"UTM_SOURCE":"google","UTM_MEDIUM":"CPC","UTM_CAMPAIGN":"summer_sale","UTM_CONTENT":"header_banner","UTM_TERM":"discount","PHONE":[{"VALUE":"+12333333555","VALUE_TYPE":"WORK"},{"VALUE":"+15599888666","VALUE_TYPE":"HOME"}],"EMAIL":[{"VALUE":"mitchell@example.mailing","VALUE_TYPE":"MAILING"},{"VALUE":"mitchell@example.work","VALUE_TYPE":"WORK"}],"UF_CRM_1720697698689":"Example value of a custom field with type \"String\"","PARENT_ID_1224":12},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/crm.contact.add
try
{
const response = await $b24.callMethod(
'crm.contact.add',
{
fields: {
HONORIFIC: "HNR_RU_1",
NAME: "John",
SECOND_NAME: "Nicholas",
LAST_NAME: "Mitchell",
PHOTO: {
fileData: document.getElementById('photo'),
},
BIRTHDATE: '11.11.2001',
TYPE_ID: "PARTNER",
SOURCE_ID: "WEB",
SOURCE_DESCRIPTION: "*Additional information about the source*",
POST: "Administrator",
COMMENTS: `
Example comment inside the contact
[B]Bold text[/B]
[I]Italic[/I]
[U]Underlined[/U]
[S]Strikethrough[/S]
[B][I][U][S]Mix[/S][/U][/I][/B]
[LIST]
[*]List item #1
[*]List item #2
[*]List item #3
[/LIST]
[LIST=1]
[*]Numbered list item #1
[*]Numbered list item #2
[*]Numbered list item #3
[/LIST]
`,
OPENED: "Y",
EXPORT: "N",
ASSIGNED_BY_ID: 6,
COMPANY_ID: 12,
COMPANY_IDS: [12, 13, 15],
UTM_SOURCE: "google",
UTM_MEDIUM: "CPC",
UTM_CAMPAIGN: "summer_sale",
UTM_CONTENT: "header_banner",
UTM_TERM: "discount",
PHONE: [
{
VALUE: "+12333333555",
VALUE_TYPE: "WORK",
},
{
VALUE: "+15599888666",
VALUE_TYPE: "HOME",
}
],
EMAIL: [
{
VALUE: "mitchellv@example.mailing",
VALUE_TYPE: "MAILING",
},
{
VALUE: "mitchell@example.work",
VALUE_TYPE: "WORK",
}
],
UF_CRM_1720697698689: "Example value of a custom field with type \"String\"",
PARENT_ID_1224: 12,
},
}
);
const result = response.getData().result;
result.error()
? console.error(result.error())
: console.info(result)
;
}
catch( error )
{
console.error(error);
}
try {
$response = $b24Service
->core
->call(
'crm.contact.add',
[
'fields' => [
'HONORIFIC' => 'HNR_RU_1',
'NAME' => 'John',
'SECOND_NAME' => 'Nicholas',
'LAST_NAME' => 'Mitchell',
'PHOTO' => [
'fileData' => document.getElementById('photo'),
],
'BIRTHDATE' => '11.11.2001',
'TYPE_ID' => 'PARTNER',
'SOURCE_ID' => 'WEB',
'SOURCE_DESCRIPTION' => '*Additional information about the source*',
'POST' => 'Administrator',
'COMMENTS' => `
Example comment inside the contact
[B]Bold text[/B]
[I]Italic[/I]
[U]Underlined[/U]
[S]Strikethrough[/S]
[B][I][U][S]Mix[/S][/U][/I][/B]
[LIST]
[*]List item #1
[*]List item #2
[*]List item #3
[/LIST]
[LIST=1]
[*]Numbered list item #1
[*]Numbered list item #2
[*]Numbered list item #3
[/LIST]
`,
'OPENED' => 'Y',
'EXPORT' => 'N',
'ASSIGNED_BY_ID' => 6,
'COMPANY_ID' => 12,
'COMPANY_IDS' => [12, 13, 15],
'UTM_SOURCE' => 'google',
'UTM_MEDIUM' => 'CPC',
'UTM_CAMPAIGN' => 'summer_sale',
'UTM_CONTENT' => 'header_banner',
'UTM_TERM' => 'discount',
'PHONE' => [
[
'VALUE' => '+12333333555',
'VALUE_TYPE' => 'WORK',
],
[
'VALUE' => '+15599888666',
'VALUE_TYPE' => 'HOME',
]
],
'EMAIL' => [
[
'VALUE' => 'mitchell@example.mailing',
'VALUE_TYPE' => 'MAILING',
],
[
'VALUE' => 'mitchell@example.work',
'VALUE_TYPE' => 'WORK',
]
],
'UF_CRM_1720697698689' => 'Example value of a custom field with type "String"',
'PARENT_ID_1224' => 12,
]
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
processData($result);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error adding contact: ' . $e->getMessage();
}
BX24.callMethod(
'crm.contact.add',
{
fields: {
HONORIFIC: "HNR_RU_1",
NAME: "John",
SECOND_NAME: "Nicholas",
LAST_NAME: "Mitchell",
PHOTO: {
fileData: document.getElementById('photo'),
},
BIRTHDATE: '11.11.2001',
TYPE_ID: "PARTNER",
SOURCE_ID: "WEB",
SOURCE_DESCRIPTION: "*Additional information about the source*",
POST: "Administrator",
COMMENTS: `
Example comment inside the contact
[B]Bold text[/B]
[I]Italic[/I]
[U]Underlined[/U]
[S]Strikethrough[/S]
[B][I][U][S]Mix[/S][/U][/I][/B]
[LIST]
[*]List item #1
[*]List item #2
[*]List item #3
[/LIST]
[LIST=1]
[*]Numbered list item #1
[*]Numbered list item #2
[*]Numbered list item #3
[/LIST]
`,
OPENED: "Y",
EXPORT: "N",
ASSIGNED_BY_ID: 6,
COMPANY_ID: 12,
COMPANY_IDS: [12, 13, 15],
UTM_SOURCE: "google",
UTM_MEDIUM: "CPC",
UTM_CAMPAIGN: "summer_sale",
UTM_CONTENT: "header_banner",
UTM_TERM: "discount",
PHONE: [
{
VALUE: "+12333333555",
VALUE_TYPE: "WORK",
},
{
VALUE: "+15599888666",
VALUE_TYPE: "HOME",
}
],
EMAIL: [
{
VALUE: "mitchell@example.mailing",
VALUE_TYPE: "MAILING",
},
{
VALUE: "mitchell@example.work",
VALUE_TYPE: "WORK",
}
],
UF_CRM_1720697698689: "Example value of a custom field with type \"String\"",
PARENT_ID_1224: 12,
},
},
(result) => {
result.error()
? console.error(result.error())
: console.info(result.data())
;
},
);
require_once('crest.php');
$result = CRest::call(
'crm.contact.add',
[
'FIELDS' => [
'HONORIFIC' => 'HNR_RU_1',
'NAME' => 'John',
'SECOND_NAME' => 'Nicholas',
'LAST_NAME' => 'Mitchell',
'PHOTO' => [
'fileData' => $_FILES['photo']
],
'BIRTHDATE' => '11.11.2001',
'TYPE_ID' => 'PARTNER',
'SOURCE_ID' => 'WEB',
'SOURCE_DESCRIPTION' => '*Additional information about the source*',
'POST' => 'Administrator',
'COMMENTS' => `
Example comment inside the contact
[B]Bold text[/B]
[I]Italic[/I]
[U]Underlined[/U]
[S]Strikethrough[/S]
[B][I][U][S]Mix[/S][/U][/I][/B]
[LIST]
[*]List item #1
[*]List item #2
[*]List item #3
[/LIST]
[LIST=1]
[*]Numbered list item #1
[*]Numbered list item #2
[*]Numbered list item #3
[/LIST]
`,
'OPENED' => 'Y',
'EXPORT' => 'N',
'ASSIGNED_BY_ID' => 6,
'COMPANY_ID' => 12,
'COMPANY_IDS' => [12, 13, 15],
'UTM_SOURCE' => 'google',
'UTM_MEDIUM' => 'CPC',
'UTM_CAMPAIGN' => 'summer_sale',
'UTM_CONTENT' => 'header_banner',
'UTM_TERM' => 'discount',
'PHONE' => [
[
'VALUE' => '+12333333555',
'VALUE_TYPE' => 'WORK',
],
[
'VALUE' => '+15599888666',
'VALUE_TYPE' => 'HOME',
]
],
'EMAIL' => [
[
'VALUE' => 'mitchell@example.mailing',
'VALUE_TYPE' => 'MAILING',
],
[
'VALUE' => 'mitchell@example.work',
'VALUE_TYPE' => 'WORK',
]
],
'UF_CRM_1720697698689' => 'Example value of a custom field with type "String"',
'PARENT_ID_1224' => 12,
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Response Handling
HTTP status: 200
{
"result": 46,
"time": {
"start": 1723713732.235658,
"finish": 1723713733.742049,
"duration": 1.5063910484313965,
"processing": 1.1416668891906738,
"date_start": "2024-08-15T11:22:12+02:00",
"date_finish": "2024-08-15T11:22:13+02:00"
}
}
Returned Data
|
Name |
Description |
|
result |
Root element of the response, contains the identifier of the created contact |
|
time |
Information about the request execution time |
Error Handling
HTTP status: 400
{
"error": "",
"error_description": "Parameter 'fields' must be array."
}
|
Name |
Description |
|
error |
String error code. It may consist of digits, Latin letters, and underscores |
|
error_description |
Textual description of the error. The description is not intended to be shown to the end user in its raw form |
Possible Error Codes
|
Code |
Description |
Value |
|
|
|
The parameter |
|
|
|
The parameter |
|
|
|
The user does not have permission to "Add" or "Import" contacts |
|
|
Disk resource exhausted |
|
|
|
The field |
Statuses and System Error Codes
HTTP Status: 20x, 40x, 50x
The errors described below may occur when calling any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred, please contact the server administrator or Bitrix24 technical support |
|
|
|
An internal server error has occurred, please contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The current method is not allowed to be called using batch |
|
|
|
The maximum length of parameters passed to the batch method has been exceeded |
|
|
|
Invalid access token or webhook code |
|
|
|
The methods must be called using the HTTPS protocol |
|
|
|
The REST API is blocked due to overload. This is a manual individual block, to remove it you need to contact Bitrix24 technical support |
|
|
|
The REST API is available only on commercial plans |
|
|
|
The user whose access token or webhook was used to call the method lacks permissions |
|
|
|
The manifest is not available |
|
|
|
The request requires higher privileges than those provided by the webhook token |
|
|
|
The provided access token has expired |
|
|
|
The user does not have access to the application. This means that the application is installed, but the account administrator has allowed access to this application only for specific users |
|
|
|
The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the option "Temporary closure of the public part of the site". Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |
Continue Learning
- Update Contact crm.contact.update
- Get Contact by Id crm.contact.get
- Get the list of contacts crm.contact.list
- Delete contact crm.contact.delete
- Get Contact Fields crm.contact.fields
- Add Contact via Web Form
- Add a contact with details via a web form
- How to Change or Delete Phone Numbers and Emails