Get the list of activities crm.activity.list

Scope: crm

Who can execute the method: any user

The method crm.activity.list returns a list of activities based on the filter, considering the access permissions of the current user.

Method Parameters

Required parameters are marked with *

Name
type

Description

select
array

An array of fields of the activity crm.activity.fields that need to be selected. To get the fields COMMUNICATIONS and FILES, specify them in select.

filter
object

An object for filtering the selected items in key-value format.

Possible values for field correspond to the fields of the activity crm.activity.fields.

An additional prefix can be assigned to the key to clarify the filter's behavior. Possible prefix values:

  • >= — greater than or equal to
  • > — greater than
  • <= — less than or equal to
  • < — less than
  • @ — IN (an array is passed as a value)
  • !@— NOT IN (an array is passed as a value)
  • % — LIKE, substring search. The % symbol in the filter value does not need to be passed. The search looks for a substring in any position of the string.
  • =% — LIKE, substring search. The % symbol needs to 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 does not need to be passed. The search goes from both sides.
  • =% — NOT LIKE, substring search. The % symbol needs to 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
object

A set of key-value pairs for sorting the output results. The keys can use the fields of the activity crm.activity.fields.

Possible values for order:

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

By default, it is sorted by increasing the Start Date field (START_TIME)

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

See the description of list methods.

Pay attention to the peculiarity of the parameter filter[BINDINGS].

Activity can be linked to multiple CRM entities. For example, a call can be linked to both a lead and an activity, so to retrieve these entities, there is a special filter key in the parameters of the method crm.activity.list - BINDINGS.

You need to specify an array of system or custom types of CRM objects for which you need to find the binding.

Each object can consist of the keys OWNER_TYPE_ID (entity type identifier) and OWNER_ID (entity identifier), either one or a combination of both. For example:

"BINDINGS": [
            {"OWNER_TYPE_ID": 2},
            {"OWNER_TYPE_ID": 3}
        ]
        

Code Examples

How to Use Examples in Documentation

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"order":{"ID":"DESC"},"filter":{"OWNER_TYPE_ID":3,"OWNER_ID":102},"select":["*","COMMUNICATIONS"]}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.activity.list
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"order":{"ID":"DESC"},"filter":{"OWNER_TYPE_ID":3,"OWNER_ID":102},"select":["*","COMMUNICATIONS"],"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.activity.list
        

In this example, we retrieve the list of activities for the contact with ID = 102.

BX24.callMethod(
            "crm.activity.list",
            {
                order: { "ID": "DESC" },
                filter:
                {
                    "OWNER_TYPE_ID": 3,
                    "OWNER_ID": 102
                },
                select: [ "*", "COMMUNICATIONS" ]
            },
            function(result)
            {
                if(result.error())
                    console.error(result.error());
                else
                {
                    console.dir(result.data());
                    if(result.more())
                        result.next();
                }
            }
        );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.activity.list',
            [
                'order' => [ 'ID' => 'DESC' ],
                'filter' => [
                    'OWNER_TYPE_ID' => 3,
                    'OWNER_ID' => 102
                ],
                'select' => [ '*', 'COMMUNICATIONS' ]
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Response Handling

HTTP status: 200

{
            "result": [
                {
                    "ID": "20",
                    "OWNER_ID": "15",
                    "OWNER_TYPE_ID": "3",
                    "TYPE_ID": "2",
                    "PROVIDER_ID": "VOXIMPLANT_CALL",
                    "PROVIDER_TYPE_ID": "CALL",
                    "PROVIDER_GROUP_ID": null,
                    "ASSOCIATED_ENTITY_ID": "0",
                    "SUBJECT": "Outgoing call Nicholas Mitchell",
                    "CREATED": "2020-09-27T13:26:55+03:00",
                    "LAST_UPDATED": "2021-03-21T20:28:24+03:00",
                    "START_TIME": "2020-09-27T13:25:00+03:00",
                    "END_TIME": "2020-09-27T19:25:00+03:00",
                    "DEADLINE": "2020-09-27T13:25:00+03:00",
                    "COMPLETED": "Y",
                    "STATUS": "2",
                    "RESPONSIBLE_ID": "505",
                    "PRIORITY": "2",
                    "NOTIFY_TYPE": "1",
                    "NOTIFY_VALUE": "15",
                    "DESCRIPTION": "",
                    "DESCRIPTION_TYPE": "1",
                    "DIRECTION": "2",
                    "LOCATION": "",
                    "SETTINGS": [],
                    "ORIGINATOR_ID": null,
                    "ORIGIN_ID": null,
                    "AUTHOR_ID": "505",
                    "EDITOR_ID": "505",
                    "PROVIDER_PARAMS": [],
                    "PROVIDER_DATA": null,
                    "RESULT_MARK": "0",
                    "RESULT_VALUE": null,
                    "RESULT_SUM": null,
                    "RESULT_CURRENCY_ID": null,
                    "RESULT_STATUS": "0",
                    "RESULT_STREAM": "0",
                    "RESULT_SOURCE_ID": null,
                    "AUTOCOMPLETE_RULE": "0"
                },
                // .. 49 more items
            ],
            "next": 50,
            "total": 123456,
            "time": {
                "start": 1724677896.295857,
                "finish": 1724677897.197243,
                "duration": 0.901386022567749,
                "processing": 0.8762130737304688,
                "date_start": "2024-08-26T16:11:36+03:00",
                "date_finish": "2024-08-26T16:11:37+03:00",
                "operating_reset_at": "2024-08-26T16:11:37+03:00",
                "operating": 0.0162130737304688
            }
        }
        

Returned Data

Name
type

Description

result
boolean

The result of the operation. An array of activitys. For information about the structure of an activity, see the method crm.activity.fields

time
time

Information about the execution time of the request

Error Handling

HTTP status: 400, 403

{
            "error": "INVALID_REQUEST",
            "error_description": "Https required"
        }
        

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

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

Private Examples

How to Use Examples in Documentation

Using BINDINGS

Retrieve fields: Identifier, Name, Owner Type (Entity Type Identifier), Owner (Entity Identifier)

Selection condition: the activity is linked to both a deal and a contact

Note

When using multiple pairs in BINDINGS, duplication may occur in the results. For example, in the result of executing the code example below, the activity linked to both entities will be output twice.

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"order":{"ID":"DESC"},"filter":{"BINDINGS":[{"OWNER_TYPE_ID":2},{"OWNER_TYPE_ID":3}]},"select":["*","COMMUNICATIONS"]}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.activity.list
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"order":{"ID":"DESC"},"filter":{"BINDINGS":[{"OWNER_TYPE_ID":2},{"OWNER_TYPE_ID":3}]},"select":["*","COMMUNICATIONS"],"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.activity.list
        
BX24.callMethod(
                "crm.activity.list",
                {
                    order: { "ID": "DESC" },
                    filter:
                    {
                        "BINDINGS": [
                            {"OWNER_TYPE_ID": 2},
                            {"OWNER_TYPE_ID": 3}
                        ]
                    },
                    select: [ "*", "COMMUNICATIONS" ]
                },
                function(result)
                {
                    if(result.error())
                        console.error(result.error());
                    else
                    {
                        console.dir(result.data());
                        if(result.more())
                            result.next();
                    }
                }
            );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.activity.list',
            [
                'order' => ['ID' => 'DESC'],
                'filter' => [
                    'BINDINGS' => [
                        ['OWNER_TYPE_ID' => 2],
                        ['OWNER_TYPE_ID' => 3]
                    ]
                ],
                'select' => ['*', 'COMMUNICATIONS']
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Retrieving COMMUNICATIONS

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"filter":{"ID":"20"},"select":["*","COMMUNICATIONS"]}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.activity.list
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"filter":{"ID":"20"},"select":["*","COMMUNICATIONS"],"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.activity.list
        
BX24.callMethod(
                "crm.activity.list",
                {
                    filter:
                    {
                        "ID": '20'
                    },
                    select: [ "*", "COMMUNICATIONS" ]
                },
                function(result)
                {
                    if(result.error())
                        console.error(result.error());
                    else
                    {
                        console.dir(result.data());
                        if(result.more())
                            result.next();
                    }
                }
            );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.activity.list',
            [
                'filter' => [
                    'ID' => '20'
                ],
                'select' => ['*', 'COMMUNICATIONS']
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Example of Returned Data

HTTP status: 200

{
            "result": [
                {
                "ID": "20",
                "COMMUNICATIONS": [
                    {
                        "ID": "23",
                        "TYPE": "PHONE",
                        "VALUE": "19152222222",
                        "ENTITY_ID": "15",
                        "ENTITY_TYPE_ID": "3",
                        "ENTITY_SETTINGS": {
                            "HONORIFIC": "1",
                            "NAME": "Andrew ",
                            "SECOND_NAME": "Nikolaev",
                            "LAST_NAME": "",
                            "COMPANY_TITLE": "Ltd. Fusion",
                            "COMPANY_ID": "21"
                        }
                    }
                ]
            }
            ],
            "total": 1,
            "time": {
                "start": 1724659407.69855,
                "finish": 1724659407.723506,
                "duration": 0.02495598793029785,
                "processing": 0.003489971160888672,
                "date_start": "2024-08-26T11:03:27+03:00",
                "date_finish": "2024-08-26T11:03:27+03:00"
            }
        }
        

Retrieving Attachments

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"filter":{"ID":"101121"},"select":["*","STORAGE_ELEMENT_IDS"]}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.activity.list
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"filter":{"ID":"101121"},"select":["*","STORAGE_ELEMENT_IDS"],"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.activity.list
        
BX24.callMethod(
                "crm.activity.list",
                {
                    filter:
                    {
                        "ID": '101121'
                    },
                    select: [ "*", "STORAGE_ELEMENT_IDS" ]
                },
                function(result)
                {
                    if(result.error())
                        console.error(result.error());
                    else
                    {
                        console.dir(result.data());
                        if(result.more())
                            result.next();
                    }
                }
            );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.activity.list',
            [
                'filter' => [
                    'ID' => '101121'
                ],
                'select' => ['*', 'STORAGE_ELEMENT_IDS']
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Example of Returned Data

HTTP status: 200

{
            "result": [
                {
                    "ID": "101121",
                    "FILES": [
                        {
                            "id": 3101820,
                            "url": "http://xxx.bitrix24.com/bitrix/tools/crm_show_file.php?fileId=3101820&ownerTypeId=6&ownerId=101121&auth="
                        }
                    ]
                }
            ],
            "total": 1,
            "time": {
                "start": 1724659652.591025,
                "finish": 1724659652.623784,
                "duration": 0.03275895118713379,
                "processing": 0.00624394416809082,
                "date_start": "2024-08-26T11:07:32+03:00",
                "date_finish": "2024-08-26T11:07:32+03:00"
            }
        }
        

Continue Learning