Teral

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

FieldTypeDescription
projectstring, requiredThe project, by ID or slug. 3 to 255 characters.
appstring, requiredThe 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:

FieldTypeDescription
idstringThe environment's ID.
slugstringThe environment's slug, such as production.
descriptionstringA description. Empty if there's none.
kindstringproduction or preview. One of production, preview.
deleteProtectionbooleanWhether delete protection is on.
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.
runtimeobjectHow instances run. Missing until settings exist.
runtime.portintegerThe port the app listens on.
runtime.vCpusnumberCPU per instance, in vCPUs.
runtime.memoryMibintegerMemory per instance, in MiB.
runtime.storageMibintegerDisk per instance, in MiB. 0 means none.
runtime.commandstring[]The start command, if one replaces the image's own.
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.
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.openapiSpecPathstringStored, but not used by Teral at the moment.
buildobjectHow the app is built. Missing until settings exist.
build.dockerfilestringThe Dockerfile, if builds use one.
build.rootDirectorystringThe folder builds start from. . is the repository root.
build.buildCommandstringThe build command, if one replaces the detected one.
build.watchPathsstring[]Glob patterns. Pushes that change no matching file are skipped.
build.autoDeploybooleanWhether pushes deploy automatically.
regionsobject[]The regions the environment runs in, with instance ranges.
regions[].namestringThe region, such as eu-central-1. 1 to 64 characters.
regions[].replicasobjectThe instance range in this region.
regions[].replicas.minintegerThe fewest instances to keep running.
regions[].replicas.maxintegerThe 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

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: 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:

FieldTypeDescription
idstringThe environment's ID.
slugstringThe environment's slug, such as production.
descriptionstringA description. Empty if there's none.
kindstringproduction or preview. One of production, preview.
deleteProtectionbooleanWhether delete protection is on.
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.
runtimeobjectHow instances run. Missing until settings exist.
runtime.portintegerThe port the app listens on.
runtime.vCpusnumberCPU per instance, in vCPUs.
runtime.memoryMibintegerMemory per instance, in MiB.
runtime.storageMibintegerDisk per instance, in MiB. 0 means none.
runtime.commandstring[]The start command, if one replaces the image's own.
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.
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.openapiSpecPathstringStored, but not used by Teral at the moment.
buildobjectHow the app is built. Missing until settings exist.
build.dockerfilestringThe Dockerfile, if builds use one.
build.rootDirectorystringThe folder builds start from. . is the repository root.
build.buildCommandstringThe build command, if one replaces the detected one.
build.watchPathsstring[]Glob patterns. Pushes that change no matching file are skipped.
build.autoDeploybooleanWhether pushes deploy automatically.
regionsobject[]The regions the environment runs in, with instance ranges.
regions[].namestringThe region, such as eu-central-1. 1 to 64 characters.
regions[].replicasobjectThe instance range in this region.
regions[].replicas.minintegerThe fewest instances to keep running.
regions[].replicas.maxintegerThe 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

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: production, preview, or its ID. 3 to 255 characters.
dockerfilestring or nullThe Dockerfile to build with, relative to the root directory. null goes back to building without one. 1 to 500 characters.
rootDirectorystringThe folder to build from, such as services/api. . is the repository root. 1 to 500 characters.
buildCommandstring or nullReplaces the detected build command. null goes back to detection. 1 to 1000 characters.
watchPathsstring[]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.
autoDeploybooleanWhether pushes deploy automatically.
portintegerThe port the app listens on. 1 to 65535.
vCpusnumberCPU per instance, in steps of 0.25 starting at 0.25. Your plan sets the maximum. At least 0.25.
memoryMibintegerMemory per instance, in steps of 256 starting at 256. Your plan sets the maximum. At least 256.
storageMibintegerDisk per instance, in steps of 512. 0 means none. Your plan sets the maximum. At least 0.
commandstring[]The start command, as a list of arguments, replacing the image's own. At most 10 items.
healthcheckobject or nullThe health check. null removes it.
healthcheck.methodstring, requiredGET or POST. One of GET, POST.
healthcheck.pathstring, requiredThe path Teral calls, starting with /, such as /health. 1 to 512 characters.
healthcheck.intervalSecondsintegerSeconds between checks. Default 10. 1 to 3600.
healthcheck.timeoutSecondsintegerSeconds to wait for an answer. Default 5. 1 to 3600.
healthcheck.failureThresholdintegerFailed checks in a row before the instance is restarted. Default 3. 1 to 100.
healthcheck.initialDelaySecondsintegerSeconds to wait after start before the first check. Default 0. 0 to 3600.
shutdownSignalstringThe signal instances get when they're stopped. One of SIGTERM, SIGINT, SIGQUIT, SIGKILL.
upstreamProtocolstringHow the gateway talks to the app: http1 or h2c. One of http1, h2c.
openapiSpecPathstring or nullStored, but not used by Teral at the moment. 1 to 512 characters.
regionsobject[]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[].namestring, requiredThe region, such as eu-central-1. 1 to 64 characters.
regions[].replicasobject, requiredThe instance range in this region.
regions[].replicas.mininteger, requiredThe fewest instances to keep running.
regions[].replicas.maxinteger, requiredThe 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

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: production, preview, or its ID. 3 to 255 characters.
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. 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:

FieldTypeDescription
keystringThe variable's name.
kindstringrecoverable variables can be read back, writeonly ones can't. The dashboard calls write-only variables sensitive. Both are stored encrypted. One of recoverable, writeonly.
valuestringThe value. Only present for recoverable variables.
descriptionstringA note about the variable, if one was added.
createdAtintegerWhen 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

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: production, preview, or its ID. 3 to 255 characters.
variablesobject[], requiredThe variables to write. Each one replaces any existing variable with the same name. At most 50 items.
variables[].keystring, requiredThe name: letters, digits and underscores, not starting with a digit. 1 to 256 characters.
variables[].valuestring, requiredThe value. Always stored encrypted. 1 to 16384 characters.
variables[].kindanywriteonly, the default, makes the value unreadable after saving. recoverable allows reading it back. Default "writeonly".
variables[].descriptionstringAn optional note. At most 255 characters.
prunebooleanWhen 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

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: production, preview, or its ID. 3 to 255 characters.
variablesstring[], requiredThe 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.

Edit on GitHub

On this page