Server4Agent REST API reference

Version 0.1.0. Base URL: https://api.server4agent.com. Every request authenticates with Authorization: Bearer sk_live_..., and every request with a body sends Content-Type: application/json.

REST API for Server4Agent: provision servers, run agent tasks and builds, manage projects and files, and subscribe to webhooks. This is the code *around* your agent (your backend, a CI job, a webhook receiver). If your agent itself does tool-calling, point it at the MCP server instead. Authenticate every request with an sk_live_ API key as a bearer token: Authorization: Bearer sk_live_.... Keys are server-side secrets, so never ship them in a browser bundle. Scoped keys can access only their explicitly allowed servers and projects. Account-level operations such as creating servers, managing keys, and managing webhooks require an account-wide key.

Also available as Markdown and as the OpenAPI spec. Guides: REST API, Examples.

Servers

Sized compute boxes. Multiple projects share a server's resources.

GET /servers

List servers

Responses:

  • 200 The caller's servers.
  • 401 Missing or invalid API key.
Fields in a 200 response
NameTypeRequiredDescription
serversServer[]yes

POST /servers

Provision a server

No plan field: the allowed tiers and limits come from the account behind the key.

Request body (JSON)
NameTypeRequiredDescription
taskstringno
tiersmall | medium | largeno
kindstandard | browsernoDefaults to standard.
regionus | eu | senoWhere the server runs, fixed once it exists. us (United States) is the default. eu runs the server, its files and its apps in Europe, in Germany, and se in Europe, in Sweden. Asia is not open yet and is refused rather than placed somewhere else.
secretsSecretInput[]noServer-wide environment variables to set and bind, shared by all projects on the server.

Responses:

  • 201 The provisioned server.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 403 The key is scoped, or the account's plan does not allow the requested server.
Fields in a 201 response
NameTypeRequiredDescription
idstringyes
urlstring, nullableno
statusrunning | sleeping | buildingyes
tiersmall | medium | largeyes
kindstandard | browsernoWhat kind of box a server is, orthogonal to its tier. standard is headless. browser adds a screen with a browser on it, so a run can drive sites that need a real one. A browser box costs more to run and needs a plan that allows the medium tier.

GET /servers/{serverId}

Get a server

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.

Responses:

  • 200 The server.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
serverServeryes

PATCH /servers/{serverId}

Rename or relocate a server

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
Request body (JSON)
NameTypeRequiredDescription
taskstringno
regionus | eu | senoA server cannot change region, so only the one it is in is accepted. To run somewhere else, create a server there.

Responses:

  • 200 The updated server.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
serverServeryes

DELETE /servers/{serverId}

Delete a server

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.

Responses:

  • 200 Deleted.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
idstringyes
deletedtrueyes

POST /servers/{serverId}/actions

Start, stop, or restart a server

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
Request body (JSON)
NameTypeRequiredDescription
actionstart | stop | restartyes

Responses:

  • 200 The server's new state.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
  • 502 The compute backend returned an error.
Fields in a 200 response
NameTypeRequiredDescription
idstringyes
statusrunning | sleeping | buildingyes

POST /servers/{serverId}/exec

Run a shell command on the server

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
Request body (JSON)
NameTypeRequiredDescription
commandstringyes
project_idstringnoOptional. Run the command inside this project's workspace folder instead of the server workspace root. The project must live on this server.

Responses:

  • 200 Command output.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.
Fields in a 200 response
NameTypeRequiredDescription
stdoutstringyes

Tasks

Give the on-server agent a goal; it plans, writes code, runs it, and can deploy.

GET /servers/{serverId}/tasks

List a server's tasks

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.

Responses:

  • 200 Tasks.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
tasksTask[]yes

POST /servers/{serverId}/tasks

Give the agent a goal

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
Request body (JSON)
NameTypeRequiredDescription
goalstringyes
project_idstringnoOptional. Run in this project's workspace folder. Omit to run at the server workspace root. The project must live on this server. Not needed with follow_up_of, which runs where the earlier task did.
follow_up_ofstringnoOptional. The id of an earlier task on this server to continue. Without it every task starts a new conversation. With it the agent picks up that task's conversation, in the same folder and project, so it remembers what it did. Use it to answer a task that is awaiting_input or to ask for changes to what a task built.

Responses:

  • 201 The created task.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 402 Authorized, but the account is out of budget (credits/cap reached).
  • 404 No such resource.
  • 409 The server is paused (server_paused), or the follow_up_of task's project is paused (project_paused).
Fields in a 201 response
NameTypeRequiredDescription
task_idstringyes
statusrunning | completed | failed | awaiting_input | cancelledyes
project_idstring, nullableno
follow_up_ofstringnoPresent when the task continues an earlier one.
resumedbooleannoPresent on a follow-up. False when the earlier task left no conversation to pick up: the agent then works in the same folder without that memory.

GET /servers/{serverId}/tasks/{taskId}

Get a task

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
taskId (path)stringyes

Responses:

  • 200 The task.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
taskTaskyes

Builds

Structured build pipeline (plan → scaffold → implement → install → build → deploy).

GET /servers/{serverId}/builds

List a server's builds

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.

Responses:

  • 200 Builds.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
buildsBuild[]yes

POST /servers/{serverId}/builds

Start a build pipeline

Starts an agent run on the server that plans, scaffolds, writes, installs, builds and starts what the goal describes. Poll getBuild for the result; it counts against the AI budget like any run.

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
Request body (JSON)
NameTypeRequiredDescription
goalstringyes

Responses:

  • 201 The started build.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 402 Authorized, but the account is out of budget (credits/cap reached).
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.
Fields in a 201 response
NameTypeRequiredDescription
build_idstringyes
statusqueued | running | completedyes
stepsBuildStep[]yes

GET /servers/{serverId}/builds/{buildId}

Get a build

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
buildId (path)stringyes

Responses:

  • 200 The build.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
buildBuildyes

Logs

Log-file tails from a server's background processes. Every long-running process a project starts appends to a log file in its workspace; the latest tails are captured after each task.

GET /servers/{serverId}/logs

Get a server's log tails

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
project_id (query)stringnoOnly log files from this project's workspace folder.
lines (query)integernoMax tail lines per file.

Responses:

  • 200 The latest log snapshot, or null when the server has not reported one yet.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
logsLogsSnapshotyes

Files

Read and write files in a server's workspace.

GET /servers/{serverId}/files

List files, or read one with ?path=

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
path (query)stringnoWhen set, returns that file's content instead of the file list.

Responses:

  • 200 A file listing, or a single file's content.
  • 401 Missing or invalid API key.
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.

PUT /servers/{serverId}/files

Write a file

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
Request body (JSON)
NameTypeRequiredDescription
pathstringyes
contentstringyes
encodingutf8 | base64noSet to base64 to upload binary content (e.g. a .zip to use as an archive project source) without corrupting the bytes.

Responses:

  • 201 Written.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.
  • 413 The content is larger than a single write carries.
  • 500 The workspace ran the write and refused it (out of disk space, the path is a folder).
  • 503 The write never reached the server. Safe to retry once it is awake.
Fields in a 201 response
NameTypeRequiredDescription
pathstringyes
writtentrueyes

DELETE /servers/{serverId}/files

Delete a file

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
path (query)stringyes

Responses:

  • 200 Deleted.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.
Fields in a 200 response
NameTypeRequiredDescription
pathstringyes
deletedtrueyes

GET /servers/{serverId}/files/download-url

Mint a signed download link for one file

Returns a signed, expiring link to exactly one file in the server's workspace. Anyone holding the link can download that file without an API key until it expires, so share it like a password. Platform files are refused.

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
path (query)stringyesWorkspace path of the file, e.g. report.xlsx.
ttl_seconds (query)numbernoHow long the link stays valid. Defaults to 24 hours, capped at 7 days.

Responses:

  • 200 The signed link.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.
Fields in a 200 response
NameTypeRequiredDescription
pathstringyes
urlstring (uri)yes
expires_atstring (date-time)yes

Deployments

Record a deployment against a server. It starts nothing: a project serves at its own URL once it is public and something inside it is running and listening for HTTP.

GET /servers/{serverId}/deployments

List a server's public projects

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.

Responses:

  • 200 Deployments.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
deploymentsDeployment[]yes

POST /servers/{serverId}/deployments

Put a running project online

Checks that something in the project is listening on its listen port, makes the project public, and waits for its URL to answer. It builds and starts nothing: when nothing is listening it answers 409 and leaves the project as it was. Without project_id, a server with exactly one project deploys that one.

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
Request body (JSON)
NameTypeRequiredDescription
project_idstringnoThe project to deploy. Optional when the server has exactly one project.

Responses:

  • 201 The project is public. status is live when its URL answered, and publishing when it had not answered yet.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 402 Authorized, but the account is out of budget (credits/cap reached).
  • 404 No such resource.
  • 409 Nothing to deploy: the server has no project (no_project), nothing is listening on the project's port (not_listening), or the server is paused (server_paused).
  • 502 The compute backend returned an error.
Fields in a 201 response
NameTypeRequiredDescription
urlstring (uri)yes
statuslive | publishingyes
project_idstringno

Projects

A workspace + app inside a server, with its own slug and public URL. A project's workspace can be seeded from a source (blank, a named template, a git repo, or an uploaded archive), then initialized: the on-server agent installs dependencies, starts the app, and confirms the service is up.

GET /servers/{serverId}/projects

List a server's projects

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.

Responses:

  • 200 Projects on the server.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
projectsProject[]yes

POST /servers/{serverId}/projects

Create a project on a server

Defaults to private; pass visibility=public to expose its URL. Pass a source to seed the workspace from a template, a git repo, or an uploaded archive. When the source carries code (git/archive) and auto_init is true (the default for those sources), the response includes an init_run_id: the on-server agent seeds the workspace, installs dependencies, starts the app, and confirms the service is up. Poll the project's init_phase until it is ready or failed.

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
Request body (JSON)
NameTypeRequiredDescription
namestringno
descriptionstringno
visibilitypublic | privateno
accesspublic | team | passwordnoWho may open a public project's URL. public is anyone with the link, which is how every project behaved before this field existed. team requires the visitor to sign in to Server4Agent and be a member of the account that owns the project. password asks the visitor for a password the owner set with access_password, and needs no account. No effect while the project is private, since there is no URL to gate.
access_passwordstringnoThe password visitors enter when access is password, which requires it. Stored encrypted and never returned. Rejected with 400 alongside any other access.
lifecyclepersistent | ephemeralno
sourceProjectSourcenoWhere to seed the workspace from. Omit for a blank project. A git or archive source carries your own code to install and run.
auto_initbooleannoDispatch bring-up (seed, install, start, confirm it answers) immediately on create. Defaults to true when source carries code (git/archive), false otherwise. When true, the response carries an init_run_id.
secretsSecretInput[]noProject-scoped environment variables to set and bind (only this project's runs see them). Provide known values up front so bring-up doesn't pause at awaiting_secrets for keys the code requires.
templatestringnoShorthand for source: { kind: template, template: <id> }, using a template id from listTemplates. Ignored if source is also given.

Responses:

  • 201 The created project.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 403 The account hit a plan limit (e.g. a tier's project cap).
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.
Fields in a 201 response
NameTypeRequiredDescription
idstringyes
server_idstringyes
namestringyes
slugstringyes
descriptionstring, nullableno
visibilitypublic | privateyes
accesspublic | team | passwordnoWho may open a public project's URL. public is anyone with the link, which is how every project behaved before this field existed. team requires the visitor to sign in to Server4Agent and be a member of the account that owns the project. password asks the visitor for a password the owner set with access_password, and needs no account. No effect while the project is private, since there is no URL to gate.
lifecyclepersistent | ephemeralyes
runtime_statusunbuilt | running | pausedyesPause/resume state of a built project. Distinct from init_phase: a project runs through init_phase from creation to its first ready, after which runtime_status governs whether its processes are running or paused.
sourceProjectSourcenoHow this project's workspace was seeded. Absent for legacy projects created before sources existed.
init_phaseseeding | awaiting_plan | awaiting_secrets | installing | starting | ready | failednoBring-up progress; absent once the project is a long-lived running app (see runtime_status) or for an unbuilt blank project.
run_planRunPlannoHow bring-up installs and starts this project, or null when no plan has been settled yet. A plan whose port is null means the project is not a server.
templatestring, nullablenoConvenience mirror of source.template when the source is a named template. Kept for backward compatibility; prefer source.
urlstring, nullablenoLive URL, or null while the project is private.
created_atstring (date-time)yes
updated_atstring (date-time)yes
init_run_idstring, nullablenoThe bring-up run dispatched for this project when auto_init ran. Poll it like any task; null when no bring-up was dispatched (blank project, or auto_init=false).

POST /servers/{serverId}/projects/import

Import a project from an export bundle

Recreates a project on this server from a bundle that POST /projects/{projectId}/export produced, on this deployment or on another one. The bundle decides the project's name, description, lifecycle, link access and run plan; it never decides anything that would act on its own, so the project lands private with its own slug and URL regardless of what the original was. Environment variables the bundle names are bound only where this account already holds a value for them, because a bundle carries names and never values: missing_env lists what still has to be set here with PUT /secrets before the app can run. Bring-up always starts, because the bundle only reaches the server as part of that run; the response carries its init_run_id. Pass the bundle in one of two ways. Base64 in bundle travels in the request body, so the platform's request size limit holds it to about 3 MB. A bundle exported on this deployment can instead be passed as the url its export returned, in bundle_url, which carries bundles up to 25 MB. Larger bundles from another deployment can be uploaded from the dashboard, which takes up to 25 MB too.

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
Request body (JSON)
NameTypeRequiredDescription
bundlestring (byte)noThe export file, base64 encoded. Pass this or bundle_url.
bundle_urlstring (uri)noThe download link an export on this deployment returned, while it is still valid. Pass this or bundle.
namestringnoName the project here. Defaults to the name in the bundle.

Responses:

  • 201 The imported project.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 402 Out of AI credits. An import needs a bring-up run to unpack its files, so nothing was created.
  • 403 The account hit a plan limit (e.g. a tier's project cap).
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.
Fields in a 201 response
NameTypeRequiredDescription
imported_fromstring, nullablenoThe deployment the bundle was exported from, as its manifest recorded it.
exported_atstring (date-time)noWhen the bundle was built.
bound_envstring[]noVariables the bundle named that this account already had a value for.
missing_envstring[]noVariables the bundle named that still need a value here. Set them with PUT /secrets before the app can run.
warningsstring[]noThings the bundle asked for that this deployment could not honour. Not failures: the import succeeded, and each of these would otherwise only surface later as unexplained behaviour.

GET /projects

List every project across the caller's servers

Responses:

  • 200 Projects.
  • 401 Missing or invalid API key.
Fields in a 200 response
NameTypeRequiredDescription
projectsProject[]yes

GET /projects/{projectId}

Get a project

Parameters
NameTypeRequiredDescription
projectId (path)stringyes

Responses:

  • 200 The project.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
idstringyes
server_idstringyes
namestringyes
slugstringyes
descriptionstring, nullableno
visibilitypublic | privateyes
accesspublic | team | passwordnoWho may open a public project's URL. public is anyone with the link, which is how every project behaved before this field existed. team requires the visitor to sign in to Server4Agent and be a member of the account that owns the project. password asks the visitor for a password the owner set with access_password, and needs no account. No effect while the project is private, since there is no URL to gate.
lifecyclepersistent | ephemeralyes
runtime_statusunbuilt | running | pausedyesPause/resume state of a built project. Distinct from init_phase: a project runs through init_phase from creation to its first ready, after which runtime_status governs whether its processes are running or paused.
sourceProjectSourcenoHow this project's workspace was seeded. Absent for legacy projects created before sources existed.
init_phaseseeding | awaiting_plan | awaiting_secrets | installing | starting | ready | failednoBring-up progress; absent once the project is a long-lived running app (see runtime_status) or for an unbuilt blank project.
run_planRunPlannoHow bring-up installs and starts this project, or null when no plan has been settled yet. A plan whose port is null means the project is not a server.
templatestring, nullablenoConvenience mirror of source.template when the source is a named template. Kept for backward compatibility; prefer source.
urlstring, nullablenoLive URL, or null while the project is private.
created_atstring (date-time)yes
updated_atstring (date-time)yes

PATCH /projects/{projectId}

Rename, redescribe, toggle visibility/lifecycle, or correct the run plan

The slug and URL stay the same across visibility toggles. A run_plan here is recorded for the next bring-up, not acted on, so correcting a wrong start command never restarts a working project.

Parameters
NameTypeRequiredDescription
projectId (path)stringyes
Request body (JSON)
NameTypeRequiredDescription
namestringno
descriptionstringno
visibilitypublic | privateno
accesspublic | team | passwordnoWho may open a public project's URL. public is anyone with the link, which is how every project behaved before this field existed. team requires the visitor to sign in to Server4Agent and be a member of the account that owns the project. password asks the visitor for a password the owner set with access_password, and needs no account. No effect while the project is private, since there is no URL to gate.
access_passwordstringnoSets or changes the password for access password. Required when switching to password unless one is already set; sent on its own, it changes the password and signs out everyone who used the old one. Switching to any other access discards the password. Stored encrypted and never returned.
lifecyclepersistent | ephemeralno
run_planRunPlannoReplaces the stored plan wholesale, so send every field you want kept. Recorded for the next bring-up rather than acted on: POST /projects/{projectId}/init is how you ask for the rebuild. Rejected with 400 if neither install nor start is set.

Responses:

  • 200 The updated project.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 403 The account hit a plan limit (e.g. a tier's project cap).
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
idstringyes
server_idstringyes
namestringyes
slugstringyes
descriptionstring, nullableno
visibilitypublic | privateyes
accesspublic | team | passwordnoWho may open a public project's URL. public is anyone with the link, which is how every project behaved before this field existed. team requires the visitor to sign in to Server4Agent and be a member of the account that owns the project. password asks the visitor for a password the owner set with access_password, and needs no account. No effect while the project is private, since there is no URL to gate.
lifecyclepersistent | ephemeralyes
runtime_statusunbuilt | running | pausedyesPause/resume state of a built project. Distinct from init_phase: a project runs through init_phase from creation to its first ready, after which runtime_status governs whether its processes are running or paused.
sourceProjectSourcenoHow this project's workspace was seeded. Absent for legacy projects created before sources existed.
init_phaseseeding | awaiting_plan | awaiting_secrets | installing | starting | ready | failednoBring-up progress; absent once the project is a long-lived running app (see runtime_status) or for an unbuilt blank project.
run_planRunPlannoHow bring-up installs and starts this project, or null when no plan has been settled yet. A plan whose port is null means the project is not a server.
templatestring, nullablenoConvenience mirror of source.template when the source is a named template. Kept for backward compatibility; prefer source.
urlstring, nullablenoLive URL, or null while the project is private.
created_atstring (date-time)yes
updated_atstring (date-time)yes

DELETE /projects/{projectId}

Delete a project

Parameters
NameTypeRequiredDescription
projectId (path)stringyes

Responses:

  • 200 Deleted.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
idstringyes
deletedtrueyes

POST /projects/{projectId}/cleanup

Tear down an ephemeral project's runtime

Ephemeral projects only. Use delete for persistent ones.

Parameters
NameTypeRequiredDescription
projectId (path)stringyes

Responses:

  • 200 Cleaned up.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.
Fields in a 200 response
NameTypeRequiredDescription
idstringyes
cleanedtrueyes

POST /projects/{projectId}/start

Start a project's app and keep it running

Runs command in the project folder as a background process with PORT set to the project's routed port, records it so a server restart starts it again, and waits about 10 seconds for it to answer. The app must listen on PORT. A project's URL serves only while something listens there and the project is public. Starting again with the same name replaces the earlier process. Name a second process (a worker, a scheduler) to run it beside the web app; only web serves the URL.

Parameters
NameTypeRequiredDescription
projectId (path)stringyes
Request body (JSON)
NameTypeRequiredDescription
commandstringyesThe shell command that starts the app, e.g. node server.js.
namestringnoProcess name. Defaults to web, the process that serves the URL.

Responses:

  • 200 Started. status is starting while the web app has not answered yet.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
  • 409 The app could not be started (error is app_failed, with the last output in log_tail), or the project cannot run one right now (paused, no_port, unsupported, failed).
Fields in a 200 response
NameTypeRequiredDescription
project_idstringyes
namestringyes
statusrunning | startingyes
listeningbooleanyes
listen_portinteger, nullableno
urlstring, nullablenoThe project's URL when it is public, otherwise null.
visibilitypublic | privateno
accesspublic | team | passwordnoWho may open a public project's URL. public is anyone with the link, which is how every project behaved before this field existed. team requires the visitor to sign in to Server4Agent and be a member of the account that owns the project. password asks the visitor for a password the owner set with access_password, and needs no account. No effect while the project is private, since there is no URL to gate.
replaced_previousbooleanno
restart_commandstringyesWhat a server restart runs to bring this process back.
log_tailstring, nullableno

POST /projects/{projectId}/init

Start or resume a project's bring-up

Kicks off bring-up for a project that wasn't auto-initialized, or resumes one paused at awaiting_secrets. Pass proceed: true to continue past still-missing (optional) secrets instead of waiting.

Parameters
NameTypeRequiredDescription
projectId (path)stringyes
Request body (JSON)
NameTypeRequiredDescription
proceedbooleannoContinue bring-up even if some discovered secrets are still unset.

Responses:

  • 201 Bring-up dispatched.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 402 Authorized, but the account is out of budget (credits/cap reached).
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.
Fields in a 201 response
NameTypeRequiredDescription
init_run_idstring, nullableno
init_phaseseeding | awaiting_plan | awaiting_secrets | installing | starting | ready | failedyes

POST /projects/{projectId}/export

Export a project to a portable bundle

Packages the project into one file and returns a time-limited link to it. The bundle carries the source tree, the project's settings, its run plan, and the NAMES of the environment variables it reads. Left out: dependency caches, git history, and any .env or credential file in the workspace, so the bundle never carries a secret value; a credential embedded in the project's own source URL is stripped too. Feed the file to POST /servers/{serverId}/projects/import, on this deployment or on another one. The link needs no credentials, so treat it as the code itself.

Parameters
NameTypeRequiredDescription
projectId (path)stringyes
Request body (JSON)
NameTypeRequiredDescription
ttl_secondsnumbernoHow long the link stays valid. Defaults to 24 hours, capped at 7 days.

Responses:

  • 201 The bundle, and where to fetch it.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
  • 409 The server (or the project) is paused, so nothing runs on it until it is resumed from the dashboard.
Fields in a 201 response
NameTypeRequiredDescription
project_idstringno
urlstring (uri)yes
expires_atstring (date-time)yes
filenamestringyes
bytesinteger (int64)yes
envstring[]yesNames of the environment variables the project reads. Whoever imports the bundle has to supply the values.

Templates

Starter sources for new projects: named recipes the agent follows, plus the git and archive sources that carry your own code to run.

GET /templates

List project templates

Responses:

  • 200 Templates.
  • 401 Missing or invalid API key.
Fields in a 200 response
NameTypeRequiredDescription
templatesProjectTemplate[]yes

Domains

Custom domains a project also serves at, over HTTPS with a certificate issued automatically. On paid plans. Add a domain, create the two DNS records it returns, then check it: a domain serves once both records are found and the project is public.

GET /projects/{projectId}/domains

List a project's custom domains

Parameters
NameTypeRequiredDescription
projectId (path)stringyes

Responses:

  • 200 The project's custom domains, each with the DNS records it needs.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
domainsCustomDomain[]yes

POST /projects/{projectId}/domains

Add a custom domain to a project

Claims the domain for the project and returns the CNAME and TXT records to create at the domain's DNS provider. Nothing is served on it until POST /projects/{projectId}/domains/{domain}/check finds both. Counts against the plan's custom domain allowance.

Parameters
NameTypeRequiredDescription
projectId (path)stringyes
Request body (JSON)
NameTypeRequiredDescription
domainstringyesThe hostname, e.g. app.yourcompany.com.

Responses:

  • 201 The domain was added and is pending its DNS records.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 403 The account hit a plan limit (e.g. a tier's project cap).
  • 404 No such resource.
  • 409 The domain is already added to one of your projects, or connected to another account.
Fields in a 201 response
NameTypeRequiredDescription
domainstringyesThe hostname.
statuspending | verified | active | cert_failedyespending: waiting for the DNS records. verified: records found, certificate being issued. active: serving over HTTPS while the project is public. cert_failed: the certificate could not be issued; see problem.
problemstring, nullablenoWhat is still wrong, in words.
recordsobject[]yesThe DNS records to create at the domain's DNS provider.
urlstring, nullablenohttps://{domain} once active and the project is public.
checked_atstring (date-time), nullableno

DELETE /projects/{projectId}/domains/{domain}

Remove a custom domain

The domain stops serving and its certificate is removed. The project keeps its own address.

Parameters
NameTypeRequiredDescription
projectId (path)stringyes
domain (path)stringyesThe hostname.

Responses:

  • 200 Removed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
deletedbooleanyes

POST /projects/{projectId}/domains/{domain}/check

Check a custom domain's DNS records

Looks the records up now. When both are right the domain is verified and its certificate is issued; while it is pending, problem says what is still missing. DNS changes can take a while to spread, so call it again later rather than in a tight loop.

Parameters
NameTypeRequiredDescription
projectId (path)stringyes
domain (path)stringyesThe hostname.

Responses:

  • 200 The domain after the check.
  • 401 Missing or invalid API key.
  • 404 No such resource.
  • 409 The domain is already added to one of your projects, or connected to another account.
  • 503 DNS did not answer in time. Retry shortly.
Fields in a 200 response
NameTypeRequiredDescription
domainstringyesThe hostname.
statuspending | verified | active | cert_failedyespending: waiting for the DNS records. verified: records found, certificate being issued. active: serving over HTTPS while the project is public. cert_failed: the certificate could not be issued; see problem.
problemstring, nullablenoWhat is still wrong, in words.
recordsobject[]yesThe DNS records to create at the domain's DNS provider.
urlstring, nullablenohttps://{domain} once active and the project is public.
checked_atstring (date-time), nullableno

Secrets

Environment variables (key → value) bound to a server (shared by all its projects) or to a single project. Injected as env into agent runs and bring-up; values are write-only and never returned.

GET /secrets

List secrets (keys and bindings only, never values)

Responses:

  • 200 The account's secrets, safe view.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
Fields in a 200 response
NameTypeRequiredDescription
secretsSecret[]yes

PUT /secrets

Create or update a secret

One secret per key per account; setting an existing key updates its value. Binding to a server/project is done separately, or inline on create.

Request body (JSON)
NameTypeRequiredDescription
keystringyesEnvironment variable name: letters, digits, and underscore.
valuestringyesThe secret value. Write-only, never returned by any read.
descriptionstringnoOptional human note about what the secret is for.

Responses:

  • 200 The secret, safe view.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
Fields in a 200 response
NameTypeRequiredDescription
idstringyes
keystringyes
descriptionstring, nullableno
maskedstring, nullablenoA masked hint (e.g. "sk_…3f9"), never the full value.
server_idsstring[]noServers this secret is bound to server-wide.
project_idsstring[]noProjects this secret is bound to.
created_atstring (date-time)yes
updated_atstring (date-time)yes

DELETE /secrets/{secretId}

Delete a secret and all its bindings

Parameters
NameTypeRequiredDescription
secretId (path)stringyes

Responses:

  • 200 Deleted.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
idstringyes
deletedtrueyes

GET /servers/{serverId}/secrets

List secrets bound to a server (server-wide)

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.

Responses:

  • 200 Secrets bound server-wide, safe view.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
secretsSecret[]yes

PUT /servers/{serverId}/secrets

Set and bind server-wide secrets

Parameters
NameTypeRequiredDescription
serverId (path)stringyesThe server id.
Request body (JSON)
NameTypeRequiredDescription
secretsSecretInput[]yes

Responses:

  • 200 The server's secrets after the change, safe view.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
secretsSecret[]yes

GET /projects/{projectId}/secrets

List secrets a project sees (its own + server-wide)

Parameters
NameTypeRequiredDescription
projectId (path)stringyes

Responses:

  • 200 Secrets in scope for the project, safe view.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
secretsSecret[]yes

PUT /projects/{projectId}/secrets

Set and bind project-scoped secrets

Sets values only this project's runs see. Setting them does not resume a bring-up paused at awaiting_secrets; call POST /projects/{projectId}/init afterwards to continue it.

Parameters
NameTypeRequiredDescription
projectId (path)stringyes
Request body (JSON)
NameTypeRequiredDescription
secretsSecretInput[]yes

Responses:

  • 200 The project's secrets after the change, safe view.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
secretsSecret[]yes

Account

The account an API key acts on, with its spend and budget.

GET /me

The account this key acts on, with spend and budget

Reports the account the key acts on, not the person holding it. For a teammate's key, you names the key's holder as well. Check usage before a long series of tasks: blocked is true when new tasks are refused, and reason says which ceiling stopped them. Scoped keys cannot read this.

Responses:

  • 200 The account, its spend this period, and resource counts.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
Fields in a 200 response
NameTypeRequiredDescription
accountobjectyes
youobjectnoPresent only when the key belongs to a teammate rather than the account owner.
usageobjectyes
authenticated_keyobjectyes
serversintegeryes
projectsintegeryes
keysintegeryes

API Keys

Manage the API keys on your account.

GET /keys

List API keys

Responses:

  • 200 API keys (masked).
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
Fields in a 200 response
NameTypeRequiredDescription
keysApiKey[]yes

POST /keys

Mint a new API key

The plaintext key is returned in this creation response. The authenticated dashboard can also reveal the encrypted-at-rest value.

Request body (JSON)
NameTypeRequiredDescription
labelstringyes

Responses:

  • 201 The new key, including its plaintext value.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
Fields in a 201 response
NameTypeRequiredDescription
idstringyes
labelstringyes
maskedstringyesMasked display form (e.g. "sk_live_abc···wxyz"). Never the full secret.
allowed_server_idsstring[]yes
allowed_project_idsstring[]yes
created_atstring (date-time)yes
last_used_atstring (date-time), nullableno
keystringyesThe plaintext sk_live_ key returned when the key is created.

PATCH /keys/{keyId}

Replace a key's access scope

Empty/omitted arrays mean the key can reach everything.

Parameters
NameTypeRequiredDescription
keyId (path)stringyes
Request body (JSON)
NameTypeRequiredDescription
allowed_server_idsstring[]no
allowed_project_idsstring[]no

Responses:

  • 200 The updated scope.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
idstringno
allowed_server_idsstring[]no
allowed_project_idsstring[]no

DELETE /keys/{keyId}

Revoke a key

Parameters
NameTypeRequiredDescription
keyId (path)stringyes

Responses:

  • 200 Revoked.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
idstringyes
deletedtrueyes

Webhooks

Subscribe to events. Deliveries are HMAC-signed.

GET /webhooks

List webhook subscriptions

Responses:

  • 200 Webhooks.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
Fields in a 200 response
NameTypeRequiredDescription
webhooksWebhook[]yes

POST /webhooks

Subscribe to events

The signing secret is returned once, here. Store it for signature verification.

Request body (JSON)
NameTypeRequiredDescription
urlstring (uri)yesPublic HTTPS endpoint. Private, loopback, link-local, and redirect destinations are rejected.
eventstask.created | task.completed | task.failed | build.failed | deployment.live | deployment.removed | server.created | server.stopped | server.deleted | quota.threshold | quota.cap_reached | quota.egress_cap_reached[]no

Responses:

  • 201 The subscription, including its one-time signing secret.
  • 400 The request was malformed.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
Fields in a 201 response
NameTypeRequiredDescription
idstringyes
urlstring (uri)yes
eventstask.created | task.completed | task.failed | build.failed | deployment.live | deployment.removed | server.created | server.stopped | server.deleted | quota.threshold | quota.cap_reached | quota.egress_cap_reached[]yes
created_atstring (date-time)yes
secretstringyesThe HMAC signing secret (whsec_...). Returned once; store it now.

DELETE /webhooks/{webhookId}

Remove a webhook subscription

Parameters
NameTypeRequiredDescription
webhookId (path)stringyes

Responses:

  • 200 Deleted.
  • 401 Missing or invalid API key.
  • 403 The API key is valid but its resource scope does not allow this operation.
  • 404 No such resource.
Fields in a 200 response
NameTypeRequiredDescription
idstringyes
deletedtrueyes