Script Execution
Section titled “Script Execution”Execute scripts as HTTP endpoints via POST requests. The script execution service maps URL paths to script files, allowing you to trigger scripts by sending HTTP requests. Path routing follows Next.js-style conventions, supporting nested directories and segments such as scripts/handle-webhook.
Execute Script
Section titled “Execute Script”POST /{path}
Execute a script identified by its path. The path supports Next.js-style routing. Any JSON body sent in the request is forwarded to the script at execution time.
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”The request accepts a JSON body of arbitrary shape. The body contents are forwarded to the script; no specific schema is enforced.
{ "data": "example payload"}Response
Section titled “Response”Script executed successfully.
{ "status": "success", "result": "Script completed"}{ "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 |
Example
Section titled “Example”curl -X POST "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/scripts/handle-webhook" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{"data": "example payload"}'import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.exec.execution.execute("scripts/handle-webhook");