Skip to content

Latest commit

 

History

History
552 lines (476 loc) · 17.5 KB

File metadata and controls

552 lines (476 loc) · 17.5 KB

Get a list of files and folders in the folder disk.folder.getChildren

{% note tip "" %}

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

{% endnote %}

Scope: disk

Who can execute the method: any user

The method disk.folder.getChildren returns a list of files and folders located in the folder.

{% note info "" %}

Only those files and folders for which the user has "Read" access permission are returned.

{% endnote %}

Method Parameters

{% include Note on required parameters %}

#| || Name type | Description || || id* integer | Identifier of the folder.

The identifier can be obtained using the method disk.storage.getChildren if the folder is located at the root of the storage, and using the method disk.folder.getChildren if the folder is located in another folder || || filter array | Array format:

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

where:

  • field_n — the name of the field by which filtering will be performed
  • value_n — the filter value

You can add a prefix to the keys field_n to specify 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 % symbol in the filter value should not be passed. The search looks for a substring at any position in the string
  • =% — LIKE, substring search. The % symbol 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 at any position
  • %= — LIKE (similar to =%)
  • = — equal, exact match (used by default)
  • != — not equal
  • ! — not equal

The list of fields available for filtering can be obtained using the method disk.folder.getFields || || order array | Array format:

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

where:

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

The list of fields available for sorting can be obtained using the method disk.folder.getFields || || 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 start parameter value:

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

Code Examples

{% include Footnote on examples %}

{% list tabs %}

  • cURL (Webhook)

    curl -X POST \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{"id":8907,"filter":{">=CREATE_TIME":"2026-01-12"},"order":{"NAME":"DESC"}}' \
    https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/disk.folder.getChildren
  • cURL (OAuth)

    curl -X POST \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{"id":8907,"filter":{">=CREATE_TIME":"2026-01-12"},"order":{"NAME":"DESC"},"auth":"**put_access_token_here**"}' \
    https://**put_your_bitrix24_address**/rest/disk.folder.getChildren
  • JS (TS)

    // 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 FolderChild returned in result[]
    type FolderChild = {
      ID: string
      NAME: string
      CODE: string | null
      STORAGE_ID: string
      TYPE: 'folder' | 'file'
      REAL_OBJECT_ID?: string
      PARENT_ID: string
      DELETED_TYPE: string
      GLOBAL_CONTENT_VERSION?: string
      FILE_ID?: string
      SIZE?: string
      CREATE_TIME: ISODate
      UPDATE_TIME: ISODate
      DELETE_TIME: ISODate | null
      CREATED_BY: string
      UPDATED_BY: string
      DELETED_BY: string
      DOWNLOAD_URL?: string
      DETAIL_URL: string
    }
    
    try {
      // disk.folder.getChildren 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<FolderChild[]>({
        method: 'disk.folder.getChildren',
        params: {
          id: 8907,
          filter: {
            '>=CREATE_TIME': '2026-01-12',
          },
          order: {
            NAME: 'DESC',
          },
        },
        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('Children count:', result.length, 'first item:', result[0]?.NAME)
      }
    } catch (error) {
      // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
      console.error(error)
    }
  • JS (UMD)

    <!-- 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 getFolderChildren() {
        try {
          // Initialize the SDK inside a Bitrix24 frame
          const $b24 = await B24Js.initializeB24Frame()
    
          // disk.folder.getChildren 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: 'disk.folder.getChildren',
            params: {
              id: 8907,
              filter: {
                '>=CREATE_TIME': '2026-01-12',
              },
              order: {
                NAME: 'DESC',
              },
            },
            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('Children count:', result.length, 'first item:', result[0]?.NAME)
        } catch (error) {
          // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
          console.error(error)
        }
      }
    
      document.addEventListener('DOMContentLoaded', getFolderChildren)
    </script>
  • Python

    from b24pysdk.errors import BitrixAPIError, BitrixSDKException
    
    try:
        bitrix_response = client.disk.folder.getchildren(
            bitrix_id=8907,
            filter={
                ">=CREATE_TIME": "2026-01-12",
            },
            order={
                "NAME": "DESC",
            },
        ).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}")
  • PHP

    try {
        $response = $b24Service
            ->core
            ->call(
                'disk.folder.getChildren',
                [
                    'id' => 8907,
                    'filter' => [
                        '>=CREATE_TIME' => '2026-01-12'
                    ],
                    'order' => [
                        'NAME' => 'DESC'
                    ]
                ]
            );
    
        $result = $response
            ->getResponseData()
            ->getResult();
    
        echo 'Success: ' . print_r($result, true);
        processData($result);
    
    } catch (Throwable $e) {
        error_log($e->getMessage());
        echo 'Error: ' . $e->getMessage();
    }
  • BX24.js

    BX24.callMethod(
        "disk.folder.getChildren",
        {
            id: 8907,
            filter: {
                '>=CREATE_TIME': '2026-01-12'
            },
            order: {
                NAME: 'DESC'
            }
        },
        function (result) {
            if (result.error())
                console.error(result.error());
            else
                console.dir(result.data());
        }
    );
  • PHP CRest

    require_once('crest.php');
    
    $result = CRest::call(
        'disk.folder.getChildren',
        [
            'id' => 8907,
            'filter' => [
                '>=CREATE_TIME' => '2026-01-12'
            ],
            'order' => [
                'NAME' => 'DESC'
            ]
        ]
    );
    
    echo '<PRE>';
    print_r($result);
    echo '</PRE>';
  • Go

    // client and ctx are already created — see the Go SDK section
    res, err := client.Core().Call(ctx, "disk.folder.getChildren", b24.Params{
    	"id": 8907,
    	"filter": b24.Params{
    		">=CREATE_TIME": "2026-01-12",
    	},
    	"order": b24.Params{
    		"NAME": "DESC",
    	},
    })
    if err != nil {
    	return fmt.Errorf("disk.folder.getChildren: %w", err)
    }
    
    var items []struct {
    	ID           b24.ID `json:"ID"`
    	Name         string `json:"NAME"`
    	StorageID    b24.ID `json:"STORAGE_ID"`
    	Type         string `json:"TYPE"`
    	RealObjectID b24.ID `json:"REAL_OBJECT_ID"`
    	ParentID     b24.ID `json:"PARENT_ID"`
    }
    if err := json.Unmarshal(res.Result, &items); err != nil {
    	return fmt.Errorf("parse response: %w", err)
    }
    for _, it := range items {
    	fmt.Println(it.ID, it.Name)
    }

{% endlist %}

Response Handling

HTTP status: 200

{
    "result": [
        {
            "ID": "8930",
            "NAME": "Folder in Folder",
            "CODE": null,
            "STORAGE_ID": "1357",
            "TYPE": "folder",
            "REAL_OBJECT_ID": "8930",
            "PARENT_ID": "8907",
            "DELETED_TYPE": "0",
            "CREATE_TIME": "2026-01-13T16:16:35+02:00",
            "UPDATE_TIME": "2026-01-13T16:16:35+02:00",
            "DELETE_TIME": null,
            "CREATED_BY": "1269",
            "UPDATED_BY": "1269",
            "DELETED_BY": "0",
            "DETAIL_URL": "https://test.bitrix24.com/company/personal/user/1269/disk/path/Folder/Folder in Folder"
        },
        {
            "ID": "8964",
            "NAME": "Image.png",
            "CODE": null,
            "STORAGE_ID": "1357",
            "TYPE": "file",
            "PARENT_ID": "8907",
            "DELETED_TYPE": "0",
            "GLOBAL_CONTENT_VERSION": "1",
            "FILE_ID": "32718",
            "SIZE": "52486",
            "CREATE_TIME": "2026-01-14T17:05:05+02:00",
            "UPDATE_TIME": "2026-01-14T17:05:39+02:00",
            "DELETE_TIME": null,
            "CREATED_BY": "1269",
            "UPDATED_BY": "1269",
            "DELETED_BY": "0",
            "DOWNLOAD_URL": "https://test.bitrix24.com/rest/download.json?auth=d9c467690000071b006e2cf2000004f5000007248f2adc44d050ace99adb3cb9d0f1aa&token=disk%7CaWQ9ODk2NCZfPU9zTE4wUFNMRVBacFJiZXF6Q203dkY4d3V6ZUQyd0Rt%7CImRvd25sb2FkfGRpc2t8YVdROU9EazJOQ1pmUFU5elRFNHdVRk5NUlZCYWFGSmlaWEY2UTIwM2RrWTRkM1Y2WlVReWQwUnR8ZDljNDY3NjkwMDAwMDcxYjAwNmUyY2YyMDAwMDA0ZjUwMDAwMDcyNDhmMmFkYzQ0ZDA1MGFjZTk5YWRiM2NiOWQwZjFhYSI%3D.oSqXbtR%2FjZL8%2BfY%2BUvgqYQdxoHVh7PCvocXUvtS9n4s%3D",
            "DETAIL_URL": "https://test.bitrix24.com/company/personal/user/1269/disk/file/Folder/Image.png"
        },
        {
            "ID": "8936",
            "NAME": "Documents",
            "CODE": null,
            "STORAGE_ID": "1357",
            "TYPE": "folder",
            "REAL_OBJECT_ID": "8936",
            "PARENT_ID": "8907",
            "DELETED_TYPE": "0",
            "CREATE_TIME": "2026-01-13T17:00:40+02:00",
            "UPDATE_TIME": "2026-01-14T17:05:25+02:00",
            "DELETE_TIME": null,
            "CREATED_BY": "1271",
            "UPDATED_BY": "1271",
            "DELETED_BY": "0",
            "DETAIL_URL": "https://test.bitrix24.com/company/personal/user/1269/disk/path/Folder/Documents"
        }
    ],
    "total": 3,
    "time": {
        "start": 1768407161,
        "finish": 1768407161.323201,
        "duration": 0.32320094108581543,
        "processing": 0,
        "date_start": "2026-01-14T17:12:41+02:00",
        "date_finish": "2026-01-14T17:12:41+02:00",
        "operating_reset_at": 1768407761,
        "operating": 0
    }
}

Returned Data

#| || Name type | Description || || result array | A list of files and folders with field descriptions.

An empty array means that the user does not have permission to view the files and folders located in the specified folder || || ID integer | Identifier of the file/folder || || NAME string | Name of the file/folder || || CODE string | Symbolic code of the file/folder || || STORAGE_ID integer | Identifier of the storage where the file/folder is located || || TYPE enum | Type of the object || || REAL_OBJECT_ID integer | Identifier of the object || || PARENT_ID integer | Identifier of the parent folder || || DELETED_TYPE enum | Deletion status of the object. Possible values:

  • 0 — not deleted
  • 3 — in the trash
  • 4 — deleted along with the parent folder || || GLOBAL_CONTENT_VERSION integer | Incremental version counter of the file || || FILE_ID integer | Internal value of the file identifier || || SIZE integer | Size of the file in bytes || || CREATE_TIME datetime | Date and time of creation of the file/folder || || UPDATE_TIME datetime | Date and time of the last update of the file/folder || || DELETE_TIME datetime | Date and time of moving the file/folder to the trash || || CREATED_BY integer | Identifier of the user who created the file/folder || || UPDATED_BY integer | Identifier of the user who made the last change || || DELETED_BY integer | Identifier of the user who deleted the file/folder || || DOWNLOAD_URL string | Link to download the file || || DETAIL_URL string | Link to open the file/folder in the interface || || total integer | Total number of files and folders || || time time | Information about the execution time of the request || |#

Error Handling

HTTP status: 400

{
    "error":"ERROR_ARGUMENT",
    "error_description":"Invalid value of parameter {Parameter #1}"
}

{% include notitle error handling %}

Possible Error Codes

#| || Code | Description | Value || || ERROR_ARGUMENT | Invalid value of parameter {Parameter #1} | The required parameter id is not specified || || ERROR_NOT_FOUND | Could not find entity with id X | The folder with the specified id was not found || |#

{% include system errors %}

Continue Learning