Teral

Apps

Create apps from a repository or an image, and manage them.

An app is one deployable service inside a project. Its source is either a GitHub repository or a container image.

Create an app

POST /v1/apps.createApp

Creates an app in a project. Pass git to build from a GitHub repository or oci to run a container image. With git and no repository, you can connect one later. The app gets the environments production and preview.

Permissions: the key needs one of project.*.create_app, project.<project_id>.create_app.

Request

FieldTypeDescription
projectstring, requiredThe project, by ID or slug. 3 to 255 characters.
namestring, requiredThe app's name, shown in the dashboard. 1 to 256 characters.
slugstring, requiredThe app's slug, unique in the project. It's part of the app's generated URLs. 3 to 255 characters.
gitobjectUse a GitHub repository as the source. Send an empty object to connect the repository later.
git.repositorystringThe repository, as owner/name. The Teral GitHub App must have access to it. 1 to 255 characters.
git.defaultBranchstringThe branch that deploys to production. Defaults to the repository's default branch on GitHub. 1 to 256 characters.
ociobjectUse a container image as the source.
oci.imagestring, requiredThe image new deployments use, with a tag or digest, such as ghcr.io/acme/api:v1.4.0. It must be public. 1 to 256 characters.
curl -X POST https://api.teral.dev/v1/apps.createApp \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "shop",
    "name": "Web",
    "slug": "web",
    "git": {
      "repository": "acme/shop"
    }
  }'

Response

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

FieldTypeDescription
appIdstringThe new app's ID. 8 to 255 characters.

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


List apps

POST /v1/apps.listApps

Returns a project's apps, a page at a time.

Permissions: the key needs app.*.read_app.

Request

FieldTypeDescription
projectstring, requiredThe project, by ID or slug. 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.
searchstringOnly return apps whose ID, name or slug contains this text. Not case sensitive. At most 256 characters.
curl -X POST https://api.teral.dev/v1/apps.listApps \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "shop"
  }'

Response

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

FieldTypeDescription
idstringThe app's ID.
namestringThe app's name.
slugstringThe app's slug.
sourceTypestringWhere deployments come from: git for a repository, oci for an image. Missing for a few old apps. One of git, oci.
gitanyThe connected repository. Missing when no repository is connected.
git.repositorystringThe repository, as owner/name. 1 to 255 characters.
git.defaultBranchstringThe branch that deploys to production. 1 to 256 characters.
ocianyThe image source. Only present for image apps.
oci.imagestringThe image new deployments use. 1 to 256 characters.
currentDeploymentIdstringThe deployment serving production. Missing before the first production deployment.
isRolledBackbooleanWhether production is on a rolled-back deployment. While it is, new pushes don't take over production until you promote a deployment.
deleteProtectionbooleanWhether delete protection is on. A protected app can't be deleted.
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.


Get an app

POST /v1/apps.getApp

Returns one app with its source and live deployment.

Permissions: the key needs one of app.*.read_app, app.<app_id>.read_app.

Request

FieldTypeDescription
projectstring, requiredThe project, by ID or slug. 3 to 255 characters.
appstring, requiredThe app, by ID (app_…) or slug. 3 to 255 characters.
curl -X POST https://api.teral.dev/v1/apps.getApp \
  -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 app's ID.
namestringThe app's name.
slugstringThe app's slug.
sourceTypestringWhere deployments come from: git for a repository, oci for an image. Missing for a few old apps. One of git, oci.
gitanyThe connected repository. Missing when no repository is connected.
git.repositorystringThe repository, as owner/name. 1 to 255 characters.
git.defaultBranchstringThe branch that deploys to production. 1 to 256 characters.
ocianyThe image source. Only present for image apps.
oci.imagestringThe image new deployments use. 1 to 256 characters.
currentDeploymentIdstringThe deployment serving production. Missing before the first production deployment.
isRolledBackbooleanWhether production is on a rolled-back deployment. While it is, new pushes don't take over production until you promote a deployment.
deleteProtectionbooleanWhether delete protection is on. A protected app can't be deleted.
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, 403, 404, 429, 500. See Errors for the codes behind them.


Update an app

POST /v1/apps.updateApp

Changes an app's name, slug, repository, default image or delete protection. Fields you leave out stay as they are. Changing the source type between repository and image isn't possible.

Permissions: the key needs one of app.*.update_app, app.<app_id>.update_app.

Request

FieldTypeDescription
projectstring, requiredThe project, by ID or slug. 3 to 255 characters.
appstring, requiredThe app, by ID or slug. 3 to 255 characters.
namestringA new name. 1 to 256 characters.
slugstringA new slug. 3 to 255 characters.
gitobject or nullChanges the connected repository. Send null to disconnect it. Send only the field you want to change.
git.repositorystringConnects this repository, as owner/name, replacing the current one. 1 to 255 characters.
git.defaultBranchstringThe branch that deploys to production from now on. 1 to 256 characters.
ocianyChanges the image of an image app. This doesn't deploy anything.
oci.imagestring, requiredThe image new deployments use, with a tag or digest. 1 to 256 characters.
deleteProtectionbooleanTurns delete protection on or off.
curl -X POST https://api.teral.dev/v1/apps.updateApp \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "shop",
    "app": "web",
    "git": {
      "defaultBranch": "release"
    }
  }'

Response

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

FieldTypeDescription
idstringThe app's ID.
namestringThe app's name.
slugstringThe app's slug.
sourceTypestringWhere deployments come from: git for a repository, oci for an image. Missing for a few old apps. One of git, oci.
gitanyThe connected repository. Missing when no repository is connected.
git.repositorystringThe repository, as owner/name. 1 to 255 characters.
git.defaultBranchstringThe branch that deploys to production. 1 to 256 characters.
ocianyThe image source. Only present for image apps.
oci.imagestringThe image new deployments use. 1 to 256 characters.
currentDeploymentIdstringThe deployment serving production. Missing before the first production deployment.
isRolledBackbooleanWhether production is on a rolled-back deployment. While it is, new pushes don't take over production until you promote a deployment.
deleteProtectionbooleanWhether delete protection is on. A protected app can't be deleted.
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, 403, 404, 409, 429, 500. See Errors for the codes behind them.


Delete an app

POST /v1/apps.deleteApp

Deletes an app with its deployments, domains and variables. The response comes right away and the cleanup runs in the background. Fails with 412 while delete protection is on.

Permissions: the key needs one of app.*.delete_app, app.<app_id>.delete_app.

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/apps.deleteApp \
  -H "Authorization: Bearer $TERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "shop",
    "app": "web"
  }'

Response

On success the status is 202 Accepted.

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

Edit on GitHub

On this page