Execute Script
Section titled “Execute Script”POST /{path}
Execute a script by its path. The path supports Next.js-style routing, so nested directories map directly to URL segments (for example, scripts/handle-webhook is invoked at /scripts/handle-webhook).
Parameters
Section titled “Parameters”| Name | In | Type | Required | Description |
|---|---|---|---|---|
path | path | string | Yes | Script path (supports Next.js-style routing) |
Request Body
Section titled “Request Body”This endpoint does not define a request body schema. Send a JSON payload of any shape; the script receives it as the raw request body.
Example Request
Section titled “Example Request”curl -X POST "https://api.example.com/scripts/handle-webhook" \ -H "Content-Type: application/json" \ -d '{ "event": "order.created", "orderId": "ord_8f3a2b1c" }'await client.exec.execution.execute("scripts/handle-webhook");Responses
Section titled “Responses”Script executed successfully. The response body has no defined schema; the script controls its own output.
{ "error": "VALIDATION_ERROR", "message": "Invalid JSON in request body"}| Error Code | Title | Description | Resolution |
|---|---|---|---|
VALIDATION_ERROR | Invalid request data | The request body failed validation | Check request body format and try again |
{ "error": "SCRIPT_NOT_FOUND", "message": "Script not found at path"}| Error Code | Title | Description | Resolution |
|---|---|---|---|
SCRIPT_NOT_FOUND | Script file not found | No script exists at the specified path | Verify the script path and ensure the file exists |
{ "error": "SCRIPT_EXECUTION_ERROR", "message": "Runtime error in script"}| Error Code | Title | Description | Resolution |
|---|---|---|---|
SCRIPT_EXECUTION_ERROR | Script execution failed | An error occurred while executing the script | Check script logs for detailed error information |