Salla Docs
Merchant API
  • Merchant API
  • Salla OAuth 2.0
Partner APIs
  • App API
  • Shipment API
Storefront
  • Twilight Engine
  • Twilight SDK
  • Web Components
  • Change Log
Salla CLI
Merchant API
  • Merchant API
  • Salla OAuth 2.0
Partner APIs
  • App API
  • Shipment API
Storefront
  • Twilight Engine
  • Twilight SDK
  • Web Components
  • Change Log
Salla CLI
Salla - Opensource
Salla - Developers Community
  1. Merchant API
  • Welcome 👋
  • Get Started
  • Create Your First App
  • Authorization
  • Webhooks
  • Conditional Webhooks
  • Security Considerations
  • Multi-Language Support
  • Responses
  • Pagination
  • Rate Limiting
  • Versioning
  • Change Log
  • Support
  • APIs
    • Orders
      • Create Order
      • List Orders
      • Order Details
      • Create Drafted Order
      • Update Order
      • Duplicate Order
      • Order Actions
    • Order Status
      • Update Order Status
      • Create Custom Order Status
      • List Order Statuses
      • Order Status Details
      • Update Custom Order Status
      • Update Bulk Orders Statuses
      • Sort Orders Statuses
    • Order Histories
      • List Order Histories
      • Create Order History
    • Order Tags
      • Create Order Tag
      • List Order Tags
      • Delete Order Tag
    • Order Invoice
      • Create Invoice
      • List Invoices
      • Invoice Details
      • Send Order Invoice
      • Create Order Invoice
    • Order Reservations
      • List Order Reservations
    • Order Items
      • List Order Items
      • Create Order Item
      • Update Order Item
      • Delete Order Item
    • Products
      • Create Product
      • List Products
      • Product Details
      • Update Product
      • Delete Product
      • Change Product Status
      • Product Details By SKU
      • Update Product By SKU
      • Delete Product By SKU
      • Update Product Price By SKU
      • Update Bulk Product Prices
      • Import Products
      • Bulk Product Actions
    • Product Options
      • Create Product Option
      • Product Option Details
      • Update Product Option
      • Delete Product Option
    • Product Quantity
      • List Product Quantities
      • Update Bulk Quantities
      • List Quantity Change Reasons
      • List Quantity Audit
      • Update Bulk Quantities by SKU
      • Update Quantity
      • Update Quantity By SKU
    • Product Variants
      • List Product Variants
      • Product Variant Details
      • Update Product Variant
      • Update Product Variant Quantity
    • Product Tags
      • Create Product Tag
      • List Product Tags
    • Product Images
      • Attach Image by SKU
      • Attach Video by SKU
      • Attach Youtube Video
      • Attach Image
      • Update Image
      • Delete Image
    • Product Option Values
      • Create Product Option Value
      • Product Option Value Details
      • Update Product Option Value
      • Delete Product Option Value
    • Abandoned Carts
      • List Abandoned Carts
      • Abandoned Cart Details
    • Customer Groups
      • Create Customer Group
      • List Customer Groups
      • Add Customers To Group Customer
      • Update Default Customer Group
      • Update Customer Group
      • Delete Customer Group
    • Customers
      • Create Customer
      • List Customers
      • Customer Details
      • Update Customer
      • Delete Customer
      • Ban Customer
      • Un-Ban customer
      • Import Customers
    • Digitals Product
      • Attach Digital Code
      • Attach Digital File
      • Delete Digital File
    • Categories
      • Create Category
      • List Categories
      • Category Details
      • Update Category
      • Delete Category
      • Category Children
      • Categories Search
      • List Category Products
    • Exports
      • Export Orders
      • Exports Logs
      • List Export Templates
      • Create Export Template
      • Update Export Template
      • Delete Export Template
      • List Export Columns
      • Export Customers
      • Export Custom URLs
      • Export Products
    • Shipments
      • Create Shipment
      • List Shipments
      • Shipment Details
      • Shipment Tracking
      • Update Shipment Details
      • Cancel Shipment
      • Return Shipment
    • Shipping Companies
      • List Shipping Companies
      • Shipping Company Details
      • List Estimate Rates
      • Create Shipping Company
      • Update Shipping Company
      • Delete Shipping Company
      • Shipping Company Options
    • Shipping Zones
      • Create Shipping Zone
      • List Shipping Zones
      • Shipping Zone Details
      • Update Shipping Zone
      • Delete Shipping Zone
    • Shipping Rules
      • List Shipping Rules
      • Shipping Rule Details
      • Delete Shipping Rule
    • Countries
      • List Countries
      • Country Details
    • Product Option Templates
      • List Option Templates
      • Option Template Details
      • Delete Option Template
      • Update Option Template
      • Create Option Template
    • Taxes
      • Create Tax
      • List Taxes
      • Tax Details
      • Update Tax
      • Delete Tax
    • Coupons
      • Create Coupon
      • List Coupons
      • Coupon Details
      • Update Coupon
      • Delete Coupon
      • List Coupon Codes
    • Affiliates
      • List Affiliates
      • Affiliate Details
      • Create Affiliate
      • Update Affiliate
      • Delete Affiliate
    • Order Assignment
      • List Auto Assignment Rules
      • Order Assigned Employees Details
      • Update Auto Assignment Rule
      • Create Auto Assignment Rules
    • Special Offers
      • Create Special Offer
      • List Special Offers
      • Special Offer Details
      • Update Special Offer
      • Delete Special Offer
      • Change Special Offer Status
    • Transactions
      • List Transactions
      • Transaction Details
      • Update Transaction
    • Payments
      • Available Payment Methods
      • List Banks
      • Payment Bank Details
    • Settlements
      • List Instant Settlements
      • Create Instant Settlement
      • Update Instant Settlement
      • Instant Settlement Details
    • Settings
      • Settings List
      • Update Setting Slug
      • Setting Details
    • Merchant
      • User Information Details
      • Store Information
    • Brands
      • Create Brand
      • List Brands
      • Brand Details
      • Update Brand
      • Delete Brand
    • Branches
      • Create Branch
      • List Branches
      • Branch Details
      • Update Branch
      • Delete Branch
    • Currencies
      • Activate Currencies
      • List Currencies
      • List Available Currencies
    • SEO
      • List SEO Settings
      • Update SEO Settings
    • Cities
      • List Cities
    • DNS Records
      • List DNS Records
      • Create DNS Record
      • Delete DNS Record
    • Languages
      • Add Language
      • List Languages
      • Update Language
    • Employees
      • List Employees
    • Advertisements
      • Create Advertisement
      • List Advertisements
      • Advertisement Details
      • Update Advertisement
      • Delete Advertisement
    • Webhooks
      • List Active Webhooks
      • List Events
      • Register Webhook
      • Deactivate Webhook
      • Update Webhook
    • Custom URLs
      • Import Custom URLs
    • Loyalty Points
      • Customer Loyalty Points
      • Update Customer Loyalty Points
    • Reviews
      • List Reviews
      • Review Details
      • Update Review
  • Webhooks - Store Events
    • Order
    • Product
    • Customer
    • Shippings
    • Shipments
    • Brand
    • Invoice
    • Category
    • Store
    • Special Offer
    • Cart
    • Miscellaneous
  1. Merchant API

Conditional Webhooks

Webhooks provide a streamlined approach to facilitate communication between applications, offering the advantage of receiving notifications whenever an app receives data from another app. They play a critical role in establishing an event-based communication channel, connecting application owners with Salla. The primary purpose of webhooks is to ensure the synchronization of data between two separate applications.
Webhooks form the foundation of the infrastructure that supports numerous online activities. By subscribing to a webhook, developers anticipate receiving a payload that contains relevant information pertaining to the events they are interested in. However, dealing with large volumes of content within these payloads can sometimes be overwhelming and challenging to navigate. This is where Salla Rules comes into play.
Salla Rules offers developers the ability to exercise control and customization over webhooks, utilizing the supported attributes. Rules enable the breakdown of simple business rules into smaller specification objects, which can later be combined to express more complex rules. This modular approach allows you as a developer to tailor their webhook experiences according to their specific needs and requirements.

Importance of Rules#

Webhooks Targeting#

Narrowing down the received payload is an achievable goal, as rules introduce you to conditional webhooks. Your communication now turns out to be an event-based communication with Salla, and the same is applied in the received payload.
Salla has provided the configurability feature to webhooks. In a sense, Rules contain basic filtering, which allow writing conditions and then afterwards receive particular payload based on the written condition.
As your business grows, you will need to redouble on your service quality served, accuracy delievred, and effort done. With rules, you can easily reduce the amount of the events you listen to, as they usually come loaded in payloads. That said, you only recieve the payloads you are in need in your app.
With rules, you get to head directly to take actions as decisions are easily made, and that means no more time wasted on time-consuming processes. Check for an overview of webhooks on Salla docs for more details.

Use Cases#

The following are some use cases that webhooks can be used for:
You can use rules in webhooks to filter updated carts that contain specific coupon codes.
You can use rules in webhooks to uniquely identify specific order from a list of orders.
You can also use rules in webhooks to recognize a specific product using its attributes (SKU, name, etc.).

General Standards in Attributes#

Some Binary, Relational, and Logical operators are used when writing rules for a Salla webhook, such as equality, bitwise, and more.
Following the general standards is a must to obtain successful responses, so make sure to follow them. These rules act like conditional webhooks, for you to receive specific data.
Operations, expressions, and conditions to your webhook can be written. For instance, you may use =,!=,AND,OR etc in such a manner: payment_method = YOUR_PAYMENT_METHOD or in combination payment_method = mada OR price < 50. That adds more capability to filter the response based on conditionalities. In the following section, you can look up more into how you can construct your own rules using real-world examples.

Write Your First Rule#

The following payload registers a new webhook on the Merchant's dashboard, not on the Partners Portal, where the developer will be notified whenever the Merchant created an order.
{
  "name": "Salla Order Created Event",
  "event": "order.created",
  "url": "https://webhook.site/a61ca376-dd98-4053-b2c4-8ba9cca470fc",
  "version": 2,
  "rule": "total > 100",
  "headers": [
    {
      "key": "Authorization",
      "value": "Your Secret token"
    },
    {
      "key": "Accept-Language",
      "value": "AR"
    }
  ]
}
That said, you have successfully set your first webhook with rules. The next section will be rules to apply in other webhooks' events.

Examples#

The following two examples showcase how conditional webhooks can be implemented practically in your webhook rules queries.
Special Offer Webhook Request
Customer Webhook Request
{
  "name": "Salla Special Offer Created Event",
  "event": "specialoffer.created",
  "url": "https://webhook.site/a61ca376-dd98-4053-b2c4-8ba9cca470fc",
  "version": 2,
  "rule": "status = `active` OR applied_to = `first_order`",
  "headers": [
    {
      "key": "Authorization",
      "value": "Your Secret token"
    },
    {
      "key": "Accept-Language",
      "value": "AR"
    }
  ]
}
In the above example the webhook was set the event to specialoffer.created. In the rule section, we added OR
that means, when one of the conditions are true, this wil trigger the webhook. In our example, the webhook will be triggered whenever there is a status equaling to active, or the the special offer created is applied to order.

Attributes#

The following attributes allow you to write conditions only based on them. For example, if you want to write conditions for the Category event, use in the rule section one or more of the following:
id
name
parent_id
status
sort_order
And the same logic goes for all the supported attributes:
Order
Product
Customer
Special Offers
Category
Brand
Cart
Miscellaneous

Order#

Events
Properties
The supported events are the following:
Event Name
order.created
order.updated
order.status.updated
order.cancelled
order.refunded
order.deleted
order.products.updated
order.payment.updated
order.coupon.updated
order.total.price.updated
order.shipment.creating
order.shipment.created
order.shipment.cancelled
order.shipment.return.creating
order.shipment.return.created
order.shipment.return.cancelled
order.shipping.address.updated

Product#

Events
Properties
The supported events are the following:
Event Name
product.created
product.updated
product.deleted
product.available
product.quantity.low

Customer#

Events
Properties
The supported events are the following:
Event Name
customer.created
customer.updated
customer.login
customer.otp.request

Special Offers#

Events
Properties
The supported events are the following:
Event Name
specialoffer.created
specialoffer.updated

Category#

Events
Properties
The supported events are the following:
Event Name
category.created
category.updated

Brand#

Events
Properties
The supported events are the following:
Event Name
brand.created
brand.updated
brand.deleted

Cart#

Events
Properties
The supported event is the following:
Event Name
abandoned.cart

Miscellaneous#

Events
Properties
The supported event is the following:
Event Name
review.added
Modified at 2024-12-19 08:37:15
Previous
Webhooks
Next
Security Considerations