Importing a Batch of CRM Records: crm.item.batchImport

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 permission to import CRM items

The crm.item.batchImport method imports up to 20 items of the same CRM type.

Pass the fields of each item according to the same rules as in crm.item.import. Import specifics are described in the method overview.

Method Parameters

Required parameters are marked with *

Name
type

Description

entityTypeId*
integer

Identifier of the system or custom CRM type into which the items should be imported.

Numerical values for system types, such as lead — 1, deal — 2, contact — 3, company — 4, and invoice — 31, are provided in the CRM object types reference. You can obtain a SPA identifier using crm.type.list.

data*
array

Array of objects with the fields of the items being imported (detailed description)

useOriginalUfNames
boolean

Parameter to control the format of custom field names in the request.
Possible values:

  • Y — original names of custom fields, e.g., UF_CRM_2_1639669411830
  • N — custom field names in camelCase, e.g., ufCrm2_1639669411830

Default is N.

Parameter data

Each element of the data array is an object containing the fields of one CRM item:

[
            {
                field_1: value_1,
                field_2: value_2
            },
            {
                field_1: value_1,
                field_2: value_2
            }
        ]
        

Field names, types, and formats are described in the fields parameter of crm.item.import.

Code Examples

How to Use Examples in Documentation

  1. How to Import Deals

    curl -X POST \
            -H "Content-Type: application/json" \
            -H "Accept: application/json" \
            -d '{"entityTypeId":2,"data":[{"title":"First imported deal","isRecurring":"N","opportunity":999.99,"currencyId":"EUR"},{"title":"Second imported deal","isRecurring":"N","opportunity":1499.99,"currencyId":"EUR"}]}' \
            https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.item.batchImport
            
    curl -X POST \
            -H "Content-Type: application/json" \
            -H "Accept: application/json" \
            -d '{"entityTypeId":2,"data":[{"title":"First imported deal","isRecurring":"N","opportunity":999.99,"currencyId":"EUR"},{"title":"Second imported deal","isRecurring":"N","opportunity":1499.99,"currencyId":"EUR"}],"auth":"**put_access_token_here**"}' \
            https://**put_your_bitrix24_address**/rest/crm.item.batchImport
            
    import { Text } from '@bitrix24/b24jssdk'
            import type { B24Frame } from '@bitrix24/b24jssdk'
            declare const $b24: B24Frame
            
            const response = await $b24.actions.v2.call.make({
              method: 'crm.item.batchImport',
              params: {
                entityTypeId: 2,
                data: [
                  { title: 'First imported deal', isRecurring: 'N', opportunity: 999.99, currencyId: 'EUR' },
                  { title: 'Second imported deal', isRecurring: 'N', opportunity: 1499.99, currencyId: 'EUR' },
                ],
              },
              requestId: Text.getUuidRfc4122()
            })
            console.info(response.getData()?.result)
            
    <script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
            <script>
              async function batchImportDeals() {
                const $b24 = await B24Js.initializeB24Frame()
                const response = await $b24.actions.v2.call.make({
                  method: 'crm.item.batchImport',
                  params: {
                    entityTypeId: 2,
                    data: [
                      { title: 'First imported deal', isRecurring: 'N', opportunity: 999.99, currencyId: 'EUR' },
                      { title: 'Second imported deal', isRecurring: 'N', opportunity: 1499.99, currencyId: 'EUR' },
                    ],
                  },
                  requestId: B24Js.Text.getUuidRfc4122()
                })
                console.info(response.getData()?.result)
              }
              document.addEventListener('DOMContentLoaded', batchImportDeals)
            </script>
            
    
            from b24pysdk.errors import BitrixAPIError, BitrixSDKException
            
            try:
                bitrix_response = client.crm.item.batch_import(
                    entity_type_id=2,
                    data=[
                        {
                            "title": "First imported deal",
                            "isRecurring": "N",
                            "opportunity": 999.99,
                            "currencyId": "EUR",
                        },
                        {
                            "title": "Second imported deal",
                            "isRecurring": "N",
                            "opportunity": 1499.99,
                            "currencyId": "EUR",
                        },
                    ],
                ).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}")
            
    try {
                $response = $b24Service->core->call(
                    'crm.item.batchImport',
                    [
                        'entityTypeId' => 2,
                        'data' => [
                            ['title' => 'First imported deal', 'isRecurring' => 'N', 'opportunity' => 999.99, 'currencyId' => 'EUR'],
                            ['title' => 'Second imported deal', 'isRecurring' => 'N', 'opportunity' => 1499.99, 'currencyId' => 'EUR'],
                        ],
                    ]
                );
                echo 'Success: ' . print_r($response->getResponseData()->getResult()->data(), true);
            } catch (Throwable $e) {
                echo 'Error: ' . $e->getMessage();
            }
            
    BX24.callMethod(
                'crm.item.batchImport',
                {
                    entityTypeId: 2,
                    data: [
                        {
                            title: 'First imported deal',
                            isRecurring: 'N',
                            opportunity: 999.99,
                            currencyId: 'EUR',
                        },
                        {
                            title: 'Second imported deal',
                            isRecurring: 'N',
                            opportunity: 1499.99,
                            currencyId: 'EUR',
                        },
                    ],
                },
                result => result.error() ? console.error(result.error()) : console.info(result.data())
            );
            
    require_once('crest.php');
            
            $result = CRest::call(
                'crm.item.batchImport',
                [
                    'entityTypeId' => 2,
                    'data' => [
                        ['title' => 'First imported deal', 'isRecurring' => 'N', 'opportunity' => 999.99, 'currencyId' => 'EUR'],
                        ['title' => 'Second imported deal', 'isRecurring' => 'N', 'opportunity' => 1499.99, 'currencyId' => 'EUR'],
                    ],
                ]
            );
            
            print_r($result);
            
    // client and ctx are already created — see the Go SDK section
            res, err := client.Core().Call(ctx, "crm.item.batchImport", b24.Params{
                "entityTypeId": 2,
                "data": []b24.Params{
                    {"title": "First imported deal", "isRecurring": "N", "opportunity": 999.99, "currencyId": "EUR"},
                    {"title": "Second imported deal", "isRecurring": "N", "opportunity": 1499.99, "currencyId": "EUR"},
                },
            })
            if err != nil {
                return fmt.Errorf("crm.item.batchImport: %w", err)
            }
            
            raw, ok := b24.Unwrap(res.Result, "items")
            if !ok {
                return fmt.Errorf("items key is missing from the response")
            }
            fmt.Printf("%s\n", raw)
            
  2. How to Create an SPA Element with a Set of Custom Fields

    Custom fields involved in the example
    {
                "ufCrm44_1721812760630": {
                    "type": "string",
                    "isRequired": false,
                    "isReadOnly": false,
                    "isImmutable": false,
                    "isMultiple": false,
                    "isDynamic": true,
                    "title": "Custom field (string)",
                    "listLabel": "Custom field (string)",
                    "formLabel": "Custom field (string)",
                    "filterLabel": "Custom field (string)",
                    "settings": {
                        "SIZE": 20,
                        "ROWS": 1,
                        "REGEXP": "",
                        "MIN_LENGTH": 0,
                        "MAX_LENGTH": 0,
                        "DEFAULT_VALUE": ""
                    },
                    "upperName": "UF_CRM_44_1721812760630"
                },
                "ufCrm44_1721812814433": {
                    "type": "enumeration",
                    "isRequired": false,
                    "isReadOnly": false,
                    "isImmutable": false,
                    "isMultiple": false,
                    "isDynamic": true,
                    "items": [
                        {
                            "ID": "79",
                            "VALUE": "List item #1"
                        },
                        {
                            "ID": "80",
                            "VALUE": "List item #2"
                        },
                        {
                            "ID": "81",
                            "VALUE": "List item #3"
                        },
                        {
                            "ID": "82",
                            "VALUE": "List item #4"
                        }
                    ],
                    "title": "Custom field (list)",
                    "listLabel": "Custom field (list)",
                    "formLabel": "Custom field (list)",
                    "filterLabel": "Custom field (list)",
                    "settings": {
                        "DISPLAY": "LIST",
                        "LIST_HEIGHT": 1,
                        "CAPTION_NO_VALUE": "",
                        "SHOW_NO_VALUE": "Y"
                    },
                    "upperName": "UF_CRM_44_1721812814433"
                },
                "ufCrm44_1721812853419": {
                    "type": "date",
                    "isRequired": false,
                    "isReadOnly": false,
                    "isImmutable": false,
                    "isMultiple": false,
                    "isDynamic": true,
                    "title": "Custom field (date)",
                    "listLabel": "Custom field (date)",
                    "formLabel": "Custom field (date)",
                    "filterLabel": "Custom field (date)",
                    "settings": {
                        "DEFAULT_VALUE": {
                            "TYPE": "NONE",
                            "VALUE": ""
                        }
                    },
                    "upperName": "UF_CRM_44_1721812853419"
                },
                "ufCrm44_1721812885588": {
                    "type": "url",
                    "isRequired": false,
                    "isReadOnly": false,
                    "isImmutable": false,
                    "isMultiple": true,
                    "isDynamic": true,
                    "title": "Multiple custom field (link)",
                    "listLabel": "Multiple custom field (link)",
                    "formLabel": "Multiple custom field (link)",
                    "filterLabel": "Multiple custom field (link)",
                    "settings": {
                        "POPUP": "Y",
                        "SIZE": 20,
                        "MIN_LENGTH": 0,
                        "MAX_LENGTH": 0,
                        "DEFAULT_VALUE": "",
                        "ROWS": 1
                    },
                    "upperName": "UF_CRM_44_1721812885588"
                },
                "ufCrm44_1721812898903": {
                    "type": "file",
                    "isRequired": false,
                    "isReadOnly": false,
                    "isImmutable": false,
                    "isMultiple": false,
                    "isDynamic": true,
                    "title": "Custom field (file)",
                    "listLabel": "Custom field (file)",
                    "formLabel": "Custom field (file)",
                    "filterLabel": "Custom field (file)",
                    "settings": {
                        "SIZE": 20,
                        "LIST_WIDTH": 0,
                        "LIST_HEIGHT": 0,
                        "MAX_SHOW_SIZE": 0,
                        "MAX_ALLOWED_SIZE": 0,
                        "EXTENSIONS": [],
                        "TARGET_BLANK": "Y"
                    },
                    "upperName": "UF_CRM_44_1721812898903"
                },
                "ufCrm44_1721812915476": {
                    "type": "money",
                    "isRequired": false,
                    "isReadOnly": false,
                    "isImmutable": false,
                    "isMultiple": false,
                    "isDynamic": true,
                    "title": "Custom field (money)",
                    "listLabel": "Custom field (money)",
                    "formLabel": "Custom field (money)",
                    "filterLabel": "Custom field (money)",
                    "settings": {
                        "DEFAULT_VALUE": ""
                    },
                    "upperName": "UF_CRM_44_1721812915476"
                },
                "ufCrm44_1721812935209": {
                    "type": "boolean",
                    "isRequired": false,
                    "isReadOnly": false,
                    "isImmutable": false,
                    "isMultiple": false,
                    "isDynamic": true,
                    "title": "Custom field (Yes/No)",
                    "listLabel": "Custom field (Yes/No)",
                    "formLabel": "Custom field (Yes/No)",
                    "filterLabel": "Custom field (Yes/No)",
                    "settings": {
                        "DEFAULT_VALUE": 0,
                        "DISPLAY": "CHECKBOX",
                        "LABEL": [
                            "",
                            ""
                        ],
                        "LABEL_CHECKBOX": {
                            "en": "Custom field (Yes/No)",
                            "ru": "Custom field (Yes/No)",
                            "th": "Custom field (Yes/No)",
                            "la": "Custom field (Yes/No)",
                            "tc": "Custom field (Yes/No)",
                            "sc": "Custom field (Yes/No)",
                            "br": "Custom field (Yes/No)",
                            "ar": "Custom field (Yes/No)",
                            "fr": "Custom field (Yes/No)",
                            "vn": "Custom field (Yes/No)",
                            "pl": "Custom field (Yes/No)",
                            "tr": "Custom field (Yes/No)",
                            "ja": "Custom field (Yes/No)",
                            "it": "Custom field (Yes/No)",
                            "ms": "Custom field (Yes/No)",
                            "id": "Custom field (Yes/No)"
                        }
                    },
                    "upperName": "UF_CRM_44_1721812935209"
                },
                "ufCrm44_1721812948498": {
                    "type": "double",
                    "isRequired": false,
                    "isReadOnly": false,
                    "isImmutable": false,
                    "isMultiple": false,
                    "isDynamic": true,
                    "title": "Custom field (number)",
                    "listLabel": "Custom field (number)",
                    "formLabel": "Custom field (number)",
                    "filterLabel": "Custom field (number)",
                    "settings": {
                        "PRECISION": 2,
                        "SIZE": 20,
                        "MIN_VALUE": 0,
                        "MAX_VALUE": 0,
                        "DEFAULT_VALUE": null
                    },
                    "upperName": "UF_CRM_44_1721812948498"
                }
            }
            
    curl -X POST \
            -H "Content-Type: application/json" \
            -H "Accept: application/json" \
            -d '{
                "entityTypeId": 1302,
                "data": [{
                    "ufCrm44_1721812760630": "String value for a custom String field",
                    "ufCrm44_1721812814433": 81,
                    "ufCrm44_1721812853419": "2024-08-21",
                    "ufCrm44_1721812885588": [
                        "example.com",
                        "second-example.com"
                    ],
                    "ufCrm44_1721812898903": [
                        "green_pixel.png",
                        "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg=="
                    ],
                    "ufCrm44_1721812915476": "300|EUR",
                    "ufCrm44_1721812935209": "Y",
                    "ufCrm44_1721812948498": 9999.9
                },{
                    "ufCrm44_1721812760630": "String value for a custom String field",
                    "ufCrm44_1721812814433": 45,
                    "ufCrm44_1721812853419": "2024-08-21",
                    "ufCrm44_1721812885588": [
                        "example.com",
                        "second-example.com"
                    ],
                    "ufCrm44_1721812898903": [
                        "green_pixel2.png",
                        "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg=="
                    ],
                    "ufCrm44_1721812915476": "600|EUR",
                    "ufCrm44_1721812935209": "N",
                    "ufCrm44_1721812948498": 9999.9
                }]
            }' \
            https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.item.batchImport
            
    curl -X POST \
            -H "Content-Type: application/json" \
            -H "Accept: application/json" \
            -d '{
                "entityTypeId": 1302,
                "data": [{
                    "ufCrm44_1721812760630": "String value for a custom String field",
                    "ufCrm44_1721812814433": 81,
                    "ufCrm44_1721812853419": "2024-08-21",
                    "ufCrm44_1721812885588": [
                        "example.com",
                        "second-example.com"
                    ],
                    "ufCrm44_1721812898903": [
                        "green_pixel.png",
                        "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg=="
                    ],
                    "ufCrm44_1721812915476": "300|EUR",
                    "ufCrm44_1721812935209": "Y",
                    "ufCrm44_1721812948498": 9999.9
                },{
                    "ufCrm44_1721812760630": "String value for a custom String field",
                    "ufCrm44_1721812814433": 45,
                    "ufCrm44_1721812853419": "2024-08-21",
                    "ufCrm44_1721812885588": [
                        "example.com",
                        "second-example.com"
                    ],
                    "ufCrm44_1721812898903": [
                        "green_pixel2.png",
                        "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg=="
                    ],
                    "ufCrm44_1721812915476": "600|EUR",
                    "ufCrm44_1721812935209": "N",
                    "ufCrm44_1721812948498": 9999.9
                }],
                "auth": "**put_access_token_here**"
            }' \
            https://**put_your_bitrix24_address**/rest/crm.item.batchImport
            
    // 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 } from '@bitrix24/b24jssdk'
            
            declare const $b24: B24Frame
            
            // Shape of the payload returned in result (match the "response handling" section of the page)
            type BatchImportResult = {
              items: Array<
                | { item: { id: number } }
                | { error: string; error_description: string }
              >
            }
            
            const greenPixelInBase64 = "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg=="
            
            try {
              const response = await $b24.actions.v2.call.make<BatchImportResult>({
                method: 'crm.item.batchImport',
                params: {
                  entityTypeId: 1302,
                  data: [
                    {
                      ufCrm44_1721812760630: "String value for a custom String field",
                      ufCrm44_1721812814433: 81,
                      ufCrm44_1721812853419: "2024-08-21",
                      ufCrm44_1721812885588: [
                        "example.com",
                        "second-example.com",
                      ],
                      ufCrm44_1721812898903: [
                        "green_pixel.png",
                        greenPixelInBase64,
                      ],
                      ufCrm44_1721812915476: "300|EUR",
                      ufCrm44_1721812935209: "Y",
                      ufCrm44_1721812948498: 9999.9,
                    },
                    {
                      ufCrm44_1721812760630: "String value for a custom String field",
                      ufCrm44_1721812814433: 45,
                      ufCrm44_1721812853419: "2024-08-21",
                      ufCrm44_1721812885588: [
                        "example.com",
                        "second-example.com",
                      ],
                      ufCrm44_1721812898903: [
                        "green_pixel2.png",
                        greenPixelInBase64,
                      ],
                      ufCrm44_1721812915476: "600|EUR",
                      ufCrm44_1721812935209: "N",
                      ufCrm44_1721812948498: 9999.9,
                    },
                  ],
                },
                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('Imported items:', result.items)
              }
            } 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 batchImportItems() {
                try {
                  // Initialize the SDK inside a Bitrix24 frame
                  const $b24 = await B24Js.initializeB24Frame()
            
                  const greenPixelInBase64 = "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg=="
            
                  const response = await $b24.actions.v2.call.make({
                    method: 'crm.item.batchImport',
                    params: {
                      entityTypeId: 1302,
                      data: [
                        {
                          ufCrm44_1721812760630: "String value for a custom String field",
                          ufCrm44_1721812814433: 81,
                          ufCrm44_1721812853419: "2024-08-21",
                          ufCrm44_1721812885588: [
                            "example.com",
                            "second-example.com",
                          ],
                          ufCrm44_1721812898903: [
                            "green_pixel.png",
                            greenPixelInBase64,
                          ],
                          ufCrm44_1721812915476: "300|EUR",
                          ufCrm44_1721812935209: "Y",
                          ufCrm44_1721812948498: 9999.9,
                        },
                        {
                          ufCrm44_1721812760630: "String value for a custom String field",
                          ufCrm44_1721812814433: 45,
                          ufCrm44_1721812853419: "2024-08-21",
                          ufCrm44_1721812885588: [
                            "example.com",
                            "second-example.com",
                          ],
                          ufCrm44_1721812898903: [
                            "green_pixel2.png",
                            greenPixelInBase64,
                          ],
                          ufCrm44_1721812915476: "600|EUR",
                          ufCrm44_1721812935209: "N",
                          ufCrm44_1721812948498: 9999.9,
                        },
                      ],
                    },
                    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('Imported items:', result.items)
                } catch (error) {
                  // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
                  console.error(error)
                }
              }
            
              document.addEventListener('DOMContentLoaded', batchImportItems)
            </script>
            
    
            from b24pysdk.errors import BitrixAPIError, BitrixSDKException
            
            try:
                bitrix_response = client.crm.item.batch_import(
                    entity_type_id=1302,
                    data=[
                        {
                        "ufCrm44_1721812760630": "String for a custom field of the String type",
                        "ufCrm44_1721812814433": 81,
                        "ufCrm44_1721812853419": "2024-08-21",
                        "ufCrm44_1721812885588": [
                            "example.com",
                            "second-example.com",
                        ],
                        "ufCrm44_1721812898903": [
                            "green_pixel.png",
                            "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg==",
                        ],
                        "ufCrm44_1721812915476": "300|EUR",
                        "ufCrm44_1721812935209": "Y",
                        "ufCrm44_1721812948498": 9999.9,
                    },
                        {
                        "ufCrm44_1721812760630": "String for a custom field of the String type",
                        "ufCrm44_1721812814433": 45,
                        "ufCrm44_1721812853419": "2024-08-21",
                        "ufCrm44_1721812885588": [
                            "example.com",
                            "second-example.com",
                        ],
                        "ufCrm44_1721812898903": [
                            "green_pixel2.png",
                            "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg==",
                        ],
                        "ufCrm44_1721812915476": "600|EUR",
                        "ufCrm44_1721812935209": "N",
                        "ufCrm44_1721812948498": 9999.9,
                    },
                    ],
                ).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}")
            
    require_once('crest.php');
            
            $result = CRest::call(
                'crm.item.batchImport',
                [
                    'entityTypeId' => 1302,
                    'data' => [
                        [
                            'ufCrm44_1721812760630' => "String value for a custom String field",
                            'ufCrm44_1721812814433' => 81,
                            'ufCrm44_1721812853419' => '2024-08-21',
                            'ufCrm44_1721812885588' => [
                                "example.com",
                                "second-example.com",
                            ],
                            'ufCrm44_1721812898903' => [
                                "green_pixel.png",
                                "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg==",
                            ],
                            'ufCrm44_1721812915476' => "300|EUR",
                            'ufCrm44_1721812935209' => "Y",
                            'ufCrm44_1721812948498' => 9999.9,
                        ],
                        [
                            'ufCrm44_1721812760630' => "String value for a custom String field",
                            'ufCrm44_1721812814433' => 45,
                            'ufCrm44_1721812853419' => '2024-08-21',
                            'ufCrm44_1721812885588' => [
                                "example.com",
                                "second-example.com",
                            ],
                            'ufCrm44_1721812898903' => [
                                "green_pixel2.png",
                                "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg==",
                            ],
                            'ufCrm44_1721812915476' => "600|EUR",
                            'ufCrm44_1721812935209' => "N",
                            'ufCrm44_1721812948498' => 9999.9,
                        ],
                    ],
                ]
            );
            
            echo '<PRE>';
            print_r($result);
            echo '</PRE>';
            
    BX24.callMethod(
                'crm.item.batchImport',
                {
                    entityTypeId: 1302,
                    data: [
                        {
                            ufCrm44_1721812760630: 'String value for a custom String field',
                            ufCrm44_1721812814433: 81,
                            ufCrm44_1721812853419: '2024-08-21',
                            ufCrm44_1721812885588: ['example.com', 'second-example.com'],
                            ufCrm44_1721812898903: ['green_pixel.png', 'iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg=='],
                            ufCrm44_1721812915476: '300|EUR',
                            ufCrm44_1721812935209: 'Y',
                            ufCrm44_1721812948498: 9999.9,
                        },
                        {
                            ufCrm44_1721812760630: 'String value for a custom String field',
                            ufCrm44_1721812814433: 45,
                            ufCrm44_1721812853419: '2024-08-21',
                            ufCrm44_1721812885588: ['example.com', 'second-example.com'],
                            ufCrm44_1721812898903: ['green_pixel2.png', 'iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg=='],
                            ufCrm44_1721812915476: '600|EUR',
                            ufCrm44_1721812935209: 'N',
                            ufCrm44_1721812948498: 9999.9,
                        },
                    ],
                },
                result => result.error() ? console.error(result.error()) : console.info(result.data())
            );
            
    require_once('crest.php');
            
            $result = CRest::call(
                'crm.item.batchImport',
                [
                    'entityTypeId' => 1302,
                    'data' => [
                        [
                            'ufCrm44_1721812760630' => "String value for a custom String field",
                            'ufCrm44_1721812814433' => 81,
                            'ufCrm44_1721812853419' => '2024-08-21',
                            'ufCrm44_1721812885588' => [
                                "example.com",
                                "second-example.com",
                            ],
                            'ufCrm44_1721812898903' => [
                                "green_pixel.png",
                                "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg==",
                            ],
                            'ufCrm44_1721812915476' => "300|EUR",
                            'ufCrm44_1721812935209' => "Y",
                            'ufCrm44_1721812948498' => 9999.9,
                        ],
                        [
                            'ufCrm44_1721812760630' => "String value for a custom String field",
                            'ufCrm44_1721812814433' => 45,
                            'ufCrm44_1721812853419' => '2024-08-21',
                            'ufCrm44_1721812885588' => [
                                "example.com",
                                "second-example.com",
                            ],
                            'ufCrm44_1721812898903' => [
                                "green_pixel2.png",
                                "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg==",
                            ],
                            'ufCrm44_1721812915476' => "600|EUR",
                            'ufCrm44_1721812935209' => "N",
                            'ufCrm44_1721812948498' => 9999.9,
                        ],
                    ],
                ]
            );
            
            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.item.batchImport", b24.Params{
                "entityTypeId": 1302,
                "data": []b24.Params{
                    {
                        "ufCrm44_1721812760630": "String value for a custom String field",
                        "ufCrm44_1721812814433": 81,
                        "ufCrm44_1721812853419": "2024-08-21",
                        "ufCrm44_1721812885588": []string{"example.com", "second-example.com"},
                        "ufCrm44_1721812898903": []string{"green_pixel.png", "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg=="},
                        "ufCrm44_1721812915476": "300|EUR",
                        "ufCrm44_1721812935209": "Y",
                        "ufCrm44_1721812948498": 9999.9,
                    },
                    {
                        "ufCrm44_1721812760630": "String value for a custom String field",
                        "ufCrm44_1721812814433": 45,
                        "ufCrm44_1721812853419": "2024-08-21",
                        "ufCrm44_1721812885588": []string{"example.com", "second-example.com"},
                        "ufCrm44_1721812898903": []string{"green_pixel2.png", "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAMCAYAAACqTLVoAAAALklEQVR42u3SAQEAAAQDsEsuOj3YMqwy6fBWCSCAAAIgAAIgAAIgAAIgAAJw3QLOrRH1U/gU4gAAAABJRU5ErkJggg=="},
                        "ufCrm44_1721812915476": "600|EUR",
                        "ufCrm44_1721812935209": "N",
                        "ufCrm44_1721812948498": 9999.9,
                    },
                },
            })
            if err != nil {
                return fmt.Errorf("crm.item.batchImport: %w", err)
            }
            
            // The method wraps the response in an object with the "items" key.
            raw, ok := b24.Unwrap(res.Result, "items")
            if !ok {
            	return fmt.Errorf("no items key in the response")
            }
            
            fmt.Printf("%s\n", raw)
            

Response Handling

The method returns an items array. Each array element contains an item object with the identifier of the created item or the error and error_description fields with import error details.

HTTP status: 200

{
            "result": {
                "items": [
                    {
                        "item": {
                            "id": 15
                        }
                    },
                    {
                        "error": "CRM_FIELD_ERROR_REQUIRED",
                        "error_description": "The \"Name\" field is required"
                    }
                ]
            },
            "time": {
                "start": 1723414961.913589,
                "finish": 1723414964.652124,
                "duration": 2.738534927368164,
                "processing": 2.376383066177368,
                "date_start": "2024-08-11T22:22:41+00:00",
                "date_finish": "2024-08-11T22:22:44+00:00",
                "operating": 2.3762991428375244
            }
        }
        

Returned Data

Name
type

Description

result
object

Root element of the response. Contains the import results (detailed description)

time
time

Information about the request execution time

Result Object

Name
type

Description

items
array

Item import results (detailed description)

Items Array Element

Each array element contains either an item object if the import succeeds or the error and error_description fields if the import fails.

Name
type

Description

item
object

Successful import result (detailed description)

error
string

Item import error code

error_description
string

Item import error description

Item Object

Name
type

Description

id
integer

Identifier of the created item

Error Handling

HTTP status: 400, 401, 403

{
            "error": "NOT_FOUND",
            "error_description": "Smart process not found"
        }
        

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

Status

Code

Description

Value

400

NOT_FOUND

SPA not found

An unknown entityTypeId was passed

400

ACCESS_DENIED

Access denied

The user does not have permission to import items of type entityTypeId

400

CRM_FIELD_ERROR_VALUE_NOT_VALID

Invalid value for field field

An invalid value was passed for the field field.

For system fields, such as createdTime, the error also occurs if the request is made by a non-administrator

400

100

Expected iterable value for multiple field, but got type instead

A value of type type was passed to a multiple field, but an iterable value was expected. The error can also occur due to invalid JSON or request headers

400

CREATE_DYNAMIC_ITEM_RESTRICTED

You cannot create a new item due to your plan restrictions

Plan restrictions do not allow creating SPA items

400

MAX_IMPORT_BATCH_SIZE_EXCEEDED

You cannot import more than 20 items

The data array contains more than 20 items

401

INVALID_CREDENTIALS

Invalid authorization data for the request

Invalid user identifier or webhook code in the request URL

403

allowed_only_intranet_user

This action is allowed only for intranet users

The user is not an intranet user

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