palbaseDocs

Palbase Machines · API

GET/machines/{name}/openapi

Read a machine's API contract

The contract (OpenAPI) of the build the machine serves from, kept with the build so it is answered without waking the machine and two versions never mix. A palbase/backend app's is written as its build ends: the build's image is run once — the machine neither woken nor changed, the run given none of its secrets — and its app reads its source for what each route answers and throws, and writes the contract; until it has, the answer is 503 contract_pending with Retry-After, and a build whose app wrote none is 422 contract_refused, saying why (a route its source does not type, a source that does not compile, a palbase/backend older than contracts written at build time). Another app's is read where the machine's openapi_path says, once that build's version alone answered at the machine's address — never while an older one still answered beside it — asked on the platform's own channel, signed with the machine's PALBASE_PLATFORM_SECRET; until it has been read it is asked live: a sleeping machine is woken for it, the call held a few seconds (503 machine_waking with Retry-After past that); a machine with no build up yet answers none (503 machine_building). A machine whose app is neither has no contract (404 not_a_palbase_backend). The answer carries its SHA-256 (ETag, Palbase-Contract-Digest; the machine's contract_digest): If-None-Match with it answers 304. A contract asked live is read up to 2 MiB (502 contract_too_large past it) and must be a JSON object (502 contract_unreadable); an app that cannot be asked — its connection ends, it answers late or answers another status — is 503 machine_unreachable. A project whose machine time is used up wakes nothing (429 quota_exceeded).

Called by your server, with the project's secret key.

Path

namestring · requiredThe machine's name: lowercase letters, digits and dashes, starting with a letter and not ending with a dash, 32 at most.

Headers

If-None-Matchstring · optionalThe ETag of a contract held already: 304 while it is still the one the machine serves from.
curl
curl -X GET "https://<your-ref>.palbase.studio/machines/<name>/openapi" \
  -H "apikey: $PALBASE_SECRET_KEY"

Responses

200The machine's contract, as its app served it

304The contract named by If-None-Match is still the one the machine serves from

400Validation failed or a required field is missing

401Missing or invalid API key

403Not the project's secret key

404The project has no machine of this name (`machine_not_found`), or the machine's app has no contract: it is not a palbase/backend app, and no openapi_path is given for it (`not_a_palbase_backend`)

422The build's app wrote no contract (`contract_refused`): its message says why — a route its source does not type, a source that does not compile, or a palbase/backend older than contracts written at build time

429Over the project's request limit, or its machine time for this period is used up

502The machine's app answered a contract larger than 2 MiB (`contract_too_large`), or one that is not a JSON object (`contract_unreadable`)

503The build's contract is being written (`contract_pending`), the machine has no build up yet (`machine_building`), is waking (`machine_waking`), could not be woken (`machine_unavailable`), or its app could not be asked (`machine_unreachable`); retrying is safe after Retry-After

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation GetMachineContract of machines's contract.