Get Contact by Id crm.contact.get

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: crm

Who can execute the method: any user with "read" access permission for contacts

DEPRECATED

Development of this method has been halted. Please use crm.item.get.

The method crm.contact.get returns a contact by its identifier.

To retrieve a list of companies associated with the contact, use the method crm.contact.company.items.get.

Method Parameters

Required parameters are marked with *

Name
type

Description

id*
integer

Identifier of the contact. Can be obtained using the methods crm.contact.list or crm.contact.add

Code Examples

How to Use Examples in Documentation

Get contact with id = 23

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"ID":23}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.contact.get
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"ID":23,"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.contact.get
        
// 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, ISODate } from '@bitrix24/b24jssdk'
        
        declare const $b24: B24Frame
        
        // Shape of the payload returned in result (match the "response handling" section of the page)
        type CrmContactResult = {
          ID: string
          NAME: string
          LAST_NAME: string
          TYPE_ID: string
          SOURCE_ID: string
          COMPANY_ID: string
          ASSIGNED_BY_ID: string
          OPENED: string
          BIRTHDATE: ISODate | null
          DATE_CREATE: ISODate | null
          DATE_MODIFY: ISODate | null
          LAST_ACTIVITY_TIME: ISODate | null
        }
        
        try {
          const response = await $b24.actions.v2.call.make<CrmContactResult>({
            method: 'crm.contact.get',
            params: {
              id: 23,
            },
            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('Contact:', result.ID, result.NAME, result.LAST_NAME)
          }
        } 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 getContact() {
            try {
              // Initialize the SDK inside a Bitrix24 frame
              const $b24 = await B24Js.initializeB24Frame()
        
              const response = await $b24.actions.v2.call.make({
                method: 'crm.contact.get',
                params: {
                  id: 23,
                },
                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('Contact:', result.ID, result.NAME, result.LAST_NAME)
            } catch (error) {
              // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
              console.error(error)
            }
          }
        
          document.addEventListener('DOMContentLoaded', getContact)
        </script>
        
try {
            $contactId = 123; // Example contact ID
            $contactResult = $serviceBuilder
                ->getCRMScope()
                ->contact()
                ->get($contactId);
            $itemResult = $contactResult->contact();
            print("ID: " . $itemResult->ID . PHP_EOL);
            print("Name: " . $itemResult->NAME . PHP_EOL);
            print("Last Name: " . $itemResult->LAST_NAME . PHP_EOL);
            print("Birthday: " . $itemResult->BIRTHDATE?->format(DATE_ATOM) . PHP_EOL);
            print("Created Date: " . $itemResult->DATE_CREATE->format(DATE_ATOM) . PHP_EOL);
            print("Modified Date: " . $itemResult->DATE_MODIFY->format(DATE_ATOM) . PHP_EOL);
        } catch (Throwable $e) {
            print("Error: " . $e->getMessage() . PHP_EOL);
        }
        
BX24.callMethod(
            'crm.contact.get',
            {
                id: 23,
            },
            (result) => {
                result.error()
                    ? console.error(result.error())
                    : console.info(result.data())
                ;
            },
        );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.contact.get',
            [
                'ID' => 23
            ]
        );
        
        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.get", b24.Params{
        	"id": 23,
        }, b24.WithIdempotent())
        if err != nil {
        	return fmt.Errorf("crm.contact.get: %w", err)
        }
        
        var item struct {
        	ID         b24.ID `json:"ID"`
        	Post       string `json:"POST"`
        	Comments   string `json:"COMMENTS"`
        	Honorific  string `json:"HONORIFIC"`
        	Name       string `json:"NAME"`
        	SecondName string `json:"SECOND_NAME"`
        }
        if err := json.Unmarshal(res.Result, &item); err != nil {
        	return fmt.Errorf("parse response: %w", err)
        }
        fmt.Println(item.ID, item.Post)
        

Response Handling

HTTP Status: 200

{
            "result": {
                "ID": "43",
                "POST": "Administrator",
                "COMMENTS": "\nExample comment within the contact\n\n[B]Bold text[\/B]\n[I]Italic[\/I]\n[U]Underlined[\/U]\n[S]Strikethrough[\/S]\n[B][I][U][S]Mix[\/S][\/U][\/I][\/B]\n\n[LIST]\n[*]List item #1\n[*]List item #2\n[*]List item #3\n[\/LIST]\n\n[LIST=1]\n[*]Numbered list item #1\n[*]Numbered list item #2\n[*]Numbered list item #3\n[\/LIST]\n",
                "HONORIFIC": "HNR_RU_1",
                "NAME": "John",
                "SECOND_NAME": "Doe",
                "LAST_NAME": "Smith",
                "PHOTO": null,
                "LEAD_ID": null,
                "TYPE_ID": "PARTNER",
                "SOURCE_ID": "WEB",
                "SOURCE_DESCRIPTION": "*Additional information about the source*",
                "COMPANY_ID": "12",
                "BIRTHDATE": "2001-11-11T02:00:00+02:00",
                "EXPORT": "N",
                "HAS_PHONE": "Y",
                "HAS_EMAIL": "Y",
                "HAS_IMOL": "N",
                "DATE_CREATE": "2024-08-15T10:38:21+02:00",
                "DATE_MODIFY": "2024-08-15T10:38:21+02:00",
                "ASSIGNED_BY_ID": "6",
                "CREATED_BY_ID": "1",
                "MODIFY_BY_ID": "1",
                "OPENED": "Y",
                "ORIGINATOR_ID": null,
                "ORIGIN_ID": null,
                "ORIGIN_VERSION": null,
                "FACE_ID": null,
                "LAST_ACTIVITY_TIME": "2024-08-15T10:38:21+02:00",
                "ADDRESS": null,
                "ADDRESS_2": null,
                "ADDRESS_CITY": null,
                "ADDRESS_POSTAL_CODE": null,
                "ADDRESS_REGION": null,
                "ADDRESS_PROVINCE": null,
                "ADDRESS_COUNTRY": null,
                "ADDRESS_LOC_ADDR_ID": null,
                "UTM_SOURCE": "google",
                "UTM_MEDIUM": "CPC",
                "UTM_CAMPAIGN": "summer_sale",
                "UTM_CONTENT": "header_banner",
                "UTM_TERM": "discount",
                "PARENT_ID_1224": "12",
                "LAST_ACTIVITY_BY": "1",
                "UF_CRM_1720697698689": "Example value of a custom field with type \u0022String\u0022",
                "PHONE": [
                {
                    "ID": "156",
                    "VALUE_TYPE": "WORK",
                    "VALUE": "+13333333555",
                    "TYPE_ID": "PHONE"
                },
                {
                    "ID": "157",
                    "VALUE_TYPE": "HOME",
                    "VALUE": "+15599888666",
                    "TYPE_ID": "PHONE"
                }
                ],
                "EMAIL": [
                {
                    "ID": "158",
                    "VALUE_TYPE": "MAILING",
                    "VALUE": "johnsmith@example.mailing",
                    "TYPE_ID": "EMAIL"
                },
                {
                    "ID": "159",
                    "VALUE_TYPE": "WORK",
                    "VALUE": "johnsmith@example.work",
                    "TYPE_ID": "EMAIL"
                }
                ]
            },
            "time": {
                "start": 1723736139.883652,
                "finish": 1723736140.299369,
                "duration": 0.41571712493896484,
                "processing": 0.14158892631530762,
                "date_start": "2024-08-15T17:35:39+02:00",
                "date_finish": "2024-08-15T17:35:40+02:00"
            }
        }
        

Returned Data

Name
type

Description

result
contact

Root element of the response. Contains information about the contact fields. The structure is described below

time
time

Object containing information about the request execution time

contact

Name
type

Description

ID
integer

Identifier of the contact

POST
string

Position

COMMENTS
text

Comment

HONORIFIC
crm_status

Salutation

NAME
string

First name

SECOND_NAME
string

Middle name

LAST_NAME
string

Last name

PHOTO
file

Photo

LEAD_ID
crm_lead

Identifier of the lead from which the contact was created

TYPE_ID
crm_status

Type of contact

SOURCE_ID
crm_status

Source

SOURCE_DESCRIPTION
text

Additional information about the source

COMPANY_ID
crm_company

Identifier of the main company

BIRTHDATE
date

Date of birth

EXPORT
boolean

Whether the contact is included in exports. Possible values:

  • Y — yes
  • N — no

HAS_PHONE
boolean

Is a phone number provided. Possible values:

  • Y — yes
  • N — no

HAS_EMAIL
boolean

Is an e-mail provided. Possible values:

  • Y — yes
  • N — no

HAS_IMOL
boolean

Is an open line provided. Possible values:

  • Y — yes
  • N — no

DATE_CREATE
datetime

Creation date

DATE_MODIFY
datetime

Modification date

ASSIGNED_BY_ID
user

Responsible person

CREATED_BY_ID
user

Created by

MODIFY_BY_ID
user

Modified by

OPENED
boolean

Is it available to everyone. Possible values:

  • Y — yes
  • N — no

FACE_ID
integer

Link to faces from the faceid module

LAST_ACTIVITY_TIME
datetime

Last activity

LAST_ACTIVITY_BY
user

Who performed the last activity in the timeline

UTM_SOURCE
string

Advertising system (Google Ads, etc.)

UTM_MEDIUM
string

Type of traffic. Possible values:

  • CPC — ads
  • CPM — banners

UTM_CAMPAIGN
string

Identifier of the advertising campaign

UTM_CONTENT
string

Content of the campaign. For example, for contextual ads

UTM_TERM
string

Search condition of the campaign. For example, keywords for contextual advertising

PHONE
crm_multifield[]

Phone

EMAIL
crm_multifield[]

E-mail

WEB
crm_multifield[]

Website

IM
crm_multifield[]

Messenger

LINK
crm_multifield[]

Links. Service field

Fields for external data source connections

If the contact was created by an external system, then:

  • the ORIGINATOR_ID field stores the string identifier of that system
  • the ORIGIN_ID field stores the string identifier of the contact in that external system
  • the ORIGIN_VERSION field stores the version of the contact data in that external system

Name
type

Description

ORIGINATOR_ID
string

External source

ORIGIN_ID
string

Identifier of the element in the external source

ORIGIN_VERSION
string

Version of the original

Deprecated Fields

Address fields in the contact are deprecated and are only used for compatibility. To work with addresses, use requisites.

Name
type

Description

ADDRESS
string

Address

ADDRESS_2
string

Second line of the address

ADDRESS_CITY
string

City

ADDRESS_POSTAL_CODE
string

Postal code

ADDRESS_REGION
string

District

ADDRESS_PROVINCE
string

Region

ADDRESS_COUNTRY
string

Country

ADDRESS_LOC_ADDR_ID
integer

Identifier of the location address

Fields of type crm_multifield

Fields of type crm_multifield (PHONE, EMAIL, WEB, IM, LINK) are explicitly returned by this method only if the values of this field are not equal to null.

Error Handling

HTTP Status: 400

{
            "error": "",
            "error_description": "ID is not defined or invalid."
        }
        

Name
type

Description

error
string

String error code. It consists of digits, Latin letters, and underscores. It may arrive empty — in that case only error_description shows the reason

error_description
string

Error message for the developer. Do not show it to the end user without processing

Possible Error Codes

Description

Value

ID is not defined or invalid

The id parameter was not provided or the provided value is not a positive integer

Access denied

The user does not have permission to "Read" the contact

Not found

The contact with the provided id was not found

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
Error Message

Description

500

INTERNAL_SERVER_ERROR
Internal server error

An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support

500

ERROR_UNEXPECTED_ANSWER
Server returned an unexpected response

The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support

503

QUERY_LIMIT_EXCEEDED
Too many requests

The request intensity limit has been exceeded

429

OPERATION_TIME_LIMIT
Method is blocked due to operation time limit

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

401

NO_AUTH_FOUND
Wrong authorization data

The request contains no authorization data: neither an access token nor a webhook code was passed

401

INVALID_REQUEST
Https required

Methods are called over the HTTPS protocol only

401

OVERLOAD_LIMIT
REST API is blocked due to overload

The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support

401

ACCESS_DENIED
REST is available only on commercial plans

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 — REST is available only by subscription

401

INVALID_CREDENTIALS
Invalid request credentials

No active webhook with the specified user identifier and secret code was found

404

ERROR_METHOD_NOT_FOUND
Method not 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

401

insufficient_scope
The request requires higher privileges than provided by the webhook token

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 provided by the access token

401

expired_token
The access token provided has expired

The access token has expired

401

user_access_error
The user does not have access to the application

The application is installed, but the Bitrix24 administrator has granted access to it only to specific users

403

PORTAL_DELETED
Portal was deleted

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

Continue Learning