moxzi
Docs / Reference / moxzid HTTP API

moxzid HTTP APIalpha

Every moxzid endpoint, with its request, response and authentication.

ACTOR is an actor's manifest name or its hex id. "Token" means the endpoint requires Authorization: Bearer TOKEN when the server has a token. Paths are matched exactly, including the query string, except on website routes.

Calling actors#

Method and pathBodyResponseAuth
POST /call-json/ACTOR/METHODJSON array of argumentsJSON array of resultsToken
POST /query-json/ACTOR/METHODJSON array of arguments. Update methods are refusedJSON array of resultsToken
POST /call/ACTOR/METHODCandid-encoded argumentsCandid-encoded replyToken
POST /query/ACTOR/METHODCandid-encoded arguments. Composite queries are supportedCandid-encoded replyToken
GET /openapi/ACTOROpenAPI 3.1 document for the JSON endpointsToken

Request headers:

HeaderEffect
x-caller: PRINCIPALSets msg.caller for the message. Default: the anonymous principal. Not authenticated

JSON errors are returned as {"code": N, "message": "…"}. Add ?lossless=1 to a JSON call for the lossless encoding, which keeps every distinction Candid makes (for example, a nat64 is {"$moxzi": "nat64", "value": "…"}).

Managing actors#

Method and pathBodyResponseAuth
GET /actors[{"name": …, "id": …}]Token
POST /install/NAMEwasm moduleThe new actor's hex id. Refused if NAME existsToken
POST /upgrade/ACTORwasm module, or empty to reload the manifest's fileupgradedToken
POST /upgrade/ACTOR?report=1as aboveJSON report of stable-variable and interface changesToken
POST /upgrade/ACTOR?force=trueas aboveSkips the stable-compatibility check. The runtime still refuses an upgrade it can't applyToken
GET /cycles/ACTORRemaining cycles, as decimal textToken
POST /cycles/ACTORCycles to add, as decimal textNew balanceToken

Observing#

Method and pathResponseAuth
GET /logs/ACTORThe actor's Debug.print output since the last read. Reading clears itToken
GET /events/ACTORThe same output as a server-sent event stream. Shares the buffer with /logsToken
GET /history/ACTORJSON array of recent messages (method, caller, argument preview, outcome)Token
GET /inspectJSON snapshot of every actor: id, name, cycles, heap size, message and trap counts, methods, Candid interfaceToken
GET /metricsPrometheus metricsToken
GET / (without --web), GET /inspectorThe inspector pageOpen

Health#

Method and pathResponseAuth
GET /healthokOpen
GET /health/readyready, or 503 and a progress note while startingOpen
GET /versionVersion and buildOpen

Every response has a moxzid-version header.

Websites#

Method and pathEffectAuth
Any method, /site/ACTOR/PATHSent to the actor's http_request (query), then to http_request_update if it returns upgrade = ?trueOpen
Any method, any other path, with --web ACTORSame, for ACTOR, at the rootOpen

The request reaches the actor as { method; url; headers; body; certificate_version } with certificate_version = null. The Authorization header isn't forwarded. The actor's status, headers and body are returned as is, except Content-Length, Connection and Transfer-Encoding.

Website errorStatus
No such actor404
The actor has no http_request method502
The reply isn't a valid HTTP response record502

Other#

Method and pathResponseAuth
GET /mops/closure/ENTRYEvery source file ENTRY depends on, as JSON with base64 contents. Requires --project; paths outside it are refused with 403Token
OPTIONS on any non-website path204, for CORS preflightOpen

Every response includes Access-Control-Allow-Origin: *.

Status codes#

StatusMeaning
200Success
204CORS preflight
400Bad request, bad arguments, or the method trapped or rejected
401Missing or wrong token
402The actor is out of cycles
403/mops/closure path outside --project
404No such actor or path
413Body too large: 192 MiB for authenticated control/service routes, 8 MiB for public actor and website routes
500The actor produced no reply
502Website request the actor couldn't answer
503Still starting, or the actor's thread has stopped
On this pageCalling actorsManaging actorsObservingHealthWebsitesOtherStatus codes