Webhooks
Basic
This is functionality that is responsible for communicating with other applications or services. Webhooks are triggered for specific actions on the store side, for example, you can configure a webhook to trigger when a new order is created, after which detailed order information will be sent to the external application.
Webhook can be created by any user who has a webhooks.add permission, but specific webhooks may require additional permissions.
Sending process
Every send webhook follows this pattern:
- After trigger specific event is created suitable query and added to queue
- Executing each webhook from queue
- Time out is set for 4s.
- To let us know about successful delivery data we have to receive one of 2** HTTP code.
- If we receive other code we will retry request but max 3 times.
- Failed webhooks are logged in, and can be viewed in admin dashboard.
Signature
Optionally, the API can send a hashed payload that can be used to verify the authenticity of the request. To enable this feature, simply specify secret in the webhooks settings. The hash is generated using the HMAC method with the sha256 algorithm and will be sent in the Signature header. To verify the signature you must hash the payload with the sha256 algorithm. and compare your hash with the one received in the request header.
Secure webhooks
Some of our webhooks have fully encrypted payloads for security reasons - they can be found here.
This feature must be enabled by store administrator. Key is hidden in API files. Additionally, this requires SSL and Signature webhook.
Decoding payload
To do that, you have to get payload string and provide that to base64 decode function and then trim from beginning to length of WEBHOOK_CIPHER - keep that fragment it's important for next step - that will be your Initialization Vector. With these strings trimmed strings put them to OpenSSL decode function with information about:
- Second part of trimmed string as
data WEBHOOK_CIPHERascipher_algoWEBHOOK_KEYaspassphraseOPENSSL_RAW_DATAasoptions- First part of trimmed string as
iv
Structure of webhook
Webhooks
{
"event": "string",
"data_type": "string",
"triggered_at": "DateTime", // ISO 8601
"issuer_type": "string", // enum - app | user
"issuer": { // when issuer is user
"id": "UUID",
"email": "string",
"name": "string",
"avatar": "string",
},
"issuer": { // when issuer is app
"id": "UUID",
"url": "string",
"microfrontend_url": "string",
"name": "string",
"slug": "string",
"version": "string",
"description": "string",
"icon": "string",
"author": "string",
},
"api_url": "string", // Store api URL
"data": {},
}
Available events
List of all events
* - It means permission is required when webhook has set with_hidden to true
| Event | Requirement permission | Payload | Encryption |
|---|---|---|---|
OrderCreatedOrderUpdatedOrderUpdatedStatus | orders.show_detailsorders.show | WebHookEvent<Order> & { data_type: 'Order' } | no |
OrderRequestedShipping | orders.show_detailsorders.showpackages.show | type ShippingRequest = {order: Order, package: Package} | no |
ProductCreatedProductUpdatedProductDeleted | products.showproducts.show_detailsproducts.show_hidden* | WebHookEvent<Product> & { data_type: 'Product' } | no |
ItemCreatedItemUpdatedItemUpdatedQuantityItemDeleted | items.showitems.show_details | WebHookEvent<Item> & { data_type: 'Item' } | no |
PageCreatedPageUpdatedPageDeleted | pages.showpages.show_detailspages.show_hidden* | WebHookEvent<Page> & { data_type: 'Page' } | no |
ProductSetCreatedProductSetUpdatedProductSetDeleted | product_sets.showproduct_sets.show_detailsproduct_sets.show_hidden* | WebHookEvent<ProductSet> & { data_type: 'ProductSet' } | no |
UserCreatedUserUpdatedUserDeleted | users.showusers.show_details | WebHookEvent<User> & { data_type: 'User' } | no |
DiscountCreatedDiscountUpdatedDiscountDeleted | discounts.showdiscounts.show_details | WebHookEvent<Discount> & { data_type: 'Discount' } | no |
LanguageCreatedLanguageUpdatedLanguageDeleted | languages.show_hidden* | WebHookEvent<Language> & { data_type: 'Language' } | no |
TfaInitTfaSecurityCode | webhooks.tfa | type TfaCode = { security_code: string, user: User } | yes |
TfaRecoveryCodesChanged | webhooks.tfa | WebHookEvent<User> & { data_type: 'User' } | yes |
PasswordReset | webhooks.password | type PasswordRecovery = { recovery_url: string, user: User, redirect_url: string } | yes |
AddOrderDocumentRemoveOrderDocument | orders.show_details | type OrderDocumentEvent = { order: Order, document: OrderDocument } | no |
SendOrderDocument | orders.show_details | type SendOrderDocument = { order: Order, documents: OrderDocument[] } | no |
NewLocalizationLoginAttempt | users.show_details | type LocalizedLoginAttempt = { user_agent: string, ip: string, user: User, date: string } | yes |
SuccessfullLoginAttempt | users.show_details | WebHookEvent<LocalizedLoginAttempt> & { data_type: 'LocalizedLoginAttempt' } | yes |
FailedLoginAttempt | users.show_details | WebHookEvent<LocalizedLoginAttempt> & { data_type: 'LocalizedLoginAttempt' } | yes |