Teral

Deployments

Deploy, watch, promote, roll back, stop and start deployments.

See Deployments for the lifecycle and Rollbacks for how promoting and rolling back behave.

To deploy from CI, call deployments.createDeployment, then call deployments.getDeployment every few seconds until status is ready, or one of failed, cancelled, superseded or skipped.

Create a deployment

POST /v1/deployments.createDeployment

Starts a deployment and returns its ID right away. The build and rollout continue in the background. Send exactly one source: git to build a branch or commit, image to run an image, or deployment to run an earlier deployment again with the current settings.

Permissions: the key needs one of environment.*.create_deployment, environment.<environment_id>.create_deployment.

Request

FieldTypeDescription
projectstring, requiredThe project, by ID or slug. 3 to 255 characters.
appstring, requiredThe app, by ID or slug. 3 to 255 characters.
environmentstring, requiredThe environment to deploy to: production, preview, or an environment ID. 3 to 255 characters.
gitobjectBuild from the app's repository. Send an empty object to build the default branch.
git.branchstringBuild the newest commit of this branch. At most 256 characters.
git.commitShastringBuild this commit. Takes priority over branch. At most 40 characters.
git.repositorystringBuild from a fork, as owner/name. Needs commitSha. Fork deployments should go to preview. At most 256 characters.
imageobjectRun a container image as it is.
image.dockerImagestring, requiredThe image, with a tag or digest, such as ghcr.io/acme/api:v1.4.0. Without either, the registry's latest is used. 1 to 256 characters.
deploymentobjectRun an earlier deployment again. Repository apps rebuild its commit, image apps reuse its image.
deployment.deploymentIdstring, requiredThe deployment to run again. 3 to 255 characters.
curl -X POST https://api.teral.dev/v1/deployments.createDeployment \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "shop",
    "app": "web",
    "environment": "production",
    "git": {
      "branch": "main"
    }
  }'

Response

On success the status is 201 Created. The fields in data:

FieldTypeDescription
deploymentIdstringThe new deployment's ID. Pass it to deployments.getDeployment to follow its progress.

Error statuses: 400, 401, 403, 404, 412, 429, 500. See Errors for the codes behind them.


Get a deployment

POST /v1/deployments.getDeployment

Returns a deployment with its status, source, resources and URLs.

Permissions: the key needs one of environment.*.read_deployment, environment.<environment_id>.read_deployment.

Request

FieldTypeDescription
deploymentIdstring, requiredThe deployment's ID (d_…). 3 to 255 characters.
curl -X POST https://api.teral.dev/v1/deployments.getDeployment \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "deploymentId": "d_7k2PqXv9"
  }'

Response

On success the status is 200 OK. The fields in data:

FieldTypeDescription
idstringThe deployment's ID.
statusstringWhere the deployment is. It ends in ready, failed, cancelled, superseded, skipped or stopped. See statuses. One of pending, starting, building, deploying, network, finalizing, ready, failed, skipped, awaiting_approval, stopped, superseded, cancelled.
isCurrentbooleanWhether this deployment serves production right now. At most one deployment is current.
environmentstringThe environment's slug.
appstringThe app's slug.
projectstringThe project's slug.
gitobjectThe commit it was built from. Only for repository deployments.
git.commitShastringThe commit SHA.
git.branchstringThe branch, when known.
dockerobjectThe image it runs. Only for image deployments.
docker.imagestringThe image reference that was requested.
availableActionsstring[]What you can do with the deployment right now: promote, rollback, stop or start. Empty while it's in progress.
regionsstring[]The regions it runs in.
errorobjectWhy it failed. Only present when status is failed.
error.codestringThe kind of failure. cpu_quota_exceeded, memory_quota_exceeded and storage_quota_exceeded mean the workspace hit a limit. unknown means look at message. One of no_schedulable_regions, invalid_runtime_settings, cpu_quota_exceeded, memory_quota_exceeded, storage_quota_exceeded, build_failed, unknown.
error.stepstringThe step that failed, such as building or deploying.
error.messagestringA readable explanation of the failure. Use code in your code, this one for people.
domainsstring[]The hostnames the deployment answers on.
runtimeobjectThe resources and settings it runs with.
runtime.vCpusnumberCPU per instance, in vCPUs. 0.25 is a quarter vCPU.
runtime.memoryMibintegerMemory per instance, in MiB.
runtime.storageMibintegerDisk per instance, mounted at /data, in MiB. 0 means none.
runtime.portintegerThe port the app listens on.
runtime.commandstring[]The start command, if one replaces the image's own.
runtime.shutdownSignalstringThe signal instances get when they're stopped. One of SIGTERM, SIGINT, SIGQUIT, SIGKILL.
runtime.upstreamProtocolstringHow the gateway talks to the app: http1 or h2c. One of http1, h2c.
runtime.healthcheckobjectThe health check, if one is set.
runtime.healthcheck.methodstringGET or POST. One of GET, POST.
runtime.healthcheck.pathstringThe path Teral calls, starting with /. 1 to 512 characters.
runtime.healthcheck.intervalSecondsintegerSeconds between checks. Default 10. 1 to 3600.
runtime.healthcheck.timeoutSecondsintegerSeconds to wait for an answer. Default 5. 1 to 3600.
runtime.healthcheck.failureThresholdintegerFailed checks in a row before the instance is restarted. Default 3. 1 to 100.
runtime.healthcheck.initialDelaySecondsintegerSeconds to wait after start before the first check. Default 0. 0 to 3600.
createdAtintegerWhen it was created, in Unix milliseconds. 0 to 9223372036854776000.
updatedAtintegerWhen it last changed, in Unix milliseconds. Missing if it never changed. 0 to 9223372036854776000.

Error statuses: 400, 401, 404, 429, 500. See Errors for the codes behind them.


List deployments

POST /v1/deployments.listDeployments

Returns deployments, newest first, a page at a time. Filter by project, app, environment and status.

Permissions: the key needs environment.*.read_deployment.

Request

FieldTypeDescription
projectstringOnly this project, by ID or slug. Needed for the app and environment filters. 3 to 255 characters.
appstringOnly this app, by ID or slug. Needs project. 3 to 255 characters.
environmentstringOnly this environment, by ID or slug. Needs project and app. 3 to 255 characters.
statusstring[]Only deployments with one of these statuses. At most 13 items.
limitintegerHow many results to return in one page. Default 100. 1 to 100.
cursorstringThe pagination.cursor of the previous response, to get the next page.
curl -X POST https://api.teral.dev/v1/deployments.listDeployments \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "shop",
    "app": "web",
    "environment": "production",
    "limit": 10
  }'

Response

On success the status is 200 OK. The fields in data:

FieldTypeDescription
idstringThe deployment's ID.
statusstringWhere the deployment is. It ends in ready, failed, cancelled, superseded, skipped or stopped. See statuses. One of pending, starting, building, deploying, network, finalizing, ready, failed, skipped, awaiting_approval, stopped, superseded, cancelled.
isCurrentbooleanWhether this deployment serves production right now. At most one deployment is current.
environmentstringThe environment's slug.
appstringThe app's slug.
projectstringThe project's slug.
gitobjectThe commit it was built from. Only for repository deployments.
git.commitShastringThe commit SHA.
git.branchstringThe branch, when known.
dockerobjectThe image it runs. Only for image deployments.
docker.imagestringThe image reference that was requested.
availableActionsstring[]What you can do with the deployment right now: promote, rollback, stop or start. Empty while it's in progress.
regionsstring[]The regions it runs in.
errorobjectWhy it failed. Only present when status is failed.
error.codestringThe kind of failure. cpu_quota_exceeded, memory_quota_exceeded and storage_quota_exceeded mean the workspace hit a limit. unknown means look at message. One of no_schedulable_regions, invalid_runtime_settings, cpu_quota_exceeded, memory_quota_exceeded, storage_quota_exceeded, build_failed, unknown.
error.stepstringThe step that failed, such as building or deploying.
error.messagestringA readable explanation of the failure. Use code in your code, this one for people.
domainsstring[]The hostnames the deployment answers on.
runtimeobjectThe resources and settings it runs with.
runtime.vCpusnumberCPU per instance, in vCPUs. 0.25 is a quarter vCPU.
runtime.memoryMibintegerMemory per instance, in MiB.
runtime.storageMibintegerDisk per instance, mounted at /data, in MiB. 0 means none.
runtime.portintegerThe port the app listens on.
runtime.commandstring[]The start command, if one replaces the image's own.
runtime.shutdownSignalstringThe signal instances get when they're stopped. One of SIGTERM, SIGINT, SIGQUIT, SIGKILL.
runtime.upstreamProtocolstringHow the gateway talks to the app: http1 or h2c. One of http1, h2c.
runtime.healthcheckobjectThe health check, if one is set.
runtime.healthcheck.methodstringGET or POST. One of GET, POST.
runtime.healthcheck.pathstringThe path Teral calls, starting with /. 1 to 512 characters.
runtime.healthcheck.intervalSecondsintegerSeconds between checks. Default 10. 1 to 3600.
runtime.healthcheck.timeoutSecondsintegerSeconds to wait for an answer. Default 5. 1 to 3600.
runtime.healthcheck.failureThresholdintegerFailed checks in a row before the instance is restarted. Default 3. 1 to 100.
runtime.healthcheck.initialDelaySecondsintegerSeconds to wait after start before the first check. Default 0. 0 to 3600.
createdAtintegerWhen it was created, in Unix milliseconds. 0 to 9223372036854776000.
updatedAtintegerWhen it last changed, in Unix milliseconds. Missing if it never changed. 0 to 9223372036854776000.

When pagination.hasMore is true, pass pagination.cursor as cursor to get the next page.

Error statuses: 400, 401, 403, 404, 429, 500. See Errors for the codes behind them.


Promote a deployment

POST /v1/deployments.promoteDeployment

Makes a production deployment the live one and ends a rolled-back state, so later pushes take over production again. Returns 202 once the switch is accepted.

Permissions: the key needs one of environment.*.promote_deployment, environment.<environment_id>.promote_deployment.

Request

FieldTypeDescription
deploymentIdstring, requiredThe production deployment to make live. 3 to 255 characters.
curl -X POST https://api.teral.dev/v1/deployments.promoteDeployment \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "deploymentId": "d_7k2PqXv9"
  }'

Response

On success the status is 202 Accepted.

Error statuses: 400, 401, 404, 412, 429, 500. See Errors for the codes behind them.


Roll back

POST /v1/deployments.rollbackDeployment

Moves production traffic to an earlier production deployment and keeps it there: new pushes still deploy, but don't take over until you promote one. Returns 202 once the switch is accepted.

Permissions: the key needs one of environment.*.rollback_deployment, environment.<environment_id>.rollback_deployment.

Request

FieldTypeDescription
deploymentIdstring, requiredThe earlier production deployment to go back to. 3 to 255 characters.
curl -X POST https://api.teral.dev/v1/deployments.rollbackDeployment \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "deploymentId": "d_3h8LmQw2"
  }'

Response

On success the status is 202 Accepted.

Error statuses: 400, 401, 404, 412, 429, 500. See Errors for the codes behind them.


Stop a deployment

POST /v1/deployments.stopDeployment

Stops a running preview deployment. Production deployments can't be stopped.

Permissions: the key needs one of environment.*.stop_deployment, environment.<environment_id>.stop_deployment.

Request

FieldTypeDescription
deploymentIdstring, requiredThe preview deployment to stop. 3 to 255 characters.
curl -X POST https://api.teral.dev/v1/deployments.stopDeployment \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "deploymentId": "d_9t4RkZy1"
  }'

Response

On success the status is 202 Accepted.

Error statuses: 400, 401, 404, 412, 429, 500. See Errors for the codes behind them.


Start a deployment

POST /v1/deployments.startDeployment

Starts a stopped preview deployment again, without building anything.

Permissions: the key needs one of environment.*.start_deployment, environment.<environment_id>.start_deployment.

Request

FieldTypeDescription
deploymentIdstring, requiredThe stopped preview deployment to start. 3 to 255 characters.
curl -X POST https://api.teral.dev/v1/deployments.startDeployment \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "deploymentId": "d_9t4RkZy1"
  }'

Response

On success the status is 202 Accepted.

Error statuses: 400, 401, 404, 412, 429, 500. See Errors for the codes behind them.

Edit on GitHub

On this page