Get a list of deals crm.deal.list

Scope: crm

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

Method Development Stopped

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

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

Method Parameters

Name
type

Description

select
string[]

List of fields that should be populated for deals in the selection.

You can use the following masks for selection:

  • '*' — to select all fields (excluding custom and multiple fields)
  • 'UF_*' — to select all custom fields (excluding multiple fields)

You can find the list of available fields for selection using the method crm.deal.fields.
The method does not support the field CONTACT_IDS; to get deals with a list of contacts, use the method crm.item.list.

By default, all fields are taken — '*' + Custom fields — 'UF_*'

filter
object

Object format:

{
            field_1: value_1,
            field_2: value_2,
            ...,
            field_n: value_n,
        }
        

where:

  • field_n — the name of the field by which the selection of elements will be filtered
  • value_n — the filter value

You can add a prefix to the keys field_n to clarify the filter operation.
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 % character in the filter value should not be passed. The search looks for a substring in any position of the string
  • =% — LIKE, substring search. The % character should be passed in the value. Examples:
    • "mol%" — searches for values starting with "mol"
    • "%mol" — searches for values ending with "mol"
    • "%mol%" — searches for values where "mol" can be in any position
  • %= — LIKE (similar to =%)
  • = — equal, exact match (used by default)
  • != — not equal
  • ! — not equal

The LIKE filter does not work with fields of type crm_status, crm_contact, crm_company (deal type TYPE_ID, stage STAGE_ID, etc.).

You can find the list of available fields for filtering using the method crm.deal.fields.

The filter does not support the field CONTACT_IDS; to filter by contacts, use the method crm.item.list

order
object

Object format:

{
            field_1: value_1,
            field_2: value_2,
            ...,
            field_n: value_n,
        }
        

where:

  • field_n — the name of the field by which the selection of deals will be sorted
  • value_n — a string value equal to:
    • ASC — ascending sort
    • DESC — descending sort

You can find the list of available fields for sorting using the method crm.deal.fields

start
integer

This parameter is used to manage pagination.

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

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

The formula for calculating the start parameter value:

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

Get a list of deals where:

  1. the funnel ID equals 1
  2. the deal type equals COMPLEX
  3. the title ends with a
  4. the stage equals C1:NEW
  5. the amount is greater than 10000 but less than or equal to 20000
  6. manual mode for amount calculation is enabled
  7. the responsible person is either the user with id = 1 or the user with id = 6
  8. the deal was created at least 6 months ago

Set the following sort order for this selection: title and amount in ascending order.

For clarity, select only the necessary fields:

  • Identifier ID
  • Title TITLE
  • Deal type TYPE_ID
  • Funnel ID CATEGORY_ID
  • Stage STAGE_ID
  • Amount OPPORTUNITY
  • Is manual mode enabled IS_MANUAL_OPPORTUNITY
  • Responsible ASSIGNED_BY_ID
  • Creation date DATE_CREATE
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"SELECT":["ID","TITLE","TYPE_ID","CATEGORY_ID","STAGE_ID","OPPORTUNITY","IS_MANUAL_OPPORTUNITY","ASSIGNED_BY_ID","DATE_CREATE"],"FILTER":{"=%TITLE":"%a","CATEGORY_ID":1,"TYPE_ID":"COMPLEX","STAGE_ID":"C1:NEW",">OPPORTUNITY":10000,"<=OPPORTUNITY":20000,"IS_MANUAL_OPPORTUNITY":"Y","@ASSIGNED_BY_ID":[1,6],">DATE_CREATE":"'"$(date --date='-6 months' +%Y-%m-%d)"'"},"ORDER":{"TITLE":"ASC","OPPORTUNITY":"ASC"}}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.deal.list
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"SELECT":["ID","TITLE","TYPE_ID","CATEGORY_ID","STAGE_ID","OPPORTUNITY","IS_MANUAL_OPPORTUNITY","ASSIGNED_BY_ID","DATE_CREATE"],"FILTER":{"=%TITLE":"%a","CATEGORY_ID":1,"TYPE_ID":"COMPLEX","STAGE_ID":"C1:NEW",">OPPORTUNITY":10000,"<=OPPORTUNITY":20000,"IS_MANUAL_OPPORTUNITY":"Y","@ASSIGNED_BY_ID":[1,6],">DATE_CREATE":"'"$(date --date='-6 months' +%Y-%m-%d)"'"},"ORDER":{"TITLE":"ASC","OPPORTUNITY":"ASC"},"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.deal.list
        
// callListMethod: Retrieves all data at once. Use only for small selections (< 1000 items) due to high memory usage.
        
        const now = new Date();
        const sixMonthAgo = new Date();
        sixMonthAgo.setMonth(now.getMonth() - 6);
        
        try {
          const response = await $b24.callListMethod(
            'crm.deal.list',
            {
              select: [
                'ID',
                'TITLE',
                'TYPE_ID',
                'CATEGORY_ID',
                'STAGE_ID',
                'OPPORTUNITY',
                'IS_MANUAL_OPPORTUNITY',
                'ASSIGNED_BY_ID',
                'DATE_CREATE',
              ],
              filter: {
                '=%TITLE': '%а',
                CATEGORY_ID: 1,
                TYPE_ID: 'COMPLEX',
                STAGE_ID: 'C1:NEW',
                '>OPPORTUNITY': 10000,
                '<=OPPORTUNITY': 20000,
                IS_MANUAL_OPPORTUNITY: 'Y',
                '@ASSIGNED_BY_ID': [1, 6],
                '>DATE_CREATE': sixMonthAgo,
              },
              order: {
                TITLE: 'ASC',
                OPPORTUNITY: 'ASC',
              },
            },
            (result) => {
              result.error()
                ? console.error(result.error())
                : console.info(result.data())
              ;
            },
          );
        } catch (error) {
          console.error('Request failed', error);
        }
        
        // fetchListMethod: Retrieves data in parts using an iterator. Use it for large data volumes to optimize memory usage.
        
        const now = new Date();
        const sixMonthAgo = new Date();
        sixMonthAgo.setMonth(now.getMonth() - 6);
        
        try {
          const generator = $b24.fetchListMethod('crm.deal.list', {
            select: [
              'ID',
              'TITLE',
              'TYPE_ID',
              'CATEGORY_ID',
              'STAGE_ID',
              'OPPORTUNITY',
              'IS_MANUAL_OPPORTUNITY',
              'ASSIGNED_BY_ID',
              'DATE_CREATE',
            ],
            filter: {
              '=%TITLE': '%а',
              CATEGORY_ID: 1,
              TYPE_ID: 'COMPLEX',
              STAGE_ID: 'C1:NEW',
              '>OPPORTUNITY': 10000,
              '<=OPPORTUNITY': 20000,
              IS_MANUAL_OPPORTUNITY: 'Y',
              '@ASSIGNED_BY_ID': [1, 6],
              '>DATE_CREATE': sixMonthAgo,
            },
            order: {
              TITLE: 'ASC',
              OPPORTUNITY: 'ASC',
            },
          }, 'ID');
          for await (const page of generator) {
            for (const entity of page) {
              console.log('Entity:', entity);
            }
          }
        } catch (error) {
          console.error('Request failed', error);
        }
        
        // callMethod: Manually controls pagination through the start parameter. Use it for precise control of request batches. For large datasets, it is less efficient than fetchListMethod.
        
        const now = new Date();
        const sixMonthAgo = new Date();
        sixMonthAgo.setMonth(now.getMonth() - 6);
        
        try {
          const response = await $b24.callMethod('crm.deal.list', {
            select: [
              'ID',
              'TITLE',
              'TYPE_ID',
              'CATEGORY_ID',
              'STAGE_ID',
              'OPPORTUNITY',
              'IS_MANUAL_OPPORTUNITY',
              'ASSIGNED_BY_ID',
              'DATE_CREATE',
            ],
            filter: {
              '=%TITLE': '%а',
              CATEGORY_ID: 1,
              TYPE_ID: 'COMPLEX',
              STAGE_ID: 'C1:NEW',
              '>OPPORTUNITY': 10000,
              '<=OPPORTUNITY': 20000,
              IS_MANUAL_OPPORTUNITY: 'Y',
              '@ASSIGNED_BY_ID': [1, 6],
              '>DATE_CREATE': sixMonthAgo,
            },
            order: {
              TITLE: 'ASC',
              OPPORTUNITY: 'ASC',
            },
          }, 0);
          const result = response.getData().result || [];
          for (const entity of result) {
            console.log('Entity:', entity);
          }
        } catch (error) {
          console.error('Request failed', error);
        }
        
try {
            $response = $b24Service
                ->core
                ->call(
                    'crm.deal.list',
                    [
                        'select' => [
                            'ID',
                            'TITLE',
                            'TYPE_ID',
                            'CATEGORY_ID',
                            'STAGE_ID',
                            'OPPORTUNITY',
                            'IS_MANUAL_OPPORTUNITY',
                            'ASSIGNED_BY_ID',
                            'DATE_CREATE',
                        ],
                        'filter' => [
                            '=%TITLE'              => '%а',
                            'CATEGORY_ID'          => 1,
                            'TYPE_ID'              => 'COMPLEX',
                            'STAGE_ID'             => 'C1:NEW',
                            '>OPPORTUNITY'         => 10000,
                            '<=OPPORTUNITY'        => 20000,
                            'IS_MANUAL_OPPORTUNITY' => 'Y',
                            '@ASSIGNED_BY_ID'      => [1, 6],
                            '>DATE_CREATE'         => $sixMonthAgo,
                        ],
                        'order' => [
                            'TITLE'       => 'ASC',
                            'OPPORTUNITY' => 'ASC',
                        ],
                    ]
                );
        
            $result = $response
                ->getResponseData()
                ->getResult();
        
            if ($result->error()) {
                echo 'Error: ' . $result->error();
            } else {
                echo 'Data: ' . print_r($result->data(), true);
            }
        
        } catch (Throwable $e) {
            error_log($e->getMessage());
            echo 'Error fetching deal list: ' . $e->getMessage();
        }
        
const now = new Date();
        const sixMonthAgo = new Date();
        sixMonthAgo.setMonth(now.getMonth() - 6);
        
        BX24.callMethod(
            'crm.deal.list',
            {
                select: [
                    'ID',
                    'TITLE',
                    'TYPE_ID',
                    'CATEGORY_ID',
                    'STAGE_ID',
                    'OPPORTUNITY',
                    'IS_MANUAL_OPPORTUNITY',
                    'ASSIGNED_BY_ID',
                    'DATE_CREATE',
                ],
                filter: {
                    '=%TITLE': '%а',
                    CATEGORY_ID: 1,
                    TYPE_ID: 'COMPLEX',
                    STAGE_ID: 'C1:NEW',
                    '>OPPORTUNITY': 10000,
                    '<=OPPORTUNITY': 20000,
                    IS_MANUAL_OPPORTUNITY: 'Y',
                    '@ASSIGNED_BY_ID': [1, 6],
                    '>DATE_CREATE': sixMonthAgo,
                },
                order: {
                    TITLE: 'ASC',
                    OPPORTUNITY: 'ASC',
                },
            },
            (result) => {
                result.error()
                    ? console.error(result.error())
                    : console.info(result.data())
                ;
            },
        );
        
require_once('crest.php');
        
        $sixMonthAgo = (new DateTime())->modify('-6 months')->format('Y-m-d');
        
        $result = CRest::call(
            'crm.deal.list',
            [
                'SELECT' => [
                    'ID',
                    'TITLE',
                    'TYPE_ID',
                    'CATEGORY_ID',
                    'STAGE_ID',
                    'OPPORTUNITY',
                    'IS_MANUAL_OPPORTUNITY',
                    'ASSIGNED_BY_ID',
                    'DATE_CREATE',
                ],
                'FILTER' => [
                    '=%TITLE' => '%а',
                    'CATEGORY_ID' => 1,
                    'TYPE_ID' => 'COMPLEX',
                    'STAGE_ID' => 'C1:NEW',
                    '>OPPORTUNITY' => 10000,
                    '<=OPPORTUNITY' => 20000,
                    'IS_MANUAL_OPPORTUNITY' => 'Y',
                    '@ASSIGNED_BY_ID' => [1, 6],
                    '>DATE_CREATE' => $sixMonthAgo,
                ],
                'ORDER' => [
                    'TITLE' => 'ASC',
                    'OPPORTUNITY' => 'ASC',
                ],
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Response Handling

HTTP status: 200

{
            "result": [
                {
                    "ID": "37",
                    "TITLE": "[A] Deal",
                    "TYPE_ID": "COMPLEX",
                    "CATEGORY_ID": "1",
                    "STAGE_ID": "C1:NEW",
                    "OPPORTUNITY": "19999.99",
                    "IS_MANUAL_OPPORTUNITY": "Y",
                    "ASSIGNED_BY_ID": "1",
                    "DATE_CREATE": "2024-09-02T18:37:18+02:00"
                },
                {
                    "ID": "38",
                    "TITLE": "[A] Deal",
                    "TYPE_ID": "COMPLEX",
                    "CATEGORY_ID": "1",
                    "STAGE_ID": "C1:NEW",
                    "OPPORTUNITY": "20000.00",
                    "IS_MANUAL_OPPORTUNITY": "Y",
                    "ASSIGNED_BY_ID": "6",
                    "DATE_CREATE": "2024-09-02T18:37:38+02:00"
                },
                {
                    "ID": "39",
                    "TITLE": "[B] Sale",
                    "TYPE_ID": "COMPLEX",
                    "CATEGORY_ID": "1",
                    "STAGE_ID": "C1:NEW",
                    "OPPORTUNITY": "12500.00",
                    "IS_MANUAL_OPPORTUNITY": "Y",
                    "ASSIGNED_BY_ID": "1",
                    "DATE_CREATE": "2024-04-09T23:11:01+02:00"
                },
                {
                    "ID": "40",
                    "TITLE": "[B] Deal",
                    "TYPE_ID": "COMPLEX",
                    "CATEGORY_ID": "1",
                    "STAGE_ID": "C1:NEW",
                    "OPPORTUNITY": "13500.00",
                    "IS_MANUAL_OPPORTUNITY": "Y",
                    "ASSIGNED_BY_ID": "6",
                    "DATE_CREATE": "2024-08-08T19:00:14+02:00"
                },
                {
                    "ID": "41",
                    "TITLE": "[C] Deal",
                    "TYPE_ID": "COMPLEX",
                    "CATEGORY_ID": "1",
                    "STAGE_ID": "C1:NEW",
                    "OPPORTUNITY": "11500.00",
                    "IS_MANUAL_OPPORTUNITY": "Y",
                    "ASSIGNED_BY_ID": "6",
                    "DATE_CREATE": "2024-05-08T09:38:23+02:00"
                },
                {
                    "ID": "42",
                    "TITLE": "[D] Deal",
                    "TYPE_ID": "COMPLEX",
                    "CATEGORY_ID": "1",
                    "STAGE_ID": "C1:NEW",
                    "OPPORTUNITY": "18500.00",
                    "IS_MANUAL_OPPORTUNITY": "Y",
                    "ASSIGNED_BY_ID": "6",
                    "DATE_CREATE": "2024-07-02T15:38:32+02:00"
                }
            ],
            "total": 6,
            "time": {
                "start": 1725292115.026221,
                "finish": 1725292115.907058,
                "duration": 0.8808369636535645,
                "processing": 0.2484450340270996,
                "date_start": "2024-09-02T17:48:35+02:00",
                "date_finish": "2024-09-02T17:48:35+02:00",
                "operating": 0
            }
        }
        

Returned Data

Name
type

Description

result
deal[]

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

It should be noted that the structure of fields may change due to the select parameter

total
integer

The total number of found items

next
integer

Contains the value that needs 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: 400

{
            "error": "",
            "error_description": "Parameter 'filter' must be array."
        }
        

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

Code

Description

Value

-

Access denied

The user does not have permission to "read" deals

-

Parameter 'order' must be array

A non-object was passed to the order parameter

-

Parameter 'filter' must be array

A non-object was passed to the filter parameter

-

Failed to get list. General error

An unknown error occurred

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