Webhooks configuration reference
Webhooks are configured in a webhooks.xml file. This file can be placed in the system <install_directory>/app/etc directory or in the etc directory of an enabled Adobe Commerce module.
Run the bin/magento webhooks:list command to determine if the webhooks you create in this file register correctly. The webhook name will be displayed in the list of registered webhooks.
A maximal webhooks.xml file has the following structure:
|__ config
|__ method
|__ hooks
|__ batch
|__ hook
|__ headers
| |__ header
|__ fields
| |__ field
|__ rules
|__ rule
Configure hooks and Create conditional webhooks contain examples of fully-defined hooks.
config attributes
The config element must contain the following text:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_AdobeCommerceWebhooks:etc/webhooks.xsd">
...
</config>
method element
The method element must define the webhook name and type. The combination of method name and type must be unique across the system.
| Attribute | Type | Description | Is required | Default | |---|---|---|---| | name | String | The webhook code name. The value must be in the form <type>.<webhook_name>, where type is either observer or plugin, and webhook_name matches a valid Commerce event name. Use the bin/magento webhooks:list:all command to display a list of possible webhooks. | true | Not applicable | | type | String | Specifies whether the webhook should be executed before or after the original action. | true | Not applicable |
hooks element
The hooks element is required. It does not contain any attributes, but it must contain one or more batch elements.
batch element
The batch element sets the order in which multiple webhooks are executed. All hooks within a batch are sent in parallel. Therefore, as you add hooks to a batch, keep in mind what task each hook will perform. For example, since the hooks are executed in parallel, you should not place a hook that relies on a response from another hook in the same batch.
nameorderhook element
The hook element defines the HTTP request to the remote server.
nameurlmethodpriorityrequiredfalse (optional), if the hook fails to execute, the failure is logged and subsequent hooks continue to be processed. When true, a failure terminates the process.timeoutsoftTimeoutfallbackErrorMessageremovettl0, the response is not cached.sslVerificationsslCertificatePathsslVerification is set to false.headersfieldsdeveloperConsoleOauthheaders and header elements
A headers element is optional and can contain one or more header elements. Each header definition creates an HTTP header to be sent in the remote server request.
nameAuthorization. Specify the value, such as Bearer: <token> in the body of the <header> element.resolverremovetrue to remove the header from the request.fields and field elements
A fields element is optional and can contain one or more field elements. The fields element provides the ability to limit the payload of a webhook to only those fields defined in the individual field definitions. Configure hook contents shows a fully-constructed hook.
nameproduct.sku.sourcename is used.converterremovetrue to remove the field from the payload.rules and rule elements
A rules element is optional and can contain one or more rule elements. Each rule element defines a conditional webhook, which configures the conditions that cause the webhook to be triggered when all conditions evaluate to true. Create conditional webhooks provides example rules and fully describes the possible operator values.
fielddata.order.product.id.operatorequal, notEqual, and regex.valueremovetrue indicates the rule is active.developerConsoleOauth element
The developerConsoleOauth element is optional. If provided must contain the following elements to generate OAuth authorization headers for the request:
clientIdclientSecretorgId