Palbase Machines · API
/machines/{name}/previews/{pull_request}Open or update a platform's pull request preview
For a platform — PalCore — that previews its product's machine itself: one read with its tokens (source.access token), whose pull requests are not heard here, or one read with Palbase's GitHub App, whose numbers then are the platform's (a pull request GitHub told of keeps its own: 409 preview_taken). Opens the preview of the pull request at the head of its branch — one of the machine's repository's own: a fork's is not built — its own machine, <name>-pr<n>, and a database of its own when the machine runs its database's migrations — or builds the open one at it, and opens one that went idle again. A machine read with tokens has its branch read with git_access_token, a GitHub App installation's token for the machine's repository alone (ghs_…), once (400 token_required without); one read with Palbase's App, with the project's installation (400 token_not_taken with one). A commit named must be the branch's head (409 commit_not_head). Any environment previews, production's too: the preview runs with its settings, secrets and users. Its address and state are read with GET /machines/{name}/previews; the platform tells its pull request itself. Refused with previews off (409 previews_off), and when the environment's limits refuse the preview (409 preview_refused, with why).
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.pull_requestinteger · requiredThe pull request's number.Request body
branchstring · requiredThe pull request's branch, of the machine's repository itself: a fork's pull request is not built with the environment's secrets.commitstring · optionalThe branch's head, its full SHA: a newer push answers 409 commit_not_head. Left out, the branch's head.git_access_tokenstring · optionalFor a machine read with a platform's tokens (source.access token), and required for one: a GitHub App installation's token (ghs_…) for the machine's repository alone, read-only, used once, never kept. A machine read with Palbase's GitHub App takes none (400 token_not_taken): its branch is read with the project's installation.curl -X PUT "https://<your-ref>.palbase.studio/machines/<name>/previews/<pull_request>" \
-H "apikey: $PALBASE_SECRET_KEY" \
-H "content-type: application/json" \
-d '{"branch":"string"}'Responses
202The preview is being built at the commit
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
409The project already has a machine of this name, or has as many machines as it may
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 PutMachinePreview of machines's contract.