Palbase Machines · API
/machines/{name}Change a machine
Changes the machine's source, size, port, env, secrets or whether a push waits for its commit's checks (deploy_after_checks) and for which (deploy_checks, deploy_checks_app). A new size, port, env or secrets rolls out beside the version that serves; a new source is built, and rolls out once its build is up. Emits machine.updated. A machine may be given one of the project's databases (database): it is started with where the database answers, a database that is not the project's is refused (400 database_not_found), and so are its migrations while another machine runs them (409 database_migrated_elsewhere).
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-Matchstring · optionalThe ETag of the machine as the change was made from (GET); when it is not the machine's now — another change came between — the change is refused (412) and nothing is written. Without it the change is written over whatever came between.Request body
portinteger · optionalThe TCP port the machine listens on; requests to its address are sent there. The machine also finds it in PORT. A change of it rolls out as any change does: while both versions serve, each is sent requests at its own port.sizestring · optionalThe machine's size. shared-256 has a fraction of a CPU as its ceiling and is put to sleep when it is idle; a standard size never sleeps — its CPUs are its ceiling, a quarter of them reserved for it, the rest its node's when the other machines there leave them; a dedicated size has whole CPUs of its own and never sleeps. shared-256: 0.2 vCPU, 256 MiB (free); starter: 0.5 vCPU, 512 MiB; standard-1x: 1 vCPU, 2048 MiB; standard-2x: 2 vCPU, 4096 MiB; standard-4x: 4 vCPU, 8192 MiB; standard-8x: 8 vCPU, 16384 MiB; highmem-4x: 4 vCPU, 16384 MiB; highmem-8x: 8 vCPU, 32768 MiB; dedicated-1x: 1 vCPU of its own, 2048 MiB; dedicated-2x: 2 vCPU of its own, 4096 MiB. GET /machines/sizes lists each with its price.envobject · optionalReplaces the machine's environment whole, besides PORT. Names are environment variable names; 100 variables and 64 KiB at most. Keep secrets in the project's secrets and start the machine with them (`secrets`).secrets"" | "production" | "development" · optionalThe project's secret environment the machine is started with; empty for none.sourceobject · optionalWhere a machine is built from: a branch of a GitHub repository one of the project's installations of Palbase Cloud reaches (GET /machines/github/repositories), and a directory of it. A push to the branch is built — using the directory's Dockerfile, or automatic runtime detection (Node, Bun, Go, Python, …) when no Dockerfile is present — and rolled out when it changes a file in what the build is given: its context (`context`, else `path`), matched by whole directory names, case-sensitively; a push that changes nothing there leaves the machine as it runs, and does not count against the project's builds for the day. A machine built from the repository's root is built by every push. When what GitHub names of a push may not be all it changed — a forced push, a branch's first push, a push of 2048 commits or more, a commit naming no files (an empty commit among them) or 3000 or more — every machine built from the branch is built.health_pathstring · optionalA new health path: the machine rolls out with it. Empty lets its build say.replicasinteger · optionalHow many copies of the machine run from now on: the machine rolls out as a new version with that many, beside what serves. Of a machine its load scales (autoscaling), the fewest copies it runs, two at least: no new version.always_onboolean · optionalWhether it is kept awake from now on (Machine.always_on): no version changes. Turning it on is open to a project on Pay as you go, refused `always_on_not_available` otherwise.previewsboolean · optionalWhether its pull requests are previewed from now on (Machine.previews): the previews open stay until their pull requests close. A preview takes none.preview_forksboolean · optionalWhether a fork's pull requests are previewed from now on (Machine.preview_forks).databaseobject · optionalThe database a machine is given: the machine is started with where it answers (PALBASE_DB_URL), by the application's login, and with how many connections to it a copy may hold (PALBASE_DB_CONNECTIONS) — a share of what the database's size allows, the copies of every machine given it counted twice (a new version comes up beside the one that serves) and a migration run's share apart. Copies those would not serve are refused (409 `database_connections_short`); the other machines given it roll out to their new share. A change gives it whole: `migrations` left out is false.deploy_after_checksboolean · optionalWhether a push waits for its commit's checks from now on; no version is rolled out for it. The newest build waiting for its checks when it is turned off is built at once, and the older ones are left behind. A push is built only once its commit's checks on GitHub have passed: those `deploy_checks` names, or else every check run reported on the commit for the machine's branch (GitHub Actions' jobs, and any other app's checks; Palbase's own left out) has ended in success, neutral or skipped, and every GitHub Actions workflow run of it has ended — taken as ended 30 s after the last ended, and no sooner than 30 s after the push's build was made. Until then the build waits (`waiting_checks`, its `reason` naming what it waits for), and the machine runs what it ran; a newer push waits beside it, for its own. The machine moves to the newest commit whose checks passed, never back: the first to pass is built and leaves the older builds behind, waiting or under way, so an older commit whose checks pass after it is not built. A check that ended otherwise (failure, cancelled, timed_out, action_required, stale), no check reported in 10 minutes, or checks not ended in 3 hours (6 hours for named ones), and the build is `skipped` (`reason`); a check run again that passes later does not build it — the next push to the branch is built then, whatever it changed. Commit statuses are not read.deploy_checksstring[] · optionalThe check runs a push waits for (`deploy_after_checks`) instead of every check, by their names as GitHub shows them — a GitHub Actions job's name, e.g. `unit` — from the app `deploy_checks_app` names, on the commit's suites for the machine's branch (a run of the same commit from a tag or another branch does not count, nor another app's run of that name): each is to be reported, to end and to succeed (success or neutral: a named check skipped did not run) — every run of that name, when two workflows name a job alike. While a suite of that app is open on the branch, with runs or not yet, the push waits. No other check is waited for or looked at. A named check that ends otherwise, or that the app's suites on the branch all ended without (cancelled before they ran), and the build is `skipped` at once (`reason`); one not reported in 6 hours, too. 20 names at most, each 1 to 200 characters with no space around it, named once. Replaces the names whole; empty waits for every check again. No version is rolled out for it.deploy_checks_appstring · optionalThe app named checks (`deploy_checks`) are taken from, by its GitHub App slug — as a required check's expected source is: another app's run of a named check counts for nothing. No version is rolled out for it.test_commandstring · optionalWhat each new build of the machine runs before it takes traffic (a pre-deploy test step): once its database's migration has started, the new version comes up beside the one that serves — its own env, secrets and database — and its image runs this command in a shell (so the image has one) against it: `PALBASE_TEST_BASE_URL` is where it answers, `PALBASE_TEST_AUTH_URL` the project's auth. The tests reach what the machine reaches — its database, the project's modules — so they write as it does. They end other than 0 and the build fails, its `reason` naming the tests that failed: the version never takes traffic, the machine runs what it ran, and the migration is taken back. `bun test`, `npm test`. A build is tested as the machine says when it is released. Absent, a build rolls out once built. An empty string runs none from now on.test_usersstring[] · optionalThe project's test users each test run makes for its tests to act as — `PALBASE_TEST_IDENTITIES` names them, each with its access token (`api.signInAs("alice")`) — and deletes once the run has ended, however it ended. Each a name, once whatever its case: letters, digits, `_` and `-`, 64 at most.openapi_pathstring · optionalWhere the machine's app serves its contract from now on: nothing that runs changes, and the contract of the build it serves from is read again. Empty for a palbase/backend app.autoscalingobject · optionalHow a machine's copies follow its load: as many run as keep each copy near the share of its size's processor and of its memory given here, from the machine's replicas (the fewest, two at least) to max_replicas, spread for high availability. The platform adds a copy within seconds of copies running above that share, and scales down after five minutes under it. A copy added or taken away starts no other copy anew: what a copy is told (PALBASE_REPLICAS) and its share of a database are of max_replicas. Each copy is paid for while it runs, as any copy; on Pay as you go only (Free runs one copy). Null: the machine runs its replicas, that many always — in a change, it no longer scales. A change of autoscaling, or of replicas while it scales, is no new version and starts no copy anew, but for max_replicas.curl -X PATCH "https://<your-ref>.palbase.studio/machines/<name>" \
-H "apikey: $PALBASE_SECRET_KEY" \
-H "content-type: application/json" \
-d '{"port":1,"size":"dedicated-1x","env":{},"secrets":"","source":{"repository":"string","branch":"string"},"health_path":"string","replicas":1,"always_on":false,"previews":false,"preview_forks":false,"database":{"name":"string"},"deploy_after_checks":false,"deploy_checks":["string"],"deploy_checks_app":"string","test_command":"string","test_users":["string"],"openapi_path":"string","autoscaling":{"max_replicas":2}}'Responses
200The machine, with the change asked for
400Validation failed or a required field is missing
401Missing or invalid API key
403Not the project's secret key; or the request requires elevated owner authentication (`owner_only`); or the size is not open to the project (`size_not_available`, its reason as GET /machines/sizes and /databases/sizes say it).
404The project has no machine of this name
409The project already has a machine of this name, or has as many machines as it may
412`precondition_failed`: the machine changed since the read If-Match names; read it again and make the change on what it is now
429Over the project's request limit, or its machine time for this period is used up
503Temporarily unavailable; retrying is safe after Retry-After
defaultAn error: the envelope names it (`error`) and explains it (`error_description`).
Operation UpdateMachine of machines's contract.