Create a New Contact crm.contact.add
Choose a tool for developing with an AI agent:
- use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
- use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation
Scope:
crmWho can execute the method: any user with "add|import" access permission for contacts
DEPRECATED
The development of this method has been halted. Please use crm.item.add.
The method crm.contact.add creates a new contact.
Method Parameters
|
Name |
Description |
|
fields |
An object in the following format:
where:
The list of available fields is described below. An incorrect field in |
|
params |
An 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 |
Photograph |
|
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 is |
|
EXPORT |
Is the contact included in the export? Possible values:
Default is |
|
ASSIGNED_BY_ID |
Identifier of the user responsible for the item. 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 associated with the contact. The list of companies can be obtained using the method |
|
UTM_SOURCE |
Advertising system (Google Ads, Microsoft Advertising, 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 portal settings, contacts may have a set of custom fields of defined types. A custom field can be added to a contact using the method crm.contact.userfield.add |
|
PARENT_ID_... |
Relationship fields. If there are smart processes associated with contacts on the portal, there is a field for each such smart process that stores the relationship between that smart process and the contact. The field itself stores the identifier of the element of that smart process. For example, the field |
Fields for connections 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 lead to data overwriting |
|
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. |
Deprecated fields
Address fields in the contact are deprecated and are only used for 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 is |
|
IMPORT |
Is import mode enabled? Possible values:
To pass the value Default is |
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":"Doe","LAST_NAME":"Smith","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":"+1333333555","VALUE_TYPE":"WORK"},{"VALUE":"+15599888666","VALUE_TYPE":"HOME"}],"EMAIL":[{"VALUE":"john.smith@example.mailing","VALUE_TYPE":"MAILING"},{"VALUE":"john.smith@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":"Doe","LAST_NAME":"Smith","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":"+1333333555","VALUE_TYPE":"WORK"},{"VALUE":"+15599888666","VALUE_TYPE":"HOME"}],"EMAIL":[{"VALUE":"john.smith@example.mailing","VALUE_TYPE":"MAILING"},{"VALUE":"john.smith@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
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
try {
const response = await $b24.actions.v2.call.make<number>({
method: 'crm.contact.add',
params: {
fields: {
HONORIFIC: 'HNR_RU_1',
NAME: 'Ivan',
SECOND_NAME: 'Ivanovich',
LAST_NAME: 'Ivanov',
PHOTO: {
fileData: document.getElementById('photo'),
},
BIRTHDATE: '11.11.2001',
TYPE_ID: 'PARTNER',
SOURCE_ID: 'WEB',
SOURCE_DESCRIPTION: '*Additional source details*',
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: 'yandex',
UTM_MEDIUM: 'CPC',
UTM_CAMPAIGN: 'summer_sale',
UTM_CONTENT: 'header_banner',
UTM_TERM: 'discount',
PHONE: [
{
VALUE: '+49333333555',
VALUE_TYPE: 'WORK',
},
{
VALUE: '+35599888666',
VALUE_TYPE: 'HOME',
},
],
EMAIL: [
{
VALUE: 'ivanov@example.mailing',
VALUE_TYPE: 'MAILING',
},
{
VALUE: 'ivanov@example.work',
VALUE_TYPE: 'WORK',
},
],
UF_CRM_1720697698689: 'Example value of a custom field of type "String"',
PARENT_ID_1224: 12,
},
},
requestId: Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
const result = response.getData()!.result
console.info('Created contact id:', result)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function addContact() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'crm.contact.add',
params: {
fields: {
HONORIFIC: 'HNR_RU_1',
NAME: 'Ivan',
SECOND_NAME: 'Ivanovich',
LAST_NAME: 'Ivanov',
PHOTO: {
fileData: document.getElementById('photo'),
},
BIRTHDATE: '11.11.2001',
TYPE_ID: 'PARTNER',
SOURCE_ID: 'WEB',
SOURCE_DESCRIPTION: '*Additional source details*',
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: 'yandex',
UTM_MEDIUM: 'CPC',
UTM_CAMPAIGN: 'summer_sale',
UTM_CONTENT: 'header_banner',
UTM_TERM: 'discount',
PHONE: [
{
VALUE: '+49333333555',
VALUE_TYPE: 'WORK',
},
{
VALUE: '+35599888666',
VALUE_TYPE: 'HOME',
},
],
EMAIL: [
{
VALUE: 'ivanov@example.mailing',
VALUE_TYPE: 'MAILING',
},
{
VALUE: 'ivanov@example.work',
VALUE_TYPE: 'WORK',
},
],
UF_CRM_1720697698689: 'Example value of a custom field of type "String"',
PARENT_ID_1224: 12,
},
},
requestId: B24Js.Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
const result = response.getData().result
console.info('Created contact id:', result)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', addContact)
</script>
try {
$response = $b24Service
->core
->call(
'crm.contact.add',
[
'fields' => [
'HONORIFIC' => 'HNR_RU_1',
'NAME' => 'John',
'SECOND_NAME' => 'Doe',
'LAST_NAME' => 'Smith',
'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 within 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' => '+1333333555',
'VALUE_TYPE' => 'WORK',
],
[
'VALUE' => '+15599888666',
'VALUE_TYPE' => 'HOME',
]
],
'EMAIL' => [
[
'VALUE' => 'john.smith@example.mailing',
'VALUE_TYPE' => 'MAILING',
],
[
'VALUE' => 'john.smith@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: "Doe",
LAST_NAME: "Smith",
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 within 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: "+1333333555",
VALUE_TYPE: "WORK",
},
{
VALUE: "+15599888666",
VALUE_TYPE: "HOME",
}
],
EMAIL: [
{
VALUE: "john.smith@example.mailing",
VALUE_TYPE: "MAILING",
},
{
VALUE: "john.smith@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' => 'Doe',
'LAST_NAME' => 'Smith',
'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 within 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' => '+1333333555',
'VALUE_TYPE' => 'WORK',
],
[
'VALUE' => '+15599888666',
'VALUE_TYPE' => 'HOME',
]
],
'EMAIL' => [
[
'VALUE' => 'john.smith@example.mailing',
'VALUE_TYPE' => 'MAILING',
],
[
'VALUE' => 'john.smith@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>';
// client and ctx are already created — see the Go SDK section
res, err := client.Core().Call(ctx, "crm.contact.add", b24.Params{
"fields": b24.Params{
"HONORIFIC": "HNR_RU_1",
"NAME": "John",
"SECOND_NAME": "Doe",
"LAST_NAME": "Smith",
"PHOTO": b24.Params{
"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": []int{12, 13, 15},
"UTM_SOURCE": "yandex",
"UTM_MEDIUM": "CPC",
"UTM_CAMPAIGN": "summer_sale",
"UTM_CONTENT": "header_banner",
"UTM_TERM": "discount",
"PHONE": []b24.Params{
{
"VALUE": "+49333333555",
"VALUE_TYPE": "WORK",
},
{
"VALUE": "+35599888666",
"VALUE_TYPE": "HOME",
},
},
"EMAIL": []b24.Params{
{
"VALUE": "ivanov@example.mailing",
"VALUE_TYPE": "MAILING",
},
{
"VALUE": "ivanov@example.work",
"VALUE_TYPE": "WORK",
},
},
"UF_CRM_1720697698689": "Example value of a custom field with type \"String\"",
"PARENT_ID_1224": 12,
},
})
if err != nil {
return fmt.Errorf("crm.contact.add: %w", err)
}
var newID b24.ID
if err := json.Unmarshal(res.Result, &newID); err != nil {
return fmt.Errorf("parse response: %w", err)
}
fmt.Println("id:", newID)
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 |
The 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 consists of digits, Latin letters, and underscores. It may arrive empty — in that case only |
|
error_description |
Error message for the developer. Do not show it to the end user without processing |
Possible Error Codes
|
Code |
Description |
Value |
|
Empty value |
|
The parameter |
|
Empty value |
|
The parameter |
|
Empty value |
|
The user does not have permission to "Add" or "Import" contacts |
|
Empty value |
Disk resource exhausted |
|
|
|
The field |
Statuses and System Error Codes
HTTP Status: 4xx, 5xx
The errors described below are returned by the REST API itself, not by the logic of a specific method. They can arrive in response to any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The method is blocked because the request resource intensity limit has been exceeded. The block is lifted automatically once the accumulated execution time of the method no longer exceeds the limit |
|
|
|
The request contains no authorization data: neither an access token nor a webhook code was passed |
|
|
|
Methods are called over the HTTPS protocol only |
|
|
|
The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support |
|
|
|
REST API access is not active for this account. In Bitrix24 Cloud, check the current plan or trial status: Vibe+ plans include REST API access, while Essentials plans do not. A webhook receives a different error message — |
|
|
|
No active webhook with the specified user identifier and secret code was found |
|
|
|
No method with this name was found. The name is misspelled, the method does not exist in the REST API, or it is unavailable without the required scope |
|
|
|
The request requires broader permissions than the token has: for a webhook these are the permissions granted to it, for an application it is the scope. For an application, the error message ends with |
|
|
|
The access token has expired |
|
|
|
The application is installed, but the Bitrix24 administrator has granted access to it only to specific users |
|
|
|
The public part of the site is closed. To open it on an on-premise installation, disable the "Temporary closure of the public part of the site" option. Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |