ATUM REST API

Tools

ATUM

The ATUM tools API allows you to view and run tools.

The tools endpoints require the ATUM manage_settings capability. Some ATUM add-ons register their own tools on these endpoints (for example, Product Levels adds the sync_calculated_stock tool).

Tool properties

AttributeTypeDescription
idstringA unique identifier for the tool. read-only
namestringTool nice name. read-only
descriptionstringTool description. read-only
configobjectIf the tool needs config in order to work. Only returned when running a tool that received a config.
successbooleanDid the tool run successfully? Only returned when running a tool. read-only
messagestringTool return message. Only returned when running a tool. read-only
resultobjectData returned by the tool, in case there were. Only returned when running a tool that returns extra data. read-only

Available tools

IDDescription
enable-manage-stockEnable the WooCommerce's manage stock at product level for all the products at once.
disable-manage-stockDisable the WooCommerce's manage stock at product level for all the products at once.
enable-atum-controlEnable the ATUM's stock control option for all the products at once.
disable-atum-controlDisable the ATUM's stock control option for all the products at once.
clear-out-stock-thresholdClear all previously saved Out of Stock Threshold values.
sync_calculated_stockSync all the associated BOM products' stock with their current calculated stock. Only available when the BOM stock control is enabled in the Product Levels settings (or when recalculating the calculated stock without BOM stock control is allowed through a filter, in which case it only recalculates the calculated stock, without changing the WooCommerce stock). See its config options. Product Levels

Retrieve a tool

This API lets you retrieve and view a specific tool by ID.

HTTP request

GET/wp-json/wc/v3/atum/tools/<id>
curl https://example.com/wp-json/wc/v3/atum/tools/enable-atum-control \
	-u consumer_key:consumer_secret
JSON response example
{
    "id": "enable-atum-control",
    "name": "Enable ATUM Stock Control",
    "description": "Enable the ATUM's stock control option for all the products at once.",
    "_links": {
        "item": [
            {
                "embeddable": true,
                "href": "https://example.com/wp-json/wc/v3/atum/tools/enable-atum-control"
            }
        ]
    }
}

List all tools

This API helps you to view all the available ATUM tools.

HTTP request

GET/wp-json/wc/v3/atum/tools
curl https://example.com/wp-json/wc/v3/atum/tools \
	-u consumer_key:consumer_secret
JSON response example
[
    {
        "id": "enable-manage-stock",
        "name": "Enable WC's Manage Stock",
        "description": "Enable the WooCommerce's manage stock at product level for all the products at once.",
        "_links": {
            "item": [
                {
                    "embeddable": true,
                    "href": "https://example.com/wp-json/wc/v3/atum/tools/enable-manage-stock"
                }
            ]
        }
    },
    {
        "id": "disable-manage-stock",
        "name": "Disable WC's Manage Stock",
        "description": "Disable the WooCommerce's manage stock at product level for all the products at once.",
        "_links": {
            "item": [
                {
                    "embeddable": true,
                    "href": "https://example.com/wp-json/wc/v3/atum/tools/disable-manage-stock"
                }
            ]
        }
    },
    {
        "id": "enable-atum-control",
        "name": "Enable ATUM Stock Control",
        "description": "Enable the ATUM's stock control option for all the products at once.",
        "_links": {
            "item": [
                {
                    "embeddable": true,
                    "href": "https://example.com/wp-json/wc/v3/atum/tools/enable-atum-control"
                }
            ]
        }
    },
    {
        "id": "disable-atum-control",
        "name": "Disable ATUM Stock Control",
        "description": "Disable the ATUM's stock control option for all the products at once.",
        "_links": {
            "item": [
                {
                    "embeddable": true,
                    "href": "https://example.com/wp-json/wc/v3/atum/tools/disable-atum-control"
                }
            ]
        }
    },
    {
        "id": "clear-out-stock-threshold",
        "name": "Clear Out of Stock Threshold",
        "description": "Clear all previously saved Out of Stock Threshold values.",
        "_links": {
            "item": [
                {
                    "embeddable": true,
                    "href": "https://example.com/wp-json/wc/v3/atum/tools/clear-out-stock-threshold"
                }
            ]
        }
    },
    {
        "id": "sync_calculated_stock",
        "name": "Sync WooCommerce stock with calculated stock",
        "description": "Sync all the associated BOM products' stock with their current calculated stock.",
        "_links": {
            "item": [
                {
                    "embeddable": true,
                    "href": "https://example.com/wp-json/wc/v3/atum/tools/sync_calculated_stock"
                }
            ]
        }
    }
]

Run a tool

This API lets you run an ATUM tool. The POST and PATCH methods can be used too. Some tools accept a config object with extra options to run them.

If the ATUM Action Logs add-on is installed, every tool run through the API is recorded in the action logs.

HTTP request

PUT/wp-json/wc/v3/atum/tools/<id>
curl -X PUT https://example.com/wp-json/wc/v3/atum/tools/enable-manage-stock \
	-u consumer_key:consumer_secret \
	-H "Content-Type: application/json"
JSON response example
{
    "id": "enable-manage-stock",
    "name": "Enable WC's Manage Stock",
    "description": "Enable the WooCommerce's manage stock at product level for all the products at once.",
    "success": true,
    "message": "All your products were updated successfully",
    "_links": {
        "item": [
            {
                "embeddable": true,
                "href": "https://example.com/wp-json/wc/v3/atum/tools/enable-manage-stock"
            }
        ]
    }
}

Config options for sync_calculated_stock

Product Levels

By default, the sync_calculated_stock tool processes all the BOM products in a single request. To process them in batches, pass a config object with these options and run the tool again, increasing the offset, until result.finished is true:

ParameterTypeDescription
stepintegerNumber of BOM products to process in this request. When it's set, the response includes a result object.
offsetintegerNumber of BOM products to skip. Default is 0.
delete_transientsbooleanWhether to delete the ATUM transients after processing the products.

The result object contains the total number of BOM products to process, whether the process is finished and the limit (the number of products already processed).

curl -X PUT https://example.com/wp-json/wc/v3/atum/tools/sync_calculated_stock \
	-u consumer_key:consumer_secret \
	-H "Content-Type: application/json" \
	-d '{
  "config": {
    "step": 100,
    "offset": 0,
    "delete_transients": true
  }
}'
JSON response example
{
    "id": "sync_calculated_stock",
    "name": "Sync WooCommerce stock with calculated stock",
    "description": "Sync all the associated BOM products' stock with their current calculated stock.",
    "config": {
        "step": 100,
        "offset": 0,
        "delete_transients": true
    },
    "success": true,
    "message": "Stock updated successfully.",
    "result": {
        "total": 248,
        "finished": false,
        "limit": 100
    },
    "_links": {
        "item": [
            {
                "embeddable": true,
                "href": "https://example.com/wp-json/wc/v3/atum/tools/sync_calculated_stock"
            }
        ]
    }
}

On this page