API

Deployments API

Trigger builds, deploy from git or an uploaded folder, then inspect, redeploy, roll back, and manage the lifecycle of a project's releases.

The Deployments API drives a project's build-and-release lifecycle: it starts builds (from a linked git repo or an uploaded folder), reports status and logs, and handles the operations you run afterwards — redeploy, roll back, pin, cancel, restart, and resolve a partial-failure compose deploy. In the dashboard this is the deploy wizard and the Deployments tab; from the terminal it's openship deploy and openship deployment.

Base path & auth

All paths are relative to your instance, under /api — e.g. https://your-host/api/deployments. Send a personal access token as a bearer header (Authorization: Bearer <token>), created with openship token create. The dashboard uses your session cookie instead. See the API overview and auth model for details.

Available on self-hosted and cloud

This module is mounted on every instance. When a deployment belongs to a cloud project, the per-deployment routes (/:id/...) transparently proxy to Openship Cloud; local deployments are handled in place. You use the same paths either way.

Endpoints

Method & pathPermissionWhat it does
GET /api/deploymentsdeployment:listList deployments in the org (optionally filter with ?projectId=).
POST /api/deploymentsdeployment:writeGit-based deploy — redeploy an already-linked project from its git source.
POST /api/deployments/preparedeployment:writeDetect stack / build config for a git repo or local path before deploying.
POST /api/deployments/build/accessdeployment:writeThe wizard Deploy action — starts the build + deployment (git or folder upload).
POST /api/deployments/ssl/statusdeployment:readCheck a domain's SSL certificate status (side-effect-free).
POST /api/deployments/ssl/renewdeployment:writeRenew a domain's SSL certificate.
GET /api/deployments/:iddeployment:readGet a deployment by id — status, URLs, timing, error summary.
GET /api/deployments/:id/logsdeployment:readFetch a deployment's build / runtime logs.
GET /api/deployments/:id/streamdeployment:readStream build / deploy logs and events live (SSE).
GET /api/deployments/:id/builddeployment:readGet the build-session status for this deployment.
POST /api/deployments/:id/builddeployment:writeStart the build for a queued deployment (then streams logs via SSE).
POST /api/deployments/:id/build/responddeployment:writeRespond to a build gate / prompt (e.g. approve a step).
POST /api/deployments/:id/redeploydeployment:writeRe-run the latest deployment for this project.
POST /api/deployments/:id/rollbackdeployment:writeRoll back to this deployment's artifact / commit.
POST /api/deployments/:id/pindeployment:writePin (or unpin) this deployment so cleanup won't reclaim it.
POST /api/deployments/:id/canceldeployment:writeCancel an in-progress deployment.
POST /api/deployments/:id/keepdeployment:writeKeep a partial-failure deployment awaiting a decision (accept the succeeded services).
POST /api/deployments/:id/rejectdeployment:writeReject a partial-failure deployment awaiting a decision (roll back the changed services).
POST /api/deployments/:id/restartdeployment:writeRestart the running container(s) for this deployment.
GET /api/deployments/:id/infodeployment:readGet container info for this deployment.
GET /api/deployments/:id/usagedeployment:readGet container CPU / memory usage for this deployment.
DELETE /api/deployments/:iddeployment:adminDelete a deployment.

rollback and cancel need admin at runtime

Their route tag is deployment:write, but the handlers additionally assert deployment:admin on the target deployment (a rollback re-clones the repo). A caller with only write will pass the route check and then be denied. Grant deployment:admin for these two operations.

Trigger a git deploy

Redeploys an already-linked project from its git source. To deploy a local folder instead, use the upload flow that ends at /build/access.

POST /api/deployments

Prop

Type

curl -X POST https://your-host/api/deployments \
  -H "Authorization: Bearer $OPENSHIP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"proj_123","branch":"main"}'
# Same thing from the CLI:
openship deploy --project proj_123 --branch main

Prepare (detect build config)

Side-effect-free: point it at a git repo or a local path and it returns the detected framework, package manager, and build/start commands so the wizard can pre-fill. Creates nothing.

POST /api/deployments/prepare

Prop

Type

Local source is self-hosted only

source: "local" is rejected with 403 in cloud mode — cloud has no host filesystem to read.

Deploy wizard (/build/access)

The wizard's Deploy button. Creates a fresh deployment and starts the build. For a folder-upload deploy, pass projectId (from projects/ensure) and uploadSessionId (from projects/folder/session); for a git project, pass projectId and optionally branch. Returns { success, deployment_id, project_id }.

POST /api/deployments/build/access

Prop

Type

Each publicEndpoints entry is { port?, targetPath?, domain?, customDomain?, domainType? } where domainType is "free" or "custom". A services entry mirrors a compose/monorepo service (name, image?, build?, dockerfile?, ports, dependsOn, environment, volumes, and the optional per-app build fields).

curl -X POST https://your-host/api/deployments/build/access \
  -H "Authorization: Bearer $OPENSHIP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"proj_123","branch":"main","buildStrategy":"server"}'

Don't force deployTarget on self-hosted

Setting deployTarget: "cloud" on a self-hosted instance triggers a promote-to-cloud flow. For a normal folder upload, leave deployTarget unset and let the upload session's mode decide.

Get status, logs, and stream

GET /api/deployments/:id
GET /api/deployments/:id/logs
GET /api/deployments/:id/stream

/:id returns the deployment's status, URLs, timing, and any error summary. /logs returns the recorded build/runtime output; /stream is a Server-Sent Events feed of the live build — reconnect to it with a ?since=<seq> cursor to resume where you left off.

openship deployment get <deploymentId>

Redeploy

Re-runs the build. By default it resolves the latest commit on the branch (the auto-redeploy semantic); send { "useExistingCommit": true } to rebuild against the exact commit the original deployment used.

POST /api/deployments/:id/redeploy
openship deployment redeploy <deploymentId>

Rollback and pin

Rollback restores a previous deployment's artifact/commit as the active release. Pinning marks a deployment as protected so it isn't reclaimed by the rollback-window cleanup — POST /:id/pin defaults to { "pinned": true }; send { "pinned": false } to unpin.

POST /api/deployments/:id/rollback
POST /api/deployments/:id/pin
openship deployment rollback <deploymentId>
openship deployment pin <deploymentId>

Cancel a running deploy

POST /api/deployments/:id/cancel
openship deployment cancel <deploymentId>

Partial-failure compose deploys: keep or reject

When a multi-service (compose) deploy has some services succeed and others fail, it is held in partial_failure with decision: pending ("Action Required"). Resolve it explicitly:

  • Keep accepts the services that succeeded and leaves the rest on their prior version.
  • Reject rolls back the changed services to their previous state.
POST /api/deployments/:id/keep
POST /api/deployments/:id/reject
openship deployment keep <deploymentId>
openship deployment reject <deploymentId>

SSL status and renew

Both take the domain in the JSON body. /ssl/status is a side-effect-free probe (POST only so the hostname travels in the body); /ssl/renew re-issues the certificate.

POST /api/deployments/ssl/status
POST /api/deployments/ssl/renew

Prop

Type

curl -X POST https://your-host/api/deployments/ssl/status \
  -H "Authorization: Bearer $OPENSHIP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"domain":"app.example.com"}'
openship deployment ssl status app.example.com
openship deployment ssl renew app.example.com

Errors you might see

400 — bad request / failed operation

Missing a required field (domain is required, source must be 'github' or 'local') or the operation couldn't run (e.g. cancelling a deployment that already finished, or keep/reject on a deployment that isn't awaiting a decision). The response body carries { success: false, error }.

403 — local source in cloud mode

prepare with source: "local" (or a folder deploy) isn't available on Openship Cloud — there's no host filesystem. Use a git source instead.

404 on a per-deployment route

The :id doesn't belong to your organization (or was deleted). List with GET /api/deployments to get valid IDs.

On this page