Get a List of Leads crm.lead.list

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: a user with read access to leads

DEPRECATED

The development of this method has been halted. Use crm.item.list.

The method crm.lead.list returns a list of leads based on a filter. It is an implementation of the list method for leads.

Method Parameters

Required parameters are marked with *

Name
type

Description

select
array

An array containing the list of fields to select (see lead fields crm-lead-fields).

When selecting, use masks:

  • "*" - to select all fields (excluding custom and multiple fields)
  • "UF_*" - to select all custom fields (excluding multiple fields)

There are no masks for selecting multiple fields. To select multiple fields, specify the required ones in the selection list ("PHONE", "EMAIL", etc.).
There is no option to add a logical OR condition to the filter if you need to select by several different fields.

filter
object

An object for filtering selected leads in the format {"field_1": "value_1", ... "field_N": "value_N"}.

Possible values for field correspond to lead fields crm-lead-fields.

An additional prefix can be assigned to the key to specify the filter behavior. Possible prefix values:

  • >= — greater than or equal to

  • > — greater than

  • <= — less than or equal to

  • < — less than

  • @ — IN (an array is passed as the value)

  • !@ — NOT IN (an array is passed as the value)

  • % — LIKE, substring search. The % symbol in the filter value should not be passed. The search looks for a substring in any position of the string

  • =% — LIKE, substring search. The % symbol should be passed in the value. Examples:

    • "mol%" — searching for values starting with "mol"
    • "%mol" — searching for values ending with "mol"
    • "%mol%" — searching for values where "mol" can be in any position
  • %= — LIKE (see description above)

  • !% — NOT LIKE, substring search. The % symbol in the filter value should not be passed. The search goes from both sides.

  • =% — NOT LIKE, substring search. The % symbol should be passed in the value. Examples:

    • "mol%" — searching for values not starting with "mol"
    • "%mol" — searching for values not ending with "mol"
    • "%mol%" — searching for values where the substring "mol" is not present in any position
  • !%= — NOT LIKE (see description above)

  • = — equal, exact match (used by default)

  • != - not equal

  • ! — not equal

order
Possible values for order:

  • asc — in ascending order
  • desc — in descending order

start
integer

This parameter is used to control pagination.

The page size of results is always static: 50 records.

To select the second page of results, you need to pass the value 50. To select the third page of results — the value 100, and so on.

The formula for calculating the value of the start parameter:

start = (N-1) * 50, where N — the number of the desired page

Also, see the description of list methods.

Code Examples

How to Use Examples in Documentation

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"select":["*","UF_*"],"start":50,"filter":{"=OPPORTUNITY":15000},"order":{"STATUS_ID":"ASC"}}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.lead.list
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"select":["*","UF_*"],"start":50,"filter":{"=OPPORTUNITY":15000},"order":{"STATUS_ID":"ASC"},"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.lead.list
        
// 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 each lead object returned in result[]
        type CrmLeadListItem = {
          ID: string
          TITLE: string
          NAME: string | null
          LAST_NAME: string | null
          STATUS_ID: string
          SOURCE_ID: string
          CURRENCY_ID: string
          OPPORTUNITY: string
          ASSIGNED_BY_ID: string
          OPENED: string
          DATE_CREATE: ISODate | null
          DATE_MODIFY: ISODate | null
        }
        
        try {
          // crm.lead.list returns a single page (max 50 records). For the whole result set
          // use a list helper: $b24.actions.v2.callList.make() returns every record as one
          // array, $b24.actions.v2.fetchList.make() yields them in chunks (async generator).
          // NOTE: the list helpers do not accept `order` (it is excluded from their params, so
          // passing it is a TS error) — keep this call.make + `start` variant when sort matters.
          const response = await $b24.actions.v2.call.make<CrmLeadListItem[]>({
            method: 'crm.lead.list',
            params: {
              select: ['*', 'UF_*'],
              filter: {
                '=OPPORTUNITY': 15000,
              },
              order: {
                STATUS_ID: 'ASC',
              },
              start: 50,
            },
            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('Leads on this page:', result.length, 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 listLeads() {
            try {
              // Initialize the SDK inside a Bitrix24 frame
              const $b24 = await B24Js.initializeB24Frame()
        
              // crm.lead.list returns a single page (max 50 records). For the whole result set
              // use a list helper: $b24.actions.v2.callList.make() returns every record as one
              // array, $b24.actions.v2.fetchList.make() yields them in chunks (async generator).
              // NOTE: the list helpers do not accept `order` (it is excluded from their params, so
              // passing it is a TS error) — keep this call.make + `start` variant when sort matters.
              const response = await $b24.actions.v2.call.make({
                method: 'crm.lead.list',
                params: {
                  select: ['*', 'UF_*'],
                  filter: {
                    '=OPPORTUNITY': 15000,
                  },
                  order: {
                    STATUS_ID: 'ASC',
                  },
                  start: 50,
                },
                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('Leads on this page:', result.length, result)
            } catch (error) {
              // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
              console.error(error)
            }
          }
        
          document.addEventListener('DOMContentLoaded', listLeads)
        </script>
        

Example


        from b24pysdk.errors import BitrixAPIError, BitrixSDKException
        
        try:
            bitrix_response = client.crm.lead.list(
                select=["ID", "TITLE", "STATUS_ID", "OPPORTUNITY", "CURRENCY_ID", "ASSIGNED_BY_ID", "DATE_CREATE"],
                filter={">OPPORTUNITY": 0, "!STATUS_ID": "CONVERTED", "=OPENED": "Y"},
                order={"DATE_CREATE": "DESC", "ID": "DESC"},
                start=0,
            ).response
            result = bitrix_response.result
            print(result)
        except BitrixAPIError as error:
            print(
                "Bitrix API error",
                f"error: {error.error}",
                f"error_description: {error.error_description}",
                sep="\n",
            )
        except BitrixSDKException as error:
            print(f"Bitrix SDK error: {error.message}")
        except Exception as error:
            print(f"Unexpected error: {error}")
        

Example as_list


        from b24pysdk.errors import BitrixAPIError, BitrixSDKException
        
        try:
            bitrix_response = client.crm.lead.list(
                select=["ID", "TITLE", "STATUS_ID"],
                filter={"!STATUS_ID": "JUNK"},
                order={"ID": "ASC"},
            ).as_list().response
            result = bitrix_response.result
            for item in result:
                print(item)
        except BitrixAPIError as error:
            print(
                "Bitrix API error",
                f"error: {error.error}",
                f"error_description: {error.error_description}",
                sep="\n",
            )
        except BitrixSDKException as error:
            print(f"Bitrix SDK error: {error.message}")
        except Exception as error:
            print(f"Unexpected error: {error}")
        

Example as_list_fast


        from b24pysdk.errors import BitrixAPIError, BitrixSDKException
        
        try:
            bitrix_response = client.crm.lead.list(
                select=["ID", "TITLE", "STATUS_ID"],
                filter={"!STATUS_ID": "JUNK"},
                order={"ID": "DESC"},
            ).as_list_fast(descending=True).response
            result = bitrix_response.result
            for item in result:
                print(item)
        except BitrixAPIError as error:
            print(
                "Bitrix API error",
                f"error: {error.error}",
                f"error_description: {error.error_description}",
                sep="\n",
            )
        except BitrixSDKException as error:
            print(f"Bitrix SDK error: {error.message}")
        except Exception as error:
            print(f"Unexpected error: {error}")
        
try {
            $order = [];
            $filter = []; // Define your filter criteria here
            $select = [
                'ID', 'TITLE', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 
                'BIRTHDATE', 'COMPANY_TITLE', 'SOURCE_ID', 'SOURCE_DESCRIPTION', 
                'STATUS_ID', 'STATUS_DESCRIPTION', 'STATUS_SEMANTIC_ID', 'POST', 
                'ADDRESS', 'ADDRESS_2', 'ADDRESS_CITY', 'ADDRESS_POSTAL_CODE', 
                'ADDRESS_REGION', 'ADDRESS_PROVINCE', 'ADDRESS_COUNTRY', 
                'ADDRESS_COUNTRY_CODE', 'ADDRESS_LOC_ADDR_ID', 'CURRENCY_ID', 
                'OPPORTUNITY', 'IS_MANUAL_OPPORTUNITY', 'OPENED', 'COMMENTS', 
                'HAS_PHONE', 'HAS_EMAIL', 'HAS_IMOL', 'ASSIGNED_BY_ID', 
                'CREATED_BY_ID', 'MODIFY_BY_ID', 'MOVED_BY_ID', 'DATE_CREATE', 
                'DATE_MODIFY', 'MOVED_TIME', 'COMPANY_ID', 'CONTACT_ID', 
                'CONTACT_IDS', 'IS_RETURN_CUSTOMER', 'DATE_CLOSED', 
                'ORIGINATOR_ID', 'ORIGIN_ID', 'UTM_SOURCE', 'UTM_MEDIUM', 
                'UTM_CAMPAIGN', 'UTM_CONTENT', 'UTM_TERM', 'PHONE', 'EMAIL', 
                'WEB', 'IM', 'LINK'
            ];
            $startItem = 0;
            $leadsResult = $serviceBuilder->getCRMScope()->lead()->list($order, $filter, $select, $startItem);
            
            foreach ($leadsResult->getLeads() as $lead) {
                print("ID: {$lead->ID}, TITLE: {$lead->TITLE}, NAME: {$lead->NAME}, BIRTHDATE: " . 
                      ($lead->BIRTHDATE ? $lead->BIRTHDATE->format(DATE_ATOM) : 'N/A') . "\n");
            }
        } catch (Throwable $e) {
            print("Error: " . $e->getMessage());
        }
        
BX24.callMethod(
          'crm.lead.list',
          {
            select: ['*', 'UF_*'],
            filter: {
                '=OPPORTUNITY': 15000,
            },
            order: {
                STATUS_ID: 'ASC',
            }, 
          },
          (result) => {
            if(result.error())
            {
              console.error(result.error());
        
              return;
            }
            
            console.info(result.data());
        
            if (result.more())
            {
              result.next();
            }
          }
        );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.lead.list',
            [
                'select' => ['*', 'UF_*'],
                'start' => 50,
                'filter' => [
                    '=OPPORTUNITY' => 15000,
                ],
                'order' => [
                    'STATUS_ID' => 'ASC',
                ],
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Some Practical Examples

BX24.callMethod(
            "crm.lead.list",
            {
                order: { "STATUS_ID": "ASC" },
                filter: { ">OPPORTUNITY": 0, "!STATUS_ID": "CONVERTED" },
                select: [ "ID", "TITLE", "STATUS_ID", "OPPORTUNITY", "CURRENCY_ID" ],
            },
            (result) => {
                if(result.error())
                {
                    console.error(result.error());
                }
                else
                {
                    console.dir(result.data());
                    if (result.more())
                    {
                        result.next();
                    }
                }
            }
        );
        
BX24.callMethod(
            "crm.lead.list",
            {
                filter: { "PHONE": "555888" },
                select: [ "ID", "TITLE" ]
            },
            (result) => {
              if(result.error())
              {
                console.error(result.error());
              }
              else
              {
                console.dir(result.data());
                if (result.more())
                {
                  result.next();
                }
              }
            }
        );
        
$result = CRest::call(
            'crm.lead.list',
            [
                'filter' => [
                    '>DATE_CREATE' => '2023-10-01T00:00:00',
                    '<DATE_CREATE' => '2023-10-31T23:59:59',
                ],
                'select' => [
                    'ID',
                    'DATE_CREATE',
                ],
            ]
        );
        

Response Handling

HTTP Status: 200

{
          "result": [
            {
              "ID": "5",
              "TITLE": "Lead 1",
              "HONORIFIC": null,
              "NAME": "Erasmus",
              "SECOND_NAME": null,
              "LAST_NAME": "Golden of Ireland",
              "COMPANY_TITLE": null,
              "COMPANY_ID": "0",
              "CONTACT_ID": "2069",
              "IS_RETURN_CUSTOMER": "N",
              "BIRTHDATE": "",
              "SOURCE_ID": "CALL",
              "SOURCE_DESCRIPTION": null,
              "STATUS_ID": "CONVERTED",
              "STATUS_DESCRIPTION": null,
              "POST": null,
              "COMMENTS": null,
              "CURRENCY_ID": "USD",
              "OPPORTUNITY": "15000.00",
              "IS_MANUAL_OPPORTUNITY": "Y",
              "HAS_PHONE": "Y",
              "HAS_EMAIL": "Y",
              "HAS_IMOL": "N",
              "ASSIGNED_BY_ID": "1",
              "CREATED_BY_ID": "1",
              "MODIFY_BY_ID": "1",
              "DATE_CREATE": "2021-05-31T15:10:16+02:00",
              "DATE_MODIFY": "2021-11-26T18:56:13+02:00",
              "DATE_CLOSED": "2021-07-16T16:43:44+02:00",
              "STATUS_SEMANTIC_ID": "S",
              "OPENED": "Y",
              "ORIGINATOR_ID": null,
              "ORIGIN_ID": null,
              "MOVED_BY_ID": "1",
              "MOVED_TIME": "2021-07-16T16:43:44+02:00",
              "ADDRESS": "7677 Hollow Ridge Alley",
              "ADDRESS_2": null,
              "ADDRESS_CITY": null,
              "ADDRESS_POSTAL_CODE": null,
              "ADDRESS_REGION": null,
              "ADDRESS_PROVINCE": null,
              "ADDRESS_COUNTRY": "Indonesia",
              "ADDRESS_COUNTRY_CODE": null,
              "ADDRESS_LOC_ADDR_ID": "1",
              "UTM_SOURCE": null,
              "UTM_MEDIUM": null,
              "UTM_CAMPAIGN": null,
              "UTM_CONTENT": null,
              "UTM_TERM": null,
              "LAST_ACTIVITY_BY": "1",
              "LAST_ACTIVITY_TIME": "2021-05-31T15:10:16+02:00",
              "UF_CRM_1704817278": null,
              "UF_CRM_1706782596092": null,
              "UF_CRM_1708952993785": false
            },
            {
              "ID": "6",
              "TITLE": "Lead 2",
              "HONORIFIC": null,
              "NAME": "Ignacius",
              "SECOND_NAME": null,
              "LAST_NAME": "Slayny",
              "COMPANY_TITLE": null,
              "COMPANY_ID": "0",
              "CONTACT_ID": "2070",
              "IS_RETURN_CUSTOMER": "N",
              "BIRTHDATE": "",
              "SOURCE_ID": "CALL",
              "SOURCE_DESCRIPTION": null,
              "STATUS_ID": "CONVERTED",
              "STATUS_DESCRIPTION": null,
              "POST": null,
              "COMMENTS": null,
              "CURRENCY_ID": "USD",
              "OPPORTUNITY": "15000.00",
              "IS_MANUAL_OPPORTUNITY": "Y",
              "HAS_PHONE": "Y",
              "HAS_EMAIL": "Y",
              "HAS_IMOL": "N",
              "ASSIGNED_BY_ID": "1",
              "CREATED_BY_ID": "1",
              "MODIFY_BY_ID": "1",
              "DATE_CREATE": "2021-05-31T15:10:16+02:00",
              "DATE_MODIFY": "2021-11-26T18:56:13+02:00",
              "DATE_CLOSED": "2021-07-16T16:43:47+02:00",
              "STATUS_SEMANTIC_ID": "S",
              "OPENED": "Y",
              "ORIGINATOR_ID": null,
              "ORIGIN_ID": null,
              "MOVED_BY_ID": "1",
              "MOVED_TIME": "2021-07-16T16:43:47+02:00",
              "ADDRESS": "35 Mosinee Street",
              "ADDRESS_2": null,
              "ADDRESS_CITY": null,
              "ADDRESS_POSTAL_CODE": null,
              "ADDRESS_REGION": null,
              "ADDRESS_PROVINCE": null,
              "ADDRESS_COUNTRY": "Japan",
              "ADDRESS_COUNTRY_CODE": null,
              "ADDRESS_LOC_ADDR_ID": "2",
              "UTM_SOURCE": null,
              "UTM_MEDIUM": null,
              "UTM_CAMPAIGN": null,
              "UTM_CONTENT": null,
              "UTM_TERM": null,
              "LAST_ACTIVITY_BY": "1",
              "LAST_ACTIVITY_TIME": "2021-05-31T15:10:16+02:00",
              "UF_CRM_1704817278": null,
              "UF_CRM_1706782596092": null,
              "UF_CRM_1708952993785": true
            },
            
              48 more leads with similar structure
            
          ],
          "next": 50,
          "total": 654,
          "time": {
            "start": 1718292234.554781,
            "finish": 1718292234.657739,
            "duration": 0.10295796394348145,
            "processing": 0.05574321746826172,
            "date_start": "2024-06-13T18:23:54+02:00",
            "date_finish": "2024-06-13T18:23:54+02:00",
            "operating": 0
          }
        }
        

Returned Data

Name
type

Description

result
array

The root element of the response. Contains an array of objects with information about the fields of deals.

Note that the structure of the fields may change due to the select parameter.

For information about the structure of a lead, see the method crm.lead.get

total
integer

The total number of found items

next
integer

Contains the value to be passed in the next request in the start parameter to get the next batch of data.

The next parameter appears in the response if the number of items matching your request exceeds 50

time
time

Information about the execution time of the request

Error Handling

HTTP Status: 40x, 50x Error

{
            "error": "",
            "error_description": "Access denied."
        }
        

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 Errors

Error Text

Description

Access denied

The user does not have permission to read leads

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