palbaseDocs

Palbase Machines · API

POST/sites

Open a site

Opens a static web site (hosting). It answers at its label on the hosting domain — the project's ref for the site named web (the default), <name>-<ref> for any other. It serves nothing before its first release: a folder deployed (releases), or a build of its source, which a push to its branch makes.

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

Request body

namestring · optionalThe site's name; `web` when left out, which answers at the project's ref.
spaboolean · optionalA single-page app: a path no file answers is answered with /index.html.
sourceobject · optionalA GitHub repository's branch and the site's directory in it: one of the environment's installations reaches the repository (machines/github). In a change, a repository of "" takes the site's source away.
buildobject · optionalWhat a site's build runs; each left empty is found in its source: its lockfile (pnpm, yarn, npm, bun), its package.json's build script, the folder its builder writes (dist, build, out, …). A folder with no package.json is served as it is.
previewsboolean · optionalWhether a pull request opened against its source's branch is previewed: its head built, with this environment's build settings, into a release of its own that answers at <name>-pr<n>-<ref> until the pull request closes — never what the site serves, none of its releases; the pull request is told where in a comment. Any environment previews, production's too: the pull request's build runs with the environment's settings.
preview_forksboolean · optionalWhether a fork's pull requests are previewed (Site.preview_forks).
environmentstring · optionalThe ref of the environment called, when given: a new site is bound to the environment whose address it is made at (409 bound_to_environment for another — make it at that environment's address). Its name is the project's one: name_taken when another environment holds a site of that name.
serverobject · optionalA site's server: the machine of its environment that answers, on every address of the site, the paths `paths` names — each a prefix ending in /, an /api/ of the site's own — as it answers at its own address (woken, held to the environment's limits); none named, every path: a web app that runs on a server (Next.js, Nuxt, SvelteKit, Remix, Express), whose site is its address and domains. A pull request's preview of the site is answered by the machine's own preview of it once that is built. 10 paths at most; `/` is every path.
previews_protectedboolean · optionalWhether its previews are its team's alone; none is true.
curl
curl -X POST "https://<your-ref>.palbase.studio/sites" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"name":"string","spa":false,"source":{"repository":"string"},"build":{"install_command":"string","command":"string","output_dir":"string","env":{}},"previews":false,"preview_forks":false,"environment":"string","server":{"machine":"string","paths":["string"]},"previews_protected":false}'

Responses

201The site, serving nothing yet

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`, `insufficient_user_authentication`).

409The project already has a site of this name, or as many sites as it may (10)

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 CreateSite of machines's contract.