Environments
Read environments, change their settings and manage variables.
Every app has the environments production and preview. Settings and variables changed here apply from the next deployment. See Environments.
List environments
POST /v1/environments.listEnvironments
Returns an app's environments with their settings.
Permissions: the key needs environment.*.read_environment.
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. |
curl -X POST https://api.teral.dev/v1/environments.listEnvironments \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project": "shop",
"app": "web"
}'Response
On success the status is 200 OK. The fields in data:
| Field | Type | Description |
|---|---|---|
id | string | The environment's ID. |
slug | string | The environment's slug, such as production. |
description | string | A description. Empty if there's none. |
kind | string | production or preview. One of production, preview. |
deleteProtection | boolean | Whether delete protection is on. |
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. |
runtime | object | How instances run. Missing until settings exist. |
runtime.port | integer | The port the app listens on. |
runtime.vCpus | number | CPU per instance, in vCPUs. |
runtime.memoryMib | integer | Memory per instance, in MiB. |
runtime.storageMib | integer | Disk per instance, in MiB. 0 means none. |
runtime.command | string[] | The start command, if one replaces the image's own. |
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. |
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.openapiSpecPath | string | Stored, but not used by Teral at the moment. |
build | object | How the app is built. Missing until settings exist. |
build.dockerfile | string | The Dockerfile, if builds use one. |
build.rootDirectory | string | The folder builds start from. . is the repository root. |
build.buildCommand | string | The build command, if one replaces the detected one. |
build.watchPaths | string[] | Glob patterns. Pushes that change no matching file are skipped. |
build.autoDeploy | boolean | Whether pushes deploy automatically. |
regions | object[] | The regions the environment runs in, with instance ranges. |
regions[].name | string | The region, such as eu-central-1. 1 to 64 characters. |
regions[].replicas | object | The instance range in this region. |
regions[].replicas.min | integer | The fewest instances to keep running. |
regions[].replicas.max | integer | The most instances to scale up to. Equal to min turns autoscaling off. |
Error statuses: 400, 401, 403, 404, 429, 500. See Errors for the codes behind them.
Get an environment
POST /v1/environments.getEnvironment
Returns one environment with its build, runtime and region settings.
Permissions: the key needs one of environment.*.read_environment, environment.<environment_id>.read_environment.
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: production, preview, or its ID. 3 to 255 characters. |
curl -X POST https://api.teral.dev/v1/environments.getEnvironment \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project": "shop",
"app": "web",
"environment": "production"
}'Response
On success the status is 200 OK. The fields in data:
| Field | Type | Description |
|---|---|---|
id | string | The environment's ID. |
slug | string | The environment's slug, such as production. |
description | string | A description. Empty if there's none. |
kind | string | production or preview. One of production, preview. |
deleteProtection | boolean | Whether delete protection is on. |
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. |
runtime | object | How instances run. Missing until settings exist. |
runtime.port | integer | The port the app listens on. |
runtime.vCpus | number | CPU per instance, in vCPUs. |
runtime.memoryMib | integer | Memory per instance, in MiB. |
runtime.storageMib | integer | Disk per instance, in MiB. 0 means none. |
runtime.command | string[] | The start command, if one replaces the image's own. |
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. |
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.openapiSpecPath | string | Stored, but not used by Teral at the moment. |
build | object | How the app is built. Missing until settings exist. |
build.dockerfile | string | The Dockerfile, if builds use one. |
build.rootDirectory | string | The folder builds start from. . is the repository root. |
build.buildCommand | string | The build command, if one replaces the detected one. |
build.watchPaths | string[] | Glob patterns. Pushes that change no matching file are skipped. |
build.autoDeploy | boolean | Whether pushes deploy automatically. |
regions | object[] | The regions the environment runs in, with instance ranges. |
regions[].name | string | The region, such as eu-central-1. 1 to 64 characters. |
regions[].replicas | object | The instance range in this region. |
regions[].replicas.min | integer | The fewest instances to keep running. |
regions[].replicas.max | integer | The most instances to scale up to. Equal to min turns autoscaling off. |
Error statuses: 400, 401, 403, 404, 429, 500. See Errors for the codes behind them.
Update settings
POST /v1/environments.updateSettings
Changes an environment's build, runtime and region settings. Fields you leave out stay as they are. Send null to clear a field that allows it. The changes apply from the next deployment.
Permissions: the key needs one of environment.*.update_environment, environment.<environment_id>.update_environment.
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: production, preview, or its ID. 3 to 255 characters. |
dockerfile | string or null | The Dockerfile to build with, relative to the root directory. null goes back to building without one. 1 to 500 characters. |
rootDirectory | string | The folder to build from, such as services/api. . is the repository root. 1 to 500 characters. |
buildCommand | string or null | Replaces the detected build command. null goes back to detection. 1 to 1000 characters. |
watchPaths | string[] | Glob patterns such as src/** or **/*.go. Pushes that change no matching file are skipped. Patterns can't start with / or ./, and one without a wildcard matches only that exact file. At most 10 items. |
autoDeploy | boolean | Whether pushes deploy automatically. |
port | integer | The port the app listens on. 1 to 65535. |
vCpus | number | CPU per instance, in steps of 0.25 starting at 0.25. Your plan sets the maximum. At least 0.25. |
memoryMib | integer | Memory per instance, in steps of 256 starting at 256. Your plan sets the maximum. At least 256. |
storageMib | integer | Disk per instance, in steps of 512. 0 means none. Your plan sets the maximum. At least 0. |
command | string[] | The start command, as a list of arguments, replacing the image's own. At most 10 items. |
healthcheck | object or null | The health check. null removes it. |
healthcheck.method | string, required | GET or POST. One of GET, POST. |
healthcheck.path | string, required | The path Teral calls, starting with /, such as /health. 1 to 512 characters. |
healthcheck.intervalSeconds | integer | Seconds between checks. Default 10. 1 to 3600. |
healthcheck.timeoutSeconds | integer | Seconds to wait for an answer. Default 5. 1 to 3600. |
healthcheck.failureThreshold | integer | Failed checks in a row before the instance is restarted. Default 3. 1 to 100. |
healthcheck.initialDelaySeconds | integer | Seconds to wait after start before the first check. Default 0. 0 to 3600. |
shutdownSignal | string | The signal instances get when they're stopped. One of SIGTERM, SIGINT, SIGQUIT, SIGKILL. |
upstreamProtocol | string | How the gateway talks to the app: http1 or h2c. One of http1, h2c. |
openapiSpecPath | string or null | Stored, but not used by Teral at the moment. 1 to 512 characters. |
regions | object[] | The full list of regions, with an instance range for each. Regions you leave out are removed. At least one is required. 1 to 5 items. |
regions[].name | string, required | The region, such as eu-central-1. 1 to 64 characters. |
regions[].replicas | object, required | The instance range in this region. |
regions[].replicas.min | integer, required | The fewest instances to keep running. |
regions[].replicas.max | integer, required | The most instances to scale up to. Equal to min turns autoscaling off. |
curl -X POST https://api.teral.dev/v1/environments.updateSettings \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project": "shop",
"app": "web",
"environment": "production",
"memoryMib": 1024,
"healthcheck": {
"method": "GET",
"path": "/health",
"intervalSeconds": 15
}
}'Response
On success the status is 200 OK.
Error statuses: 400, 401, 403, 404, 429, 500. See Errors for the codes behind them.
List variables
POST /v1/environments.listEnvironmentVariables
Returns an environment's variables, a page at a time. Values of sensitive variables are never returned.
Permissions: the key needs one of environment.*.read_environment_variables, environment.<environment_id>.read_environment_variables.
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: production, preview, or its ID. 3 to 255 characters. |
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. 1 to 1024 characters. |
curl -X POST https://api.teral.dev/v1/environments.listEnvironmentVariables \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project": "shop",
"app": "web",
"environment": "production"
}'Response
On success the status is 200 OK. The fields in data:
| Field | Type | Description |
|---|---|---|
key | string | The variable's name. |
kind | string | recoverable variables can be read back, writeonly ones can't. The dashboard calls write-only variables sensitive. Both are stored encrypted. One of recoverable, writeonly. |
value | string | The value. Only present for recoverable variables. |
description | string | A note about the variable, if one was added. |
createdAt | integer | When it was created, in Unix milliseconds. 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.
Set variables
POST /v1/environments.setEnvironmentVariables
Creates or overwrites variables. Variables not in the list stay as they are, unless prune is true. The whole call succeeds or fails together. Running deployments keep their old values until the next deployment.
Permissions: the key needs one of environment.*.set_environment_variables, environment.<environment_id>.set_environment_variables.
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: production, preview, or its ID. 3 to 255 characters. |
variables | object[], required | The variables to write. Each one replaces any existing variable with the same name. At most 50 items. |
variables[].key | string, required | The name: letters, digits and underscores, not starting with a digit. 1 to 256 characters. |
variables[].value | string, required | The value. Always stored encrypted. 1 to 16384 characters. |
variables[].kind | any | writeonly, the default, makes the value unreadable after saving. recoverable allows reading it back. Default "writeonly". |
variables[].description | string | An optional note. At most 255 characters. |
prune | boolean | When true, also deletes every variable not in variables, so the list becomes the complete set. With an empty list, this removes all variables. Default false. |
curl -X POST https://api.teral.dev/v1/environments.setEnvironmentVariables \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project": "shop",
"app": "web",
"environment": "production",
"variables": [
{
"key": "DATABASE_URL",
"value": "postgres://…"
},
{
"key": "LOG_LEVEL",
"value": "info",
"kind": "recoverable"
}
]
}'Response
On success the status is 200 OK.
Error statuses: 400, 401, 403, 404, 429, 500. See Errors for the codes behind them.
Remove variables
POST /v1/environments.removeEnvironmentVariables
Deletes variables by name. Names that don't exist are skipped. The whole call succeeds or fails together.
Permissions: the key needs one of environment.*.remove_environment_variables, environment.<environment_id>.remove_environment_variables.
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: production, preview, or its ID. 3 to 255 characters. |
variables | string[], required | The names of the variables to delete. 1 to 50 items. |
curl -X POST https://api.teral.dev/v1/environments.removeEnvironmentVariables \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project": "shop",
"app": "web",
"environment": "production",
"variables": [
"LOG_LEVEL"
]
}'Response
On success the status is 200 OK.
Error statuses: 400, 401, 403, 404, 429, 500. See Errors for the codes behind them.