Test a Function
Apps
Test a Function
Compile and execute a function in an ephemeral sandbox without installing it.
POST
Test a Function
Documentation Index
Fetch the complete documentation index at: https://docs.launchmystore.io/llms.txt
Use this file to discover all available pages before exploring further.
POST /apps/functions/test compiles a JavaScript function to WASM with
Javy and runs it in the same sandboxed worker the production dispatcher
uses — same per-type timeout, same output validator, same console.log
forwarding — but nothing is persisted. No AppFunctionRuns row, no
state change on any installation.
Use it for:
- Quick iteration in the developer dashboard’s “Try it” editor.
- CI smoke-tests that compile and exercise a function against a known fixture.
- Schema-conformance checks against the type-specific output validator.
@Auth(MERCHANT)). The sandbox is rate-limited per
calling account; abusive callers (excessive compile failures, sustained
timeouts) are throttled.
Request
JavaScript source. Must export a top-level
run (or main) function
that accepts the input object and returns the type-specific output
shape. Max 64 KB of source.Function type — determines the input shape that will be passed and the
output validator that will check the return value. One of:
discount, shipping_rate, payment_customization,
delivery_customization, order_validation, cart_transform,
fulfillment_constraints, local_pickup_options, pickup_point_options.Test input passed to
run(input). Should match the input contract for
the function type — see Function input fields.Execution timeout in ms. Server-clamped to the per-type cap below
(range: 50–5000). Omit to use the per-type default.
Per-type timeouts
| Function type | Default timeout | Hard cap |
|---|---|---|
discount | 500ms | 500ms |
payment_customization | 500ms | 500ms |
order_validation | 1000ms | 1000ms |
cart_transform | 1000ms | 1000ms |
delivery_customization | 1000ms | 1000ms |
fulfillment_constraints | 1000ms | 1000ms |
local_pickup_options | 1500ms | 1500ms |
shipping_rate | 2000ms | 2000ms |
pickup_point_options | 2000ms | 2000ms |
Example: discount
Response
The response is always200 OK — the function-execution outcome is
encoded in the data body (success: true/false). Only auth / compile /
quota errors surface as non-200.
true when the function ran AND its output passed validation.The function’s return value, after validator normalization.
null on hard failure.Wall-clock execution time inside the WASM worker.
Time spent compiling source → WASM (typically 80-300ms).
Source bytes after trimming.
Compiled WASM bytes (~3 KB in dynamic mode + shared provider).
Lines emitted by
console.log inside the function (truncated at 32 lines).Runtime error message when
success: false. null otherwise.Output validator error (when the function returned but its shape was wrong).
null otherwise.Example success
Example timeout
Example validation error
Error codes (non-200)
| Code | Description |
|---|---|
400 | Unknown type — must be one of the nine FunctionType values. |
400 | Compile failed (syntax error). data.message contains the Javy compiler error. |
400 | code larger than 64 KB. |
401 | Missing or invalid merchant JWT. |
429 | Sandbox rate limit hit. Wait and retry. |
503 | Sandbox compiler not available (Javy not installed on this host). |