Skip to content

HTTP Surface Reference

Reference: every byte the host serves.

POST /api/event — the Event API (envelope wire)

Mirrors the engines' event.api.service:

Aspect Behavior
Request body event envelope bytes (standard wire format)
x-ttl header execution bound in ms (floor 1000); a value that is no whole number counts as none
x-async: true drop-n-forget → HTTP 202 with ack envelope {type: async, delivered: true, time}
Reply always envelope bytes, content-type: application/octet-stream
Handler outcome rides HTTP 200 with the status inside the envelope (including AppException and unexpected errors)
Transport failures set the HTTP status too: 400 undecodable / missing route field, 403 private target, 404 unknown route (Route X not found), 408 timeout (Timeout for N ms), 413 a body over the 16 MiB the host reads into memory (Request body exceeds 16777216 bytes), 500 a reply the wire codec refuses (Reply cannot be rendered; in band, as the terminal frame, once a stream has started). Behind a rest.yaml entry the edge's own refusals (401, 413) are the engines' JSON error body, which the pack's client and the engines' read as the failure it carries
Header hygiene inbound x-event-api and my_* removed; the my_cid tag becomes the read-only my_correlation_id header (local bus deliveries inject the same view). Outbound, the client stamps the current context's business correlation-id back onto the event as the my_cid tag — the engines' PostOffice parity, so the business correlation-id continues across every hop
accept: text/event-stream streaming-capable call to an interceptor target: a streamed reply rides the same call as SSE in the envelope-mode dialect; a single-shot reply stays byte-identical; a streaming reply to a NON-accepting caller → 406 Streaming function requires a caller that accepts text/event-stream. See Event Streaming

Actuator endpoints

All JSON responses are pretty-printed with content-type: application/json; charset=utf-8 (the engines' default-serializer presentation).

Endpoint Content type Shape
GET / text/html the static folder's index.html, else a minimal index page linking the endpoints
GET /info JSON {app{name,version,description}, runtime{language,python,mercury_composable}, origin, time{start,current}, up_time}
GET /info/routes JSON {app, routing{public{route: instances}, private{...}}}
GET /env JSON {app, env{environment{...}, properties{...}}} (opt-in lists)
GET /health JSON {dependency[...], status: UP\|DOWN, origin, name} — HTTP 200 when UP, 400 when DOWN
GET /livenessprobe text/plain OK, or HTTP 400 Unhealthy. Please check '/health' endpoint.

Each /health dependency entry: {route, required, ...info-map, status_code, message} — the info map comes from the function's type=info reply; a missing route reports status_code: 404 with Please check - Route X not found.

  • origin — unique instance id, minted once per process: UTC yyyyMMdd + 32-hex uuid (the Java reference engine's format).
  • up_time — the engines' rendering (59 seconds, 1 minute 1 second, …).

REST automation entries (opt-in)

With rest.automation: true (guide) the entries of rest.yaml are served first, in the engines' grammar; POST /api/event and the actuators are the default entries.

Aspect Behavior
Matching the engines' precedence — the most specific route wins, {param} and a trailing *; a known path under another method → 405 Method not allowed; an unknown path → 404 Resource not found; OPTIONS → 204 with the entry's CORS options lines, 405 without a CORS block
Request to the function the whole request as the AsyncHttpRequest map — method, url, headers (lowercased, after the request transform), path and query parameters (a form's fields among them), the body parsed by its content type (JSON → map or list, text types → text, else bytes), cookies, the session map an authentication function left; x-ttl carries the entry's timeout in ms
Reply a returned value is the body; a returned EventEnvelope sets the status and headers (set-cookie values split on \|); the content type is the function's or negotiated from Accept (text/html wraps a map in the HTML shell; no Accept → no content type); a map or list is pretty-printed JSON with null entries omitted
Errors the engines' body below with content-type: application/json: an AppException from the function or the authentication function (anything but true from the latter → 401 Unauthorized); 408 Timeout for N ms at the entry's timeout (1 s–5 min, 30 s default; an inbound x-ttl that is a whole number wins); 503 Service X not reachable for an unregistered function; 413 Upload exceeds N bytes and the 400s of an upload a form does not send; 413 Request body exceeds 16777216 bytes for a body over the 16 MiB the host reads into memory; 500 Reply cannot be rendered for a reply the serializer refuses
Correlation and tracing X-Correlation-Id (or http.correlation.id.header) always ensured and echoed, delivered as my_correlation_id; with tracing: true a W3C traceparent, else X-Trace-Id (http.trace.id.header), else a fresh id, and the http.request record plus the function's round-trip record; a refusal while the body is read (400, 413) leaves the http.request record too
stream: true an interceptor's segments rendered progressively: Server-Sent Events (event:/data: frames, event: done at the end, event: error in band, : ping keep-alives every event.stream.keep.alive) for a text/event-stream head or Accept, chunked text or JSON lines otherwise; the entry's timeout is the idle allowance, the head's x-ttl (a whole number of seconds) overrides it; a keep-alive that cannot be written ends the stream; a segment the serializer refuses fails it in band with 500 Reply cannot be rendered
upload: true a POST entry's multipart/form-data files in the request map (filename, file_type, file_length, upload, size, bytes in contents), the form's text fields as query parameters, no body; the files and the text fields together, counted in bytes, within rest.upload.max.bytes (16 MiB). Read as a browser's form sends it, the same in both packs: a part is form-data with a name and, for a file, a filename (an empty one included), either also in the extended form name* / filename* (RFC 5987: UTF-8 or ISO-8859-1, percent-encoded), which wins; a file's type is its Content-Type as written or application/octet-stream, its bytes as they arrived; a text field is UTF-8, or the ISO-8859-1 or US-ASCII its part declares. Anything else → 400 by name: a part that is multipart itself (Upload takes text fields and files, not a nested multipart part), a part without a name, a name* or filename* that is malformed, in another charset or not the text it declares, a Content-Transfer-Encoding other than 7bit, 8bit, binary, a Content-Encoding, another charset, a field that is not the text it declares, a body not delimited as declared (Invalid multipart body - ...)
Precedence a rest.yaml entry, then an extension's mounted routes (Platform.add_routes), then the static folder (under the static-content block's no-cache-pages and filter), then the error signature below

Static content

A GET or HEAD of any other path is answered with the file it names inside static.html.folder (resources/public next to the application file by default; index.html for a folder) when there is one: the content type by extension from the engines' table, an ETag (If-None-Match answers 304 with no body) and, for HTML, Cache-Control: no-cache. A path that names nothing — including a hidden entry, a link out of the folder or a folder without an index page — falls through to the error signature below. See the guide.

Error signature (host-level)

Unknown paths and non-GET methods on known paths answer the engines' shape — pretty-printed JSON:

{
  "status": 404,
  "message": "Resource not found",
  "type": "error"
}

Handler-level errors never use this shape on /api/event — they ride the envelope. Behind a rest.yaml entry a function's AppException does render as this shape, as in the engines.