Skip to content

The Route Management API lets you inspect, discover, and test the URL routes that map to your script directory, manage imported SDK packages, and generate or validate user-defined OpenAPI specifications. Use these endpoints to debug routing behavior, onboard external SDKs, and produce machine-readable API documentation from your scripts.

Discover all available routes in the script directory, classified by Next.js-style type. Scans for .js and .ts files and classifies each as: static, dynamic ([param]), catch-all ([...slug]), or optional catch-all ([[...path]]). Returns the route pattern, file path, type, and extracted parameter names for each route. Optionally includes file metadata (size, modification time) when includeMetadata is true.

NameTypeRequiredDefaultDescription
baseDirstringNo""Base directory to scan for routes.
includeMetadatabooleanNofalseWhen true, includes file size and modification time for each route.
Terminal window
curl -X POST https://api.example.com/api/v1/exec/route/discover \
-H "Content-Type: application/json" \
-d '{
"baseDir": "scripts",
"includeMetadata": true
}'

Resolve a URL path to the script file that handles it, using Next.js-style dynamic routing. Supports static routes, dynamic segments [param], catch-all [...slug], and optional catch-all [[...path]]. Routes are matched in priority order: static > dynamic > catch-all > optional catch-all. Scoped by hostname and execId: checks {hostname}/{execId}/, then {hostname}/, then {execId}/, then root. Returns the matched script path, extracted route parameters, and route type.

This endpoint accepts a request payload. The request body schema is empty; the server derives the target URL, hostname, and execId from the request context.

Terminal window
curl -X POST https://api.example.com/api/v1/exec/route/resolve \
-H "Content-Type: application/json" \
-d '{}'

Test multiple URL paths against the routing system in a single batch request. For each path, resolves which script would handle it using Next.js-style dynamic routing with the same priority and scoping rules as resolveRoute. Returns per-path match results with extracted parameters, plus aggregate matched/notMatched counts.

This endpoint accepts a request payload. The request body schema is empty; provide the list of test paths in the request body according to the server contract.

Terminal window
curl -X POST https://api.example.com/api/v1/exec/route/test \
-H "Content-Type: application/json" \
-d '{}'

Retrieve a single imported SDK by its identifier, including its source URL, on-disk path, marker, middleware files, and endpoint inventory.

NameInTypeRequiredDescription
idpathstringYesId parameter
Terminal window
curl https://api.example.com/api/v1/exec/sdk/stripe-v1

List all imported SDKs with summary metadata.

This endpoint takes no parameters.

Terminal window
curl https://api.example.com/api/v1/exec/sdk/list

Import an SDK from a remote git source into the script directory, with optional pre- and post-middleware hooks and magic comments for the script generator.

NameTypeRequiredDefaultDescription
execIdstringYesIdentifier for the target exec context.
source_urlstringYesGit URL of the SDK to import.
source_authstringNoAuthentication string for private repositories.
middlewarestringNoMiddleware configuration payload.
magic_commentsstringNoMagic comments to inject into generated scripts.
forcebooleanNofalseRe-import and overwrite when an SDK with the same marker already exists.
Terminal window
curl -X POST https://api.example.com/api/v1/exec/sdk/import \
-H "Content-Type: application/json" \
-d '{
"execId": "app-1",
"source_url": "https://github.com/stripe/stripe-node.git",
"source_auth": "ghp_exampleToken",
"middleware": "auth",
"force": false
}'

Delete an imported SDK, removing all of its generated files and the associated marker directory.

NameInTypeRequiredDescription
idpathstringYesId parameter
Terminal window
curl -X DELETE https://api.example.com/api/v1/exec/sdk/stripe-v1

List available user scripts along with their detected schemas and route paths. Useful for inventorying which scripts are API endpoints, which carry a Zod/JSON schema, and which path parameters they expect.

NameInTypeRequiredDefaultDescription
directoryquerystringNoscriptsScript directory to list (absolute or relative to scripts-dir).
dirquerystringNoAlias of directory. Ignored when directory is provided.
subdomainquerystringNoLimit scan to scripts under this subdomain. Falls back to the Host header when omitted.
execIdquerystringNoLimit scan to scripts under this execId. Falls back to the Host header when omitted.
Terminal window
curl "https://api.example.com/api/v1/exec/user-openapi/list?directory=scripts&subdomain=example.com"

Serve a single script’s schema file directly, returning the raw Zod or JSON Schema definition as JSON.

NameInTypeRequiredDescription
filequerystringNoAbsolute or scripts-dir-relative path to the target script (e.g. default/api/users/[id].ts). Either file or path must be provided.
pathquerystringNoAlias of file. Either file or path must be provided.
Terminal window
curl "https://api.example.com/api/v1/exec/user-openapi/schema?file=default/api/users/%5Bid%5D.ts"

Generate and serve the full OpenAPI specification for the user scripts on-the-fly, combining the schema files of every script in the scanned directory. Output can be requested as JSON or YAML.

NameInTypeRequiredDefaultDescription
dirquerystringNoscriptsScript directory to scan (absolute or relative to scripts-dir).
directoryquerystringNoAlias of dir. Ignored when dir is provided.
formatquerystringNojsonOutput format. json (default) or yaml.
subdomainquerystringNoLimit scan to scripts under this subdomain. Falls back to the Host header when omitted.
execIdquerystringNoLimit scan to scripts under this execId. Falls back to the Host header when omitted.
Terminal window
curl "https://api.example.com/api/v1/exec/user-openapi/spec?format=json&subdomain=example.com"

Generate the OpenAPI specification for the user scripts and return it inline in the response body, along with metadata about the scan (path count, scan directory, generation timestamp).

This endpoint accepts a request payload. The request body schema is empty; supply scan options (e.g. directory, subdomain, execId) in the request body according to the server contract.

Terminal window
curl -X POST https://api.example.com/api/v1/exec/user-openapi/generate \
-H "Content-Type: application/json" \
-d '{}'

Merge multiple OpenAPI specifications into a single combined document, returning the merged result.

This endpoint accepts a request payload. The request body schema is empty; supply the list of specs to merge in the request body according to the server contract.

Terminal window
curl -X POST https://api.example.com/api/v1/exec/user-openapi/merge \
-H "Content-Type: application/json" \
-d '{}'

Validate a single script’s schema file, returning whether the schema is well-formed and a list of validation errors when it is not.

This endpoint accepts a request payload. The request body schema is empty; supply the script path to validate in the request body according to the server contract.

Terminal window
curl -X POST https://api.example.com/api/v1/exec/user-openapi/validate \
-H "Content-Type: application/json" \
-d '{}'