Exposes iii functions as REST API endpoints. Use when building HTTP APIs, webhooks, or inbound request handling where iii owns the route.
Comparable to: Express, Fastify, Flask
Use the concepts below when they fit the task. Not every HTTP endpoint needs all of them.
body, path_params, headers, and method{ status_code, body, headers } to shape the HTTP response/users/:id) and arrive in path_paramsmiddleware_function_ids in the trigger config — see iii-http-middleware for detailsHTTP request
→ iii-http (port 3111)
→ registerTrigger route match (method + path)
→ registerFunction handler (receives ApiRequest)
→ { status_code, body, headers } response
| Primitive | Purpose |
|---|---|
registerFunction | Define the handler for a route |
registerTrigger({ type: 'http' }) | Bind a route path and method to a function |
config: { api_path: '/path', http_method: 'GET' } | Route configuration on the trigger |
config: { ..., middleware_function_ids: [...] } | Optional middleware chain before the handler |
See ../references/http-endpoints.js for the full working example — a REST API with parameterized routes handling GET and POST requests.
Also available in Python: ../references/http-endpoints.py
Also available in Rust: ../references/http-endpoints.rs
Code using this pattern commonly includes, when relevant:
registerWorker(url, { workerName }) — worker initializationregisterFunction(id, handler) — define the route handlerregisterTrigger({ type: 'http', config: { api_path, http_method } }) — bind path and methodreq.body — parsed request body for POST/PUTreq.path_params — extracted path parametersreturn { status_code: 200, body: { data }, headers: { 'Content-Type': 'application/json' } } — response shapeconst logger = new Logger() — structured logging per handlerUse the adaptations below when they apply to the task.
path_params for resource identifiers (e.g. /orders/:orderId)middleware_function_ids) or inspect req.headers for tokens or API keysiii-http-middlewareiii-http-invoked-functions.iii-queue-processing for the background work.iii-http-middleware.iii-http-endpoints when iii owns the route and handles the inbound request directly.iii-http-endpoints in the iii engine.