Asynchronous web endpoints
An asynchronous web endpoint intercepts messages to a Web API and writes them to the message queue. Each time the system accepts such an API request, it generates a UUID identifier. Adobe Commerce includes this UUID when it adds the message to the queue. Then, a consumer reads the messages from the queue and executes them one-by-one.
data-variant=success
data-slots=text1, text2
bin/magento queue:consumers:start async.operations.all command to start the consumer that handles asynchronous and bulk API messages.Commerce supports the following types of asynchronous requests:
- POST
- PUT
- DELETE
- PATCH
data-variant=info
data-slots=text
The route to all asynchronous calls varies between platforms:
data-src=../../includes/paas-only.md
In Adobe Commerce on Cloud and on-premises projects, the route contains the prefix /async, added before /V1 of a standard synchronous endpoint. For example:
POST https://<host>/rest/<store-view-code>/async/V1/products
PUT https://<host>/rest/<store-view-code>/async/V1/products/:sku
data-src=../../includes/saas-only.md
In Adobe Commerce as a Cloud Service, the /async segment occurs after the V1 segment of the route. For example:
POST https://<server>.api.commerce.adobe.com/<tenant-id>/V1/async/products
PUT https://<server>.api.commerce.adobe.com/<tenant-id>/V1/async/products/:sku
The response of an asynchronous request contains the following fields:
bulk_uuidrequest_itemsiddata_hashstatusaccepted.errorsfalse. If an error occurs, the system provides all error-related information as a standard webapi exception.Sample usage
The following call asynchronously changes the price of the product that has a sku of 24-MB01:
data-src=../../includes/paas-only.md
PUT https://<host>/rest/<store-view-code>/async/V1/products/24-MB01
data-src=../../includes/saas-only.md
PUT https://<server>.api.commerce.adobe.com/<tenant-id>/V1/async/products/24-MB01
Payload
{
"product": {
"price": 29
}
}
Response
Commerce generates a bulk_uuid for each asynchronous request. Use the bulk_uuid to determine the operation status of your request.
{
"bulk_uuid": "fbfca270-7a90-4c4e-9f32-d6cf3728cdc7",
"request_items": [
{
"id": 0,
"data_hash": "9c1bd4bfd8defcc856ddf129cc01d172625d139d5f7dcf53b6cb09a0e9a843a3",
"status": "accepted"
}
],
"errors": false
}
Store scopes
data-src=../../includes/paas-only.md
You can specify a store code (which is labeled in the Admin as store view code) in the route of an asynchronous endpoint so that it operates on a specific store, as shown below:
POST /<store_code>/async/V1/products
PUT /<store_code>/async/V1/products/:sku
As a result, the asynchronous calls update the products on the specific store, instead of the default store.
You can specify the all store code to perform operations on all existing stores:
POST /all/async/V1/products
PUT /all/async/V1/products/:sku
data-src=../../includes/saas-only.md
In Adobe Commerce as a Cloud Service, you must specify the store code in the Store header of the request.
Fallback and creating/updating objects when setting store scopes
The following rules apply when you create or update an object, such as a product.
- If you do not set the store code while creating a new product, Commerce creates a new object with all values set globally for each scope.
- If you do not set the store code while updating a product, then by fallback, Commerce updates values for the default store only.
- If you include the
allparameter, then Commerce updates values for all store scopes (in case a particular store doesn't yet have its own value set). - If
<store_code>parameter is set, then values for only defined store will be updated.