Set environment variables with the Apps API
Give an app settings and secrets through the Apps API, for its build, its replicas or both, and apply them with a release.
Environment variables give an app its settings and secrets, such as a database address or a key for another service. Each variable reaches the build, the running app or both. Once you save a value, the API never shows it again.
The Apps API sets the variables of the all environment, which the dashboard shows as All environments on the Variables tab of the app's page under App Deployment. Every release reads them, unless production, previews or a branch have a value of their own for the same name (Environments and variables). Values for one environment, .env files and env groups are set on that tab or through the deployments API. This page covers the Apps API, which scripts written for Apps keep using.
Before you begin
Section titled Before you begin- Send your access token as
Authorization: Bearer $CORITAN_TOKEN(Authentication). Each request takes the app'suuid, whichGET /api/v1/client/appslists. - For an organization's app, you need the owner or admin role in the organization to change variables, and every member can read their names. Send the same requests under
/api/v1/orgs/{org_slug}/apps(organization apps reference). - A change reaches the app with its next release (Apply a change).
Names and values
Section titled Names and valuesA name has upper-case letters, digits and underscores, does not start with a digit, and has at most 128 characters, such as DATABASE_URL. These names are set by the platform, so you cannot use them:
PORT,TZ,STARTUP,SERVER_MEMORY,SERVER_IPandSERVER_PORT- any name that starts with
CORITAN_orP_SERVER_, except the three names in Names your app reads
A value can be empty, and holds up to 32 KiB. An app has up to 200 variables, and their names and values together hold up to 256 KiB.
Where a variable reaches
Section titled Where a variable reachesEach variable has a target:
both- The build and every replica get it. New variables have this target unless you choose another.
runtime- Only the replicas get it.
build- Only the build gets it, as an environment variable of the install and build commands (Builds).
An image app is not built, so only the variables its replicas get reach it. Every replica also gets PORT, CORITAN_APP, CORITAN_REGION and CORITAN_DEPLOYMENT (What your app must do).
Names your app reads
Section titled Names your app readsThree names that start with CORITAN_ are ones the platform never sets. Your own app reads them when it runs, so you can set them:
| Name | Use |
|---|---|
CORITAN_ORG_API_KEY |
A value your app reads, such as an organization API key it sends to the Organization API. |
CORITAN_WEBHOOK_SECRET |
A value your app reads, such as the secret that signs the webhooks it receives. |
CORITAN_MICROSOFT_ADS_FEED_URL |
The full feed URL that the Microsoft Ads integration shows once. A storefront that holds it asks Coritan to claim each order (Microsoft Ads). |
The platform does not set or read these names. Your app decides what each holds.
Set each one with the target runtime. The build leaves out every name that starts with CORITAN_, so a value with the target build or both never reaches it, and a build cannot read these three. Like any new variable, each is secret unless you say otherwise. A change reaches the app with its next release, so redeploy after you set one (Apply a change).
Every other name that starts with CORITAN_, such as CORITAN_REGION, and every name that starts with P_SERVER_, stays refused.
Secret and plain values
Section titled Secret and plain valuesA variable is secret unless you say otherwise. A secret value of six characters or more appears as [redacted] in the build log. A plain value can appear in the build log as it is.
Both kinds are stored encrypted, and neither is ever shown again after you save it. For a value of eight characters or more, the variable shows its last four characters as hint, so you can tell which value is saved. To change a value, replace it.
Apply a change
Section titled Apply a changeReplicas keep the variables they started with. After you change a variable:
- For one that the running app reads, redeploy the app.
- For one that the build reads, such as a build-time
NEXT_PUBLIC_value, rebuild the app, so the build runs again.
Redeploy and Rebuild show both. The answer to each change says redeploy_required when a new release is needed.
A value that cannot be read
Section titled A value that cannot be readRarely, a saved value can no longer be opened on the platform, and the variable's readable is false. The running app starts without it, and a build that needs it fails with The build variable API_KEY cannot be read on this platform. Save it again. Set the variable again with its value.
With the API
Section titled With the APIIn each request, target is both, runtime or build.
List variables
Section titled List variablesGET /api/v1/client/apps/{app_uuid}/env lists the variables by name, without their values:
curl https://api.coritan.com/api/v1/client/apps/3c9e2f4a-8b1d-4f6e-a2c7-5d8b9e0f1a21/env \
-H "Authorization: Bearer $CORITAN_TOKEN"
{
"vars": [
{
"key": "DATABASE_URL",
"secret": true,
"target": "runtime",
"value": null,
"hint": "shop",
"readable": true,
"created_at": "2026-09-20T09:12:00Z",
"updated_at": "2026-09-24T16:40:00Z"
},
{
"key": "NODE_ENV",
"secret": false,
"target": "both",
"value": null,
"hint": null,
"readable": true,
"created_at": "2026-09-20T09:12:00Z",
"updated_at": "2026-09-20T09:12:00Z"
}
]
}
value is always null. hint is the last four characters of a value of eight characters or more, and null otherwise. readable is false when the saved value can no longer be opened.
Set one variable
Section titled Set one variablePUT /api/v1/client/apps/{app_uuid}/env/{key} creates the variable or changes it. The body takes value, secret and target. A new variable needs value. For one that exists, leave value out to keep the saved value while you change secret or target. A name cannot change: to rename a variable, delete it and set it again.
curl -X PUT https://api.coritan.com/api/v1/client/apps/3c9e2f4a-8b1d-4f6e-a2c7-5d8b9e0f1a21/env/STRIPE_KEY \
-H "Authorization: Bearer $CORITAN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"value": "sk_live_EXAMPLE0000", "target": "runtime"}'
{
"var": {"key": "STRIPE_KEY", "secret": true, "target": "runtime", "value": null, "hint": "0000", "readable": true},
"created": true,
"redeploy_required": true
}
created is true for a new variable. The example shortens var.
Set many variables
Section titled Set many variablesPUT /api/v1/client/apps/{app_uuid}/env sets up to 200 variables in one request. Each item in vars has a key and the same value, secret and target as above. With "replace": true, every variable not in the list is deleted.
curl -X PUT https://api.coritan.com/api/v1/client/apps/3c9e2f4a-8b1d-4f6e-a2c7-5d8b9e0f1a21/env \
-H "Authorization: Bearer $CORITAN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"vars": [{"key": "NODE_ENV", "value": "production", "secret": false}, {"key": "DATABASE_URL"}], "replace": true}'
{
"created": [],
"updated": ["NODE_ENV"],
"deleted": ["STRIPE_KEY"],
"redeploy_required": true
}
created, updated and deleted name the variables the request touched. DATABASE_URL kept its value because the request left value out. The answer also holds vars, every variable after the change, as in the list above. "replace": true deletes only variables of the all environment: values for one environment or branch stay.
Delete a variable
Section titled Delete a variableDELETE /api/v1/client/apps/{app_uuid}/env/{key} deletes one variable and answers {"deleted": "STRIPE_KEY", "redeploy_required": true}. Running replicas keep it until the next release, and the value cannot be recovered.
Errors
Section titled Errors| Status | detail |
Cause |
|---|---|---|
404 |
Variable not found |
The app has no variable with that name. |
422 |
{"message": "PORT is set by the platform and cannot be changed", "field": "key"} |
The name is one the platform sets. PORT and every name that starts with CORITAN_ or P_SERVER_ are refused, except the three in Names your app reads. |
422 |
{"message": "API_KEY needs a value", "field": "value"} |
A new variable came without value. |
422 |
{"message": "The value of API_KEY is larger than 32 KiB", "field": "value"} |
The value is too long. |
422 |
{"message": "API_KEY appears twice", "field": "key"} |
vars names one variable twice. |
422 |
An app can have at most 200 variables |
The change would leave the app with more than 200. |
422 |
The environment is larger than 256 KiB in total |
The names and values would hold more than 256 KiB. |
422 |
A deployment can have at most 1000 variables across its environments and branches |
With the values set for each environment and branch, the app would hold more than 1000. |
Result
Section titled ResultGET /api/v1/client/apps/{app_uuid}/env lists each name with its target, whether it is secret, and the hint of its value. The next release uses them.
Troubleshooting
Section titled Troubleshooting'database_url' is not a variable name: upper-case letters, digits and underscores, not starting with a digit, at most 128 characters- Change the name, for example to
DATABASE_URL. PORT is set by the platform and cannot be changed- The platform sets that name on every replica. Use another name, and read
PORTto know where to listen. The same message appears forCORITAN_REGIONand any other name that starts withCORITAN_, exceptCORITAN_ORG_API_KEY,CORITAN_WEBHOOK_SECRETandCORITAN_MICROSOFT_ADS_FEED_URL. - A
CORITAN_variable is empty during the build - The build leaves out every name that starts with
CORITAN_. SetCORITAN_ORG_API_KEY,CORITAN_WEBHOOK_SECRETorCORITAN_MICROSOFT_ADS_FEED_URLwith the targetruntimeand read it from the running app. The environment is larger than 256 KiB in total- Shorten or delete some values. A large file is better kept in Object Storage and fetched when the app starts.
- A variable does not change in the running app
- Replicas keep the variables they started with. Redeploy the app, or rebuild it for a variable the build reads. A value that production or a branch sets for the same name also wins over the one the Apps API sets.
Related
Section titled Related- Deploy an app with the Apps API
- How the Apps API runs an app
- Apps API limits
- Environments and variables, for environments,
.envfiles and env groups
API operations on this page
| Method | Path | What it does |
|---|---|---|
GET | /api/v1/client/apps/{app_uuid}/env | List an app's environment variables without their values |
PUT | /api/v1/client/apps/{app_uuid}/env | Set many variables; a variable given without value keeps its saved one |
PUT | /api/v1/client/apps/{app_uuid}/env/{key} | Set one environment variable, creating it when it is new |
DELETE | /api/v1/client/apps/{app_uuid}/env/{key} | Delete one environment variable |
GET | /api/v1/orgs/{org_slug}/apps/{app_uuid}/env | List an app's environment variables without their values |
PUT | /api/v1/orgs/{org_slug}/apps/{app_uuid}/env | Set many variables; a variable given without value keeps its saved one |
PUT | /api/v1/orgs/{org_slug}/apps/{app_uuid}/env/{key} | Set one environment variable, creating it when it is new |
DELETE | /api/v1/orgs/{org_slug}/apps/{app_uuid}/env/{key} | Delete one environment variable |