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.
Name Type Required Default Description baseDirstring No ""Base directory to scan for routes. includeMetadataboolean No falseWhen true, includes file size and modification time for each route.
curl -X POST https://api.example.com/api/v1/exec/route/discover \
-H " Content-Type: application/json " \
const result = await client . exec . route . discover ( {
"filePath" : " scripts/default/api/users.ts " ,
"pattern" : " /api/users/[id] " ,
"filePath" : " scripts/default/api/users/[id].ts " ,
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution NOT_FOUNDResource not found The requested resource does not exist Verify the resource identifier
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
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.
curl -X POST https://api.example.com/api/v1/exec/route/resolve \
-H " Content-Type: application/json " \
const result = await client . exec . route . resolve ( {} );
"path" : " scripts/example.com/app-1/api/users/[id].ts " ,
"hostname" : " example.com " ,
" scripts/example.com/app-1 " ,
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
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.
curl -X POST https://api.example.com/api/v1/exec/route/test \
-H " Content-Type: application/json " \
const result = await client . exec . route . test ( {} );
"script" : " scripts/default/api/users/[id].ts " ,
"params" : { "id" : " 42 " },
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Retrieve a single imported SDK by its identifier, including its source URL, on-disk path, marker, middleware files, and endpoint inventory.
Name In Type Required Description idpath string Yes Id parameter
curl https://api.example.com/api/v1/exec/sdk/stripe-v1
const result = await client . exec . sdk . get ( " stripe-v1 " );
"source_url" : " https://github.com/stripe/stripe-node.git " ,
"path" : " scripts/sdks/stripe-v1 " ,
"path" : " scripts/sdks/stripe-v1/middleware.pre.ts " ,
"hash" : " a1b2c3d4e5f67890 "
" scripts/sdks/stripe-v1/charges.ts " ,
" scripts/sdks/stripe-v1/customers.ts "
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution NOT_FOUNDResource not found The requested resource does not exist Verify the resource identifier
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
List all imported SDKs with summary metadata.
This endpoint takes no parameters.
curl https://api.example.com/api/v1/exec/sdk/list
const result = await client . exec . sdk . list ();
"source_url" : " https://github.com/stripe/stripe-node.git " ,
"source_url" : " https://github.com/openai/openai-node.git " ,
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
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.
Name Type Required Default Description execIdstring Yes — Identifier for the target exec context. source_urlstring Yes — Git URL of the SDK to import. source_authstring No — Authentication string for private repositories. middlewarestring No — Middleware configuration payload. magic_commentsstring No — Magic comments to inject into generated scripts. forceboolean No falseRe-import and overwrite when an SDK with the same marker already exists.
curl -X POST https://api.example.com/api/v1/exec/sdk/import \
-H " Content-Type: application/json " \
"source_url": "https://github.com/stripe/stripe-node.git",
"source_auth": "ghp_exampleToken",
const result = await client . exec . sdk . importSDK ( {
source_url: " https://github.com/stripe/stripe-node.git " ,
source_auth: " ghp_exampleToken " ,
"source_url" : " https://github.com/stripe/stripe-node.git " ,
"path" : " scripts/sdks/stripe-v1 " ,
"pre" : " scripts/sdks/stripe-v1/middleware.pre.ts " ,
"post" : " scripts/sdks/stripe-v1/middleware.post.ts " ,
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Delete an imported SDK, removing all of its generated files and the associated marker directory.
Name In Type Required Description idpath string Yes Id parameter
curl -X DELETE https://api.example.com/api/v1/exec/sdk/stripe-v1
const result = await client . exec . sdk . delete ( " stripe-v1 " );
"message" : " SDK deleted " ,
"directory" : " scripts/sdks/stripe-v1 "
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution NOT_FOUNDResource not found The requested resource does not exist Verify the resource identifier
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
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.
Name In Type Required Default Description directoryquery string No scriptsScript directory to list (absolute or relative to scripts-dir). dirquery string No — Alias of directory. Ignored when directory is provided. subdomainquery string No — Limit scan to scripts under this subdomain. Falls back to the Host header when omitted. execIdquery string No — Limit scan to scripts under this execId. Falls back to the Host header when omitted.
curl " https://api.example.com/api/v1/exec/user-openapi/list?directory=scripts&subdomain=example.com "
const result = await client . exec . openapi . listScripts ( {
"path" : " scripts/default/api/users.ts " ,
"routePath" : " /api/users " ,
"path" : " scripts/default/api/users/[id].ts " ,
"routePath" : " /api/users/[id] " ,
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Serve a single script’s schema file directly, returning the raw Zod or JSON Schema definition as JSON.
Name In Type Required Description filequery string No Absolute or scripts-dir-relative path to the target script (e.g. default/api/users/[id].ts). Either file or path must be provided. pathquery string No Alias of file. Either file or path must be provided.
curl " https://api.example.com/api/v1/exec/user-openapi/schema?file=default/api/users/%5Bid%5D.ts "
const result = await client . exec . openapi . serveSchema ( {
file: " default/api/users/[id].ts "
"id" : { "type" : " string " },
"email" : { "type" : " string " , "format" : " email " }
"required" : [ " id " , " email " ]
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
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.
Name In Type Required Default Description dirquery string No scriptsScript directory to scan (absolute or relative to scripts-dir). directoryquery string No — Alias of dir. Ignored when dir is provided. formatquery string No jsonOutput format. json (default) or yaml. subdomainquery string No — Limit scan to scripts under this subdomain. Falls back to the Host header when omitted. execIdquery string No — Limit scan to scripts under this execId. Falls back to the Host header when omitted.
curl " https://api.example.com/api/v1/exec/user-openapi/spec?format=json&subdomain=example.com "
const result = await client . exec . openapi . serve ( {
"title" : " User Scripts API " ,
"200" : { "description" : " OK " }
"summary" : " Get user by id " ,
"schema" : { "type" : " string " }
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
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.
curl -X POST https://api.example.com/api/v1/exec/user-openapi/generate \
-H " Content-Type: application/json " \
const result = await client . exec . openapi . generate ( {} );
"info" : { "title" : " User Scripts API " , "version" : " 1.0.0 " },
"scanDirectory" : " scripts " ,
"generatedAt" : " 2025-01-15T12:34:56.789Z "
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
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.
curl -X POST https://api.example.com/api/v1/exec/user-openapi/merge \
-H " Content-Type: application/json " \
const result = await client . exec . openapi . merge ( {} );
"info" : { "title" : " Merged API " , "version" : " 1.0.0 " },
"/api/users" : { "get" : { "summary" : " List users " } },
"/api/orders" : { "get" : { "summary" : " List orders " } }
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
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.
curl -X POST https://api.example.com/api/v1/exec/user-openapi/validate \
-H " Content-Type: application/json " \
const result = await client . exec . openapi . validateSchema ( {} );
"path" : " scripts/default/api/users.ts " ,
"fields" : [ " id " , " email " , " name " ]
"error" : " VALIDATION_ERROR " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,
Error Code Title Description Resolution VALIDATION_ERRORInvalid input Request parameters failed validation Check parameter format and requirements
"error" : " Internal server error " ,
"timestamp" : " 2025-01-15T12:34:56.789Z " ,