What Are Scripts?
Scripts are small server-side functions you can write in the Sellrn dashboard to extend your store — custom webhooks, automations, product logic, and API endpoints.
Scripts are small JavaScript/TypeScript functions you write directly in the Sellrn dashboard. They run on Sellrn's server infrastructure and let you extend your store without setting up external servers or webhooks.
What you can build with scripts
- Custom checkout logic — validate cart contents, enforce minimum order quantities, or block restricted products for certain buyer types.
- Order automations — send a Slack message when a high-value order comes in, update a spreadsheet, or trigger a print label request.
- Product data enrichment — fetch real-time stock levels from your ERP and return them to the storefront.
- Custom API endpoints — create your own URL endpoints (Script Endpoints) that your mobile app, POS, or third-party tools can call.
- Form submission handlers — process contact form submissions, validate data, and send to your CRM.
Enabling scripts
Scripts require Advanced Developer Settings to be enabled. Go to Settings → Advanced and toggle on Developer mode. This unlocks the Scripts section in the dashboard sidebar.
Creating a script
- Go to Scripts → New script.
- Choose a script type: Endpoint, Webhook, or Scheduled.
- Write your function in the built-in editor (TypeScript supported).
- Click Deploy. The script is live immediately.
Script types
| Type | When it runs |
|---|---|
| Endpoint | When an HTTP request is made to its URL (/api/scripts/v1/your-script). |
| Webhook | When a store event fires (order created, product updated, buyer approved, etc.). |
| Scheduled | On a cron schedule (e.g. every hour, every day at 9 am). |
Security
Script Endpoints are protected by a script token — a secret key that must be included in the request header. Requests without a valid token are rejected with a 401. Rotate the token any time in Scripts → Settings.
Logs and debugging
Every script execution is logged. View logs in Scripts → [script] → Logs. Logs show the request, response, and any console output or errors from your script.
Limits
- Maximum execution time: 30 seconds per script invocation.
- Maximum response size: 10 MB.
- Scripts can call external APIs (fetch is available).
- Scripts have read/write access to your store's database via the Sellrn SDK.