# Script Execution

**Page:** api/exec/script-execution

[Download Raw Markdown](./api/exec/script-execution.md)

---

{/* AUTO-GENERATED — Do not edit manually. Regenerate with: npm run docs:api:generate */}



Execute scripts as HTTP endpoints via POST requests. The Script Execution API lets you run server-side scripts by making a POST request to the script's path, supporting Next.js-style routing for dynamic and catch-all routes.

## Execute Script

### `POST /{path}`

Execute a script with POST data. The script receives the POST body and returns the result in the response.

### Parameters

| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| `path` | path | string | Yes | Script path (supports Next.js-style routing) |

### Request Body

This endpoint does not define a request body schema. Any JSON payload sent will be forwarded to the script.

### Response



```json
{
  "success": true,
  "output": "Script executed successfully",
  "data": {
    "result": "processed"
  }
}
```


```json
{
  "statusCode": 400,
  "error": "Bad Request",
  "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 |


```json
{
  "statusCode": 404,
  "error": "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 |


```json
{
  "statusCode": 500,
  "error": "Internal Server 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 |



### SDK Usage

```ts
const result = await client.exec.execution.execute({
  path: "scripts/handle-webhook",
});
```