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.⚠️ 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:| Metric | Target |
|---|
| Recommended | Under 500 milliseconds |
| Acceptable | Under 1 seconds |
| Maximum | 5 seconds (poor UX) |
❌ External API calls that may be slow
❌ Complex calculations or database queries
✔️ Best practice — Keep logic simple and fast
✔️ Validating data before creation
✔️ Calculating custom shipping rates
✔️ Applying custom pricing logic
✔️ Real-time inventory checks
shipment.creating — Runs before a shipment is created
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).✔️ 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
🔄 Syncing data to external systems
📊 Tracking customer behavior
🎯 Personalizing user experience
📧 Triggering marketing campaigns
📈 Analytics and reporting
Example 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
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#
| Feature | Synchronous Actions | Asynchronous Events |
|---|
| Execution | Immediate, blocks user | Queued instantly (< 1s), executes in background |
| Response Time | Milliseconds (< 500ms recommended) | N/A (queued instantly) |
| Max Timeout | 5-10 seconds | 30 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 |
| Response | Can modify/reject action | Notification only |
| Use Case | Validation, modification (simple & fast) | Logging, sync, notifications, analytics, tracking |
| Examples | shipment.creating | order.created, Product Viewed |
| Return Value | Affects action | Ignored |
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:🖥️ 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:✔️ 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)
🕐 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.
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
Support and Resources#
👥 Community — Join our developer community for support and discussions
Modified at 2025-11-17 11:41:06