Get lead by Id crm.lead.get

Scope: crm

Who can execute the method: a user with read access permission for the requested lead

Method Development Stopped

The method crm.lead.get continues to function, but there is a more relevant alternative crm.item.get.

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

Method Parameters

Required parameters are marked with *

Name
type

Description

id*
integer

Lead identifier.

The identifier can be obtained using the methods crm.lead.list or crm.lead.add

Code Examples

How to Use Examples in Documentation

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"ID":123}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.lead.get
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"ID":123,"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.lead.get
        
try
        {
        	const response = await $b24.callMethod(
        		'crm.lead.get',
        		{ id: 123 }
        	);
        	
        	const result = response.getData().result;
        	console.info(result);
        }
        catch( error )
        {
        	console.error(error);
        }
        
try {
            $response = $b24Service
                ->core
                ->call(
                    'crm.lead.get',
                    [
                        'id' => 123,
                    ]
                );
        
            $result = $response
                ->getResponseData()
                ->getResult();
        
            if ($result->error()) {
                error_log($result->error());
                return;
            }
        
            echo 'Lead data: ' . print_r($result->data(), true);
        
        } catch (Throwable $e) {
            error_log($e->getMessage());
            echo 'Error getting lead data: ' . $e->getMessage();
        }
        
BX24.callMethod(
          'crm.lead.get',
          { id: 123 },
          (result) => {
            if(result.error())
            {
              console.error(result.error());
        
              return;
            }
            
            console.info(result.data());
          }
        );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.lead.get',
            [
                'ID' => 123
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Response Handling

HTTP status: 200

{
          "result": {
            "ID": "123",
            "TITLE": "Lead #1591",
            "HONORIFIC": null,
            "NAME": "",
            "SECOND_NAME": null,
            "LAST_NAME": null,
            "COMPANY_TITLE": null,
            "COMPANY_ID": null,
            "CONTACT_ID": null,
            "IS_RETURN_CUSTOMER": "N",
            "BIRTHDATE": "",
            "SOURCE_ID": "1",
            "SOURCE_DESCRIPTION": null,
            "STATUS_ID": "IN_PROCESS",
            "STATUS_DESCRIPTION": null,
            "POST": null,
            "COMMENTS": null,
            "CURRENCY_ID": "USD",
            "OPPORTUNITY": "0.00",
            "IS_MANUAL_OPPORTUNITY": "N",
            "HAS_PHONE": "N",
            "HAS_EMAIL": "N",
            "HAS_IMOL": "N",
            "ASSIGNED_BY_ID": "1",
            "CREATED_BY_ID": "1",
            "MODIFY_BY_ID": "1",
            "DATE_CREATE": "2024-05-23T18:18:25+02:00",
            "DATE_MODIFY": "2024-05-23T18:18:25+02:00",
            "DATE_CLOSED": "",
            "STATUS_SEMANTIC_ID": "P",
            "OPENED": "Y",
            "ORIGINATOR_ID": null,
            "ORIGIN_ID": null,
            "MOVED_BY_ID": "1",
            "MOVED_TIME": "2024-05-23T18:18:25+02:00",
            "ADDRESS": null,
            "ADDRESS_2": null,
            "ADDRESS_CITY": null,
            "ADDRESS_POSTAL_CODE": null,
            "ADDRESS_REGION": null,
            "ADDRESS_PROVINCE": null,
            "ADDRESS_COUNTRY": null,
            "ADDRESS_COUNTRY_CODE": null,
            "ADDRESS_LOC_ADDR_ID": null,
            "UTM_SOURCE": null,
            "UTM_MEDIUM": null,
            "UTM_CAMPAIGN": null,
            "UTM_CONTENT": null,
            "UTM_TERM": null,
            "LAST_ACTIVITY_BY": "1",
            "LAST_ACTIVITY_TIME": "2024-05-23T18:18:25+02:00",
            "PHONE": [
              {
                "ID": "11658",
                "VALUE_TYPE": "OTHER",
                "VALUE": "+15454777777",
                "TYPE_ID": "PHONE"
              }
            ],
            "IM": [
              {
                "ID": "11660",
                "VALUE_TYPE": "OPENLINE",
                "VALUE": "imol|livechat|1|67|21",
                "TYPE_ID": "IM"
              }
            ]
          },
          "time": {
              "start": 1705764932.998683,
              "finish": 1705764937.173995,
              "duration": 4.1753120422363281,
              "processing": 3.3076529502868652,
              "date_start": "2024-01-20T18:35:32+02:00",
              "date_finish": "2024-01-20T18:35:37+02:00",
              "operating_reset_at": 1705765533,
              "operating": 3.3076241016387939
          }
        }
        

Returned Data

Name
type

Description

result
lead

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

time
time

Information about the request execution time

Type lead

Name
type

Description

ID
integer

Integer identifier of the lead

TITLE
string

Title of the lead

HONORIFIC
crm_status

Type of address. Status from the directory. A list of possible identifiers can be obtained using the method crm.status.list with the filter filter[ENTITY_ID]=HONORIFIC

NAME
string

Contact's first name

SECOND_NAME
string

Contact's middle name

LAST_NAME
string

Contact's last name

COMPANY_ID
crm_company

Link of the lead to the company

COMPANY_TITLE
string

Company name

CONTACT_ID
crm_contact

Link of the lead to the contact

IS_RETURN_CUSTOMER
char

Indicator of a returning lead. Allowed values Y or N

BIRTHDATE
date

Date of birth

SOURCE_ID
crm_status

Identifier of the source. Status from the directory. A list of possible identifiers can be obtained using the method crm.status.list with the filter filter[ENTITY_ID]=SOURCE

SOURCE_DESCRIPTION
string

Description of the source

STATUS_ID
crm_status

Identifier of the lead stage. Status from the directory. A list of possible identifiers can be obtained using the method crm.status.list with the filter filter[ENTITY_ID]=STATUS

STATUS_DESCRIPTION
string

Additional information about the stage

POST
string

Position

COMMENTS
string

Comments

CURRENCY_ID
crm_currency

Currency identifier

OPPORTUNITY
double

Estimated amount

IS_MANUAL_OPPORTUNITY
char

Indicator of manual calculation of the amount. Allowed values Y or N

HAS_PHONE
char

Indicator of phone field completion. Allowed values Y or N

HAS_EMAIL
char

Indicator of email field completion. Allowed values Y or N

HAS_IMOL
char

Indicator of the presence of an attached open line. Allowed values Y or N

ASSIGNED_BY_ID
user

Identifier of the user responsible for the lead

CREATED_BY_ID
user

Identifier of the user who created the lead

MODIFY_BY_ID
user

Identifier of the user who last modified the lead

MOVED_BY_ID
user

Identifier of the user who moved the item to the current stage

DATE_CREATE
datetime

Creation date

DATE_MODIFY
datetime

Modification date

DATE_CLOSED
datetime

Closing date

STATUS_SEMANTIC_ID
string

  • F (failed) – processed unsuccessfully
  • S (success) – processed successfully
  • P (processing) – lead is being processed

OPENED
char

Indicator of the lead's availability to everyone. Allowed values Y or N

ORIGINATOR_ID
string

Identifier of the data source. Used only for linking to an external source

ORIGIN_ID
string

Identifier of the item in the data source. Used only for linking to an external source

MOVED_TIME
datetime

Date of moving the item to the current stage

ADDRESS
string

Contact's address

ADDRESS_2
string

Second line of the address. In some countries, it is customary to split the address into 2 parts

ADDRESS_CITY
string

City

ADDRESS_POSTAL_CODE
string

Postal code

ADDRESS_REGION
string

Region

ADDRESS_PROVINCE
string

Province

ADDRESS_COUNTRY
string

Country

ADDRESS_COUNTRY_CODE
string

Country code

ADDRESS_LOC_ADDR_ID
string

Used for service purposes

UTM_SOURCE
string

Advertising system. Google Ads, Facebook Ads, and others

UTM_MEDIUM
string

Type of traffic. CPC (ads), CPM (banners)

UTM_CAMPAIGN
string

Designation of the advertising campaign

UTM_CONTENT
string

Content of the campaign. For example, for contextual ads

UTM_TERM
string

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

LAST_ACTIVITY_BY
string

Identifier of the user responsible for the last activity in this lead (e.g., who created a new activity in the lead)

LAST_ACTIVITY_TIME
datetime

Time of the last activity

UF_...

Custom fields. For example, UF_CRM_25534736.

Depending on the account settings, leads may have a set of custom fields of specific types.

To create, modify, or delete custom fields in leads, use the methods crm.lead.userfield.*

PHONE
crm_multifield

Array of phone numbers

IM
crm_multifield

Array of messengers

Error Handling

40x, 50x Error

{
            "error": "",
            "error_description": "Not found"
        }
        

Name
type

Description

error
string

String error code. It may consist of digits, Latin letters, and underscores

error_description
error_description

Textual description of the error. The description is not intended to be shown to the end user in its raw form

Possible Errors

Error Text

Description

ID is not defined or invalid

The id parameter is either not provided or is not a positive integer

Not found

A lead with the specified id was not found

Access denied

The user does not have permission to read the lead

Statuses and System Error Codes

HTTP Status: 20x, 40x, 50x

The errors described below may occur when calling any method.

Status

Code
Error Message

Description

500

INTERNAL_SERVER_ERROR
Internal server error

An internal server error has occurred, please contact the server administrator or Bitrix24 technical support

500

ERROR_UNEXPECTED_ANSWER
Server returned an unexpected response

An internal server error has occurred, please contact the server administrator or Bitrix24 technical support

503

QUERY_LIMIT_EXCEEDED
Too many requests

The request intensity limit has been exceeded

405

ERROR_BATCH_METHOD_NOT_ALLOWED
Method is not allowed for batch usage

The current method is not allowed to be called using batch

400

ERROR_BATCH_LENGTH_EXCEEDED
Max batch length exceeded

The maximum length of parameters passed to the batch method has been exceeded

401

NO_AUTH_FOUND
Wrong authorization data

Invalid access token or webhook code

400

INVALID_REQUEST
Https required

The methods must be called using the HTTPS protocol

503

OVERLOAD_LIMIT
REST API is blocked due to overload

The REST API is blocked due to overload. This is a manual individual block, to remove it you need to contact Bitrix24 technical support

403

ACCESS_DENIED
REST API is available only on commercial plans

The REST API is available only on commercial plans

403

INVALID_CREDENTIALS
Invalid request credentials

The user whose access token or webhook was used to call the method lacks permissions

404

ERROR_MANIFEST_IS_NOT_AVAILABLE
Manifest is not available

The manifest is not available

403

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

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

401

expired_token
The access token provided has expired

The provided access token has expired

403

user_access_error
The user does not have access to the application

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

500

PORTAL_DELETED
Portal was deleted

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