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
| Field | Type | Description |
|---|---|---|
project | string, required | The project, by ID or slug. 3 to 255 characters. |
app | string, required | The app, by ID or slug. 3 to 255 characters. |
environment | string, required | The environment to deploy to: production, preview, or an environment ID. 3 to 255 characters. |
git | object | Build from the app's repository. Send an empty object to build the default branch. |
git.branch | string | Build the newest commit of this branch. At most 256 characters. |
git.commitSha | string | Build this commit. Takes priority over branch. At most 40 characters. |
git.repository | string | Build from a fork, as owner/name. Needs commitSha. Fork deployments should go to preview. At most 256 characters. |
image | object | Run a container image as it is. |
image.dockerImage | string, required | The 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. |
deployment | object | Run an earlier deployment again. Repository apps rebuild its commit, image apps reuse its image. |
deployment.deploymentId | string, required | The 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:
| Field | Type | Description |
|---|---|---|
deploymentId | string | The 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
| Field | Type | Description |
|---|---|---|
deploymentId | string, required | The 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:
| Field | Type | Description |
|---|---|---|
id | string | The deployment's ID. |
status | string | Where 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. |
isCurrent | boolean | Whether this deployment serves production right now. At most one deployment is current. |
environment | string | The environment's slug. |
app | string | The app's slug. |
project | string | The project's slug. |
git | object | The commit it was built from. Only for repository deployments. |
git.commitSha | string | The commit SHA. |
git.branch | string | The branch, when known. |
docker | object | The image it runs. Only for image deployments. |
docker.image | string | The image reference that was requested. |
availableActions | string[] | What you can do with the deployment right now: promote, rollback, stop or start. Empty while it's in progress. |
regions | string[] | The regions it runs in. |
error | object | Why it failed. Only present when status is failed. |
error.code | string | The 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.step | string | The step that failed, such as building or deploying. |
error.message | string | A readable explanation of the failure. Use code in your code, this one for people. |
domains | string[] | The hostnames the deployment answers on. |
runtime | object | The resources and settings it runs with. |
runtime.vCpus | number | CPU per instance, in vCPUs. 0.25 is a quarter vCPU. |
runtime.memoryMib | integer | Memory per instance, in MiB. |
runtime.storageMib | integer | Disk per instance, mounted at /data, in MiB. 0 means none. |
runtime.port | integer | The port the app listens on. |
runtime.command | string[] | The start command, if one replaces the image's own. |
runtime.shutdownSignal | string | The signal instances get when they're stopped. One of SIGTERM, SIGINT, SIGQUIT, SIGKILL. |
runtime.upstreamProtocol | string | How the gateway talks to the app: http1 or h2c. One of http1, h2c. |
runtime.healthcheck | object | The health check, if one is set. |
runtime.healthcheck.method | string | GET or POST. One of GET, POST. |
runtime.healthcheck.path | string | The path Teral calls, starting with /. 1 to 512 characters. |
runtime.healthcheck.intervalSeconds | integer | Seconds between checks. Default 10. 1 to 3600. |
runtime.healthcheck.timeoutSeconds | integer | Seconds to wait for an answer. Default 5. 1 to 3600. |
runtime.healthcheck.failureThreshold | integer | Failed checks in a row before the instance is restarted. Default 3. 1 to 100. |
runtime.healthcheck.initialDelaySeconds | integer | Seconds to wait after start before the first check. Default 0. 0 to 3600. |
createdAt | integer | When it was created, in Unix milliseconds. 0 to 9223372036854776000. |
updatedAt | integer | When 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
| Field | Type | Description |
|---|---|---|
project | string | Only this project, by ID or slug. Needed for the app and environment filters. 3 to 255 characters. |
app | string | Only this app, by ID or slug. Needs project. 3 to 255 characters. |
environment | string | Only this environment, by ID or slug. Needs project and app. 3 to 255 characters. |
status | string[] | Only deployments with one of these statuses. At most 13 items. |
limit | integer | How many results to return in one page. Default 100. 1 to 100. |
cursor | string | The 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:
| Field | Type | Description |
|---|---|---|
id | string | The deployment's ID. |
status | string | Where 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. |
isCurrent | boolean | Whether this deployment serves production right now. At most one deployment is current. |
environment | string | The environment's slug. |
app | string | The app's slug. |
project | string | The project's slug. |
git | object | The commit it was built from. Only for repository deployments. |
git.commitSha | string | The commit SHA. |
git.branch | string | The branch, when known. |
docker | object | The image it runs. Only for image deployments. |
docker.image | string | The image reference that was requested. |
availableActions | string[] | What you can do with the deployment right now: promote, rollback, stop or start. Empty while it's in progress. |
regions | string[] | The regions it runs in. |
error | object | Why it failed. Only present when status is failed. |
error.code | string | The 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.step | string | The step that failed, such as building or deploying. |
error.message | string | A readable explanation of the failure. Use code in your code, this one for people. |
domains | string[] | The hostnames the deployment answers on. |
runtime | object | The resources and settings it runs with. |
runtime.vCpus | number | CPU per instance, in vCPUs. 0.25 is a quarter vCPU. |
runtime.memoryMib | integer | Memory per instance, in MiB. |
runtime.storageMib | integer | Disk per instance, mounted at /data, in MiB. 0 means none. |
runtime.port | integer | The port the app listens on. |
runtime.command | string[] | The start command, if one replaces the image's own. |
runtime.shutdownSignal | string | The signal instances get when they're stopped. One of SIGTERM, SIGINT, SIGQUIT, SIGKILL. |
runtime.upstreamProtocol | string | How the gateway talks to the app: http1 or h2c. One of http1, h2c. |
runtime.healthcheck | object | The health check, if one is set. |
runtime.healthcheck.method | string | GET or POST. One of GET, POST. |
runtime.healthcheck.path | string | The path Teral calls, starting with /. 1 to 512 characters. |
runtime.healthcheck.intervalSeconds | integer | Seconds between checks. Default 10. 1 to 3600. |
runtime.healthcheck.timeoutSeconds | integer | Seconds to wait for an answer. Default 5. 1 to 3600. |
runtime.healthcheck.failureThreshold | integer | Failed checks in a row before the instance is restarted. Default 3. 1 to 100. |
runtime.healthcheck.initialDelaySeconds | integer | Seconds to wait after start before the first check. Default 0. 0 to 3600. |
createdAt | integer | When it was created, in Unix milliseconds. 0 to 9223372036854776000. |
updatedAt | integer | When 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
| Field | Type | Description |
|---|---|---|
deploymentId | string, required | The 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
| Field | Type | Description |
|---|---|---|
deploymentId | string, required | The 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
| Field | Type | Description |
|---|---|---|
deploymentId | string, required | The 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
| Field | Type | Description |
|---|---|---|
deploymentId | string, required | The 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.