Salla Docs
Merchant API
  • Merchant API
  • Salla OAuth 2.0
Partner APIs
  • App API
  • Shipments & Fulfillment APIs
  • Recurring Payments API
  • App Functions
Storefront
  • Twilight Engine
  • Twilight SDK
  • Web Components
  • Change Log
Salla CLI
Merchant API
  • Merchant API
  • Salla OAuth 2.0
Partner APIs
  • App API
  • Shipments & Fulfillment APIs
  • Recurring Payments API
  • App Functions
Storefront
  • Twilight Engine
  • Twilight SDK
  • Web Components
  • Change Log
Salla CLI
Salla - Opensource
Salla - Developers Community
  1. App Functions
  • Welcome 👋
  • What are App Functions?
  • Get Started
  • Supported Events
  • Testing
  • Responses
  • NodeJs Support
  • Merchants Events
    • Brand Events
    • Cart Events
    • Category Events
    • Communication Events
    • Customer Events
    • Invoice Events
    • Review Events
    • Shipment Events
    • Shipping Company Events
    • Shipping Zone Events
    • Special Offer Events
    • Store Branch Events
  • Customers Events
    • Account Events
    • Cart & Checkout Events
    • Product Events
    • Promotion & Coupon Events
    • Wishlist Events
  1. App Functions

What are App Functions?

App Functions allow third-party developers to embed custom logic directly into the lifecycle of merchant and customer activities on Salla. This powerful feature enables you to build dynamic, event-driven applications that respond to real-time store events without managing your own infrastructure.

What are App Functions?#

App Functions are serverless functions that execute automatically when specific activities occur in a Salla store. These activities, called Actions and Events, trigger your custom code with relevant context data, allowing you to:
📦 Process orders and update external systems
🔄 Sync inventory across platforms
📧 Send custom notifications
✔️ Validate and transform data
🔌 Integrate with third-party services
⚙️ Implement custom business logic

How It Works?#

When a merchant or customer performs an action in a Salla store (e.g., creating an order, updating a product, or completing checkout), Salla triggers the corresponding App Function with a context object containing:
payload — Event-specific data (order details, product information, customer data, etc.)
settings — Your app's configuration values defined in the Salla Partner Portal and customized by each merchant
merchant - An object contains the merchant info on which the Action/Event occures.
Your function processes this data and can:
🔐 Call Salla APIs (with automatic authentication)
🔌 Integrate with external services
✔️ Return responses that affect the store's behavior (for synchronous actions)
🔄 Process data asynchronously in the background (for events)

Execution Types#

App Functions support two execution types based on when they run and how they affect operations. Understanding these types is critical for building performant and reliable integrations.

Synchronous Actions#

Synchronous actions execute immediately within the same process. The user is blocked and waiting for your function to complete before they can proceed.
Characteristics:
⚠️ Blocks the user — Merchant cannot proceed until your function responds
⚡ Must respond in milliseconds — Target < 500ms for good user experience
⏱️ Maximum timeout — 5 seconds (but this creates poor UX)
🔄 Executed in real-time, synchronously
✔️ Can return data that affects the operation
✔️ Can modify or reject the action
⚠️ Critical performance — Slow responses create poor user experience
Performance Requirements:
MetricTarget
RecommendedUnder 500 milliseconds
AcceptableUnder 1 seconds
Maximum5 seconds (poor UX)
What to Avoid:
❌ External API calls that may be slow
❌ Complex calculations or database queries
✔️ Best practice — Keep logic simple and fast
Use Cases:
✔️ Validating data before creation
✔️ Calculating custom shipping rates
✔️ Applying custom pricing logic
✔️ Real-time inventory checks
Example Events:
shipment.creating — Runs before a shipment is created
Example Response:

Asynchronous Events#

Asynchronous events are queued and processed in the background without blocking other operations. They work the same way regardless of who triggers them (merchant or customer).
Characteristics:
✔️ Action completes immediately (user doesn't wait)
⚡ Event is queued for background processing (happens in < 1 second)
🔄 Function executes in background (max 30 seconds timeout)
ℹ️ Your return value doesn't affect the original action
👥 Works for both merchant actions and customer interactions
✔️ User cycle is never impacted - queuing is instant
✔️ Ideal for non-critical operations
Use Cases:
For Merchant Events:
📧 Sending notifications
📊 Logging and analytics
🔄 Syncing data to external systems
⚙️ Triggering workflows
For Customer Events:
📊 Tracking customer behavior
🎯 Personalizing user experience
📧 Triggering marketing campaigns
📈 Analytics and reporting

Example Events:#

Merchant Events:
order.created — Runs after an order is created
brand.updated — Runs after a brand is updated
product.deleted — Runs after a product is deleted
Customer Events:
Product Viewed — Customer views a product
Product Added — Customer adds product to cart
Order Completed — Customer completes checkout
Example Handler (Merchant Event):
Example Handler (Customer Event):

Quick Comparison#

FeatureSynchronous ActionsAsynchronous Events
ExecutionImmediate, blocks userQueued instantly (< 1s), executes in background
Response TimeMilliseconds (< 500ms recommended)N/A (queued instantly)
Max Timeout5-10 seconds30 seconds (background execution)
User Impact⚠️ User is blocked and waiting✔️ User never waits - instant response
Performance⚠️ Critical - must be extremely fast✔️ Non-critical, can take time
ResponseCan modify/reject actionNotification only
Use CaseValidation, modification (simple & fast)Logging, sync, notifications, analytics, tracking
Examplesshipment.creatingorder.created, Product Viewed
Return ValueAffects actionIgnored

Understanding Webhooks vs App Functions#

It's important to understand the difference between Salla Webhooks and App Functions:

Salla Webhooks (Traditional Approach)#

Webhooks send HTTP POST requests to your server endpoint when events occur:
Requirements:
🖥️ You need to host and maintain a server
🔐 You need to handle authentication and security
📈 You need to manage scaling and infrastructure
🔄 You need to implement retry logic for failures

App Functions (Modern Approach)#

App Functions receive the webhook payload wrapped in a context object with additional features:
Benefits:
✔️ No server infrastructure needed (serverless)
🔐 Automatic authentication and security
📈 Auto-scaling handled by Salla
🔄 Built-in retry logic and error handling
⚙️ Access to app settings for each merchant

Key Difference: The Context Object#

Webhook Payload (what Salla sends):
{
  "event": "brand.created",
  "merchant": 596493488,
  "created_at": "Sun Mar 24 2024 16:09:48 GMT+0300",
  "data": {
    "id": 190175156,
    "name": "Brand Name"
  }
}
App Function Context (what your function receives):

Context Object Structure#

Every App Function receives a context object with the following structure:

Payload Object#

The payload object contains the webhook event data that Salla sends. This is the same data structure you would receive if using traditional webhooks:
📋 event: The event name (e.g., order.created, brand.updated)
🏪 merchant: The merchant ID (number) who installed your app. Get merchant details via API
🕐 created_at: ISO timestamp when the event occurred
📦 data: Event-specific data that varies by event type

Settings Object#

The settings object contains your app's configuration values:
⚙️ Defined in the Salla Partner Portal when building your app
🎛️ Customized by each merchant when they install your app
✔️ Accessible in all your App Functions
🔑 Can include API keys, feature flags, preferences, etc.

Merchant Object#

The merchant object contains the info of the merchant on which the event took place, You can get more details about the merchant using Get merchant details API.
Example Settings:

Pricing Model#

App Functions are currently in beta and are free of charge.
When the feature becomes generally available, pricing will be based on:
📊 Number of function calls: Pay only for what you use
⏱️ Execution time: Longer-running functions may incur additional costs
💾 Resource usage: Memory and CPU consumption

Benefits for Third-Party Developers#

🖥️ Serverless Infrastructure — No servers to manage or maintain
📈 Automatic Scaling — Handles any volume of events automatically
🔐 Built-in Authentication — Seamless access to Salla APIs with automatic token injection
💻 TypeScript Support — Strong static typing for better development experience
🧪 Real-time Testing — Test your functions directly in the Partner Portal
👨‍💻 Developer-Friendly — Syntax highlighting, autocomplete, and error detection
⚡ Event-Driven — Respond to store activities in real-time
🔌 Flexible Integration — Connect with any external service or API

Next Steps#

🚀 Get Started — Get started with your first App Function in minutes
📋 Supported Events — Explore all available actions and events
🧪 Testing App Functions — Learn how to test your App Functions

Support and Resources#

📖 Documentation — Salla Developer Docs
📚 API Reference — Salla API Documentation
👤 Partner Portal — Salla Partners Portal
👥 Community — Join our developer community for support and discussions
Modified at 2025-11-17 11:41:06
Previous
Welcome 👋
Next
Get Started