You are browsing the documentation for version 4.2 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Security Support ends in January 2024. Read version 5.0 (the latest LTS version) of the Oro documentation to get the updated information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Batch API

The Batch API provides a way to create or update a list of entities of the same type via one API request.

For detailed information how this API works see update_list, batch_update and batch_update_item actions.

Enable Batch API for Entity

By default, Batch API is disabled for all API resources. To enable it for an API resource, the update_list action should be enabled for this resource. This can be done via actions section for an entity in Resources/config/oro/api.yml.


                update_list: true

Batch API Configuration

All configuration options related to Batch API are grouped in batch_api section of ApiBundle configuration:


        # The default maximum number of entities that can be saved in a chunk. The default value is 100.
        chunk_size: 100

        # The maximum number of entities of a specific type that can be saved in a chunk.
            Oro\Bundle\UserBundle\Entity\User: 10 # example

        # The default maximum number of included entities that can be saved in a chunk. The default value is 50.
        included_data_chunk_size: 50

        # The maximum number of included entities that can be saved in a chunk for a specific primary entity type.
            Oro\Bundle\UserBundle\Entity\User: 20 # example

Parameters chunk_size_per_entity and included_data_chunk_size_per_entity can be used to tuning of an API engine to have maximum performance.

To get maximum performance in requests with included entities, the value of the included_data_chunk_size_per_entity parameter can be changed to the medium number of related entities that will be set to one primary entity when processing the request.

Asynchronous Batch Operations Cleanup Configuration

Obsolete asynchronous batch operations are removed once a day by a cron job.

The default configuration of this cron job is illustrated below:


            # The number of days async operations are stored in the system.
            lifetime: 30

            # The maximum number of seconds that the cron job can spend in one run.
            cleanup_process_timeout: 3600 # 1 hour

            # The maximum number of seconds after which an operation will be removed regardless of status.
            operation_timeout: 3600 # 1 hour

Storage Configuration

The KnpGaufretteBundle is used to configure storages for source data files of Batch API requests and all files that are created when processing asynchronous batch operations (e.g. chunk files, error files, etc.).

Here is the default configuration of these storages:

                connection_name: batch
                table: oro_api_async_data
                    key: name
                    content: content
                    mtime: updated_at
                    checksum: checksum
        # a storage for source data files
            adapter: private
            alias: api_source_data_filesystem
        # a storage for files created when processing asynchronous batch operations
            adapter: api
            alias: api_filesystem

To change the adapter configuration the Resources/config/oro/app.yml in any bundle or config/config.yml of your application can be used. The following example shows how to reconfigure this adapter to use a local filesystem:

                directory: '%kernel.project_dir%/var/api_files'

More examples can be found in KnpGaufretteBundle documentation.

Business Tip

Explore our guide to learn how digital transformation in manufacturing industry improves operations, customer experiences, and sales.