Environment variables
App-level variables and the team-owned shared variables that link into several apps at once.
A variable is plain or secret and applies to one or more targets (production, preview). A shared variable is owned by the team and linked into apps; the link is what injects it.
A secret variable is write-only and immutable
Once a row is secret, upsertEnv, renameEnv and saveSharedVar refuse it, setAppEnv skips it, and importEnv counts it in skippedSecrets instead of writing over it. Rotating one is delete + create, and no mutation turns a secret back into a plain variable. The reverse (plain to secret) is always allowed.
App variables
env
Any signed-in principal. Returns [EnvVar!].
Env vars of a single project (requires manage_env).
| Argument | Type | Description |
|---|---|---|
appId | String! |
query {
env(appId: "prj_9f1c2ab7d3e4f5a6") {
id
key
type
targets
isMasked
}
}allAppEnv
Any signed-in principal. Returns [AppEnvGroup!].
Every app's env vars in the active team, grouped by project.
query {
allAppEnv {
app {
slug
}
vars {
key
type
}
}
}upsertEnv
Needs manage_env. Returns EnvVar.
Create or update an env var, then return the stored entity.
| Argument | Type | Description |
|---|---|---|
input | UpsertEnvInput! | |
input.appId | String! | |
input.key | String! | |
input.targets | [EnvTarget!] | One of preview, production. |
input.type | EnvVarType! | One of plain, secret. |
input.value | String! |
mutation {
upsertEnv(
input: { appId: "prj_9f1c2ab7d3e4f5a6", key: "DATABASE_URL", value: "postgres://shop:secret@db-orders:5432/orders", type: secret, targets: [production, preview] }
) {
id
key
type
targets
isMasked
}
}renameEnv
Needs manage_env. Returns EnvVar.
Rename an env var's key in place, then return the stored entity.
| Argument | Type | Description |
|---|---|---|
id | String! | |
newKey | String! |
mutation {
renameEnv(id: "env_9f1c2ab7d3e4f5a6", newKey: "POSTGRES_URL") {
id
key
type
targets
isMasked
}
}deleteEnv
Needs manage_env. Returns Boolean.
Delete an env var. Returns true.
| Argument | Type | Description |
|---|---|---|
id | String! |
mutation {
deleteEnv(id: "env_9f1c2ab7d3e4f5a6")
}setAppEnv
Needs manage_env. Returns Int.
Replace an app's whole env set from the .env editor (upsert the given entries, delete the rest). New vars default to plain; existing secrets are left untouched. Returns the resulting variable count.
| Argument | Type | Description |
|---|---|---|
appId | String! | |
defaultTargets | [EnvTarget!] | One of preview, production. |
entries | [EnvEntryInput!]! | |
entries.key | String! | |
entries.value | String! |
mutation {
setAppEnv(
appId: "prj_9f1c2ab7d3e4f5a6"
entries: [{ key: "NODE_ENV", value: "production" }, { key: "PORT", value: "3000" }]
defaultTargets: [production, preview]
)
}importEnv
Needs manage_env. Returns EnvImportResult.
Bulk-import a .env-style blob. Every line lands as plain, so a key that already exists as a secret is skipped rather than downgraded.
| Argument | Type | Description |
|---|---|---|
appId | String! | |
blob | String! | |
targets | [EnvTarget!] | One of preview, production. |
mutation {
importEnv(appId: "prj_9f1c2ab7d3e4f5a6", blob: "API_URL=https://api.example.com\nLOG_LEVEL=info", targets: [production]) {
added
skippedSecrets
}
}makeEnvSecret
Needs manage_env. Returns Boolean.
Make a variable Secret without changing its stored value or scope.
| Argument | Type | Description |
|---|---|---|
id | String! |
mutation {
makeEnvSecret(id: "env_9f1c2ab7d3e4f5a6")
}Shared variables
sharedVars
Needs manage_env. Returns [SharedVar!].
All shared variables in the active team, A->Z.
query {
sharedVars {
id
key
type
teamWide
}
}sharedVarsForApp
Needs manage_env. Returns [AppSharedVar!].
Every team shared variable as seen from one app, with its opt-in (link) state.
| Argument | Type | Description |
|---|---|---|
appId | String! |
query {
sharedVarsForApp(appId: "prj_9f1c2ab7d3e4f5a6") {
id
key
linked
inScope
}
}saveSharedVar
Needs manage_env. Returns SharedVar.
Create or update a shared variable; returns the saved entity.
| Argument | Type | Description |
|---|---|---|
input | SaveSharedVarInput! | |
input.appIds | [String!] | The per-app links, as a whole set. OMIT to leave the existing links untouched - that is what preserves setSharedVarAppLink's app-side toggle. |
input.environmentIds | [ID!]! | |
input.id | String | |
input.key | String! | |
input.projectIds | [ID!]! | |
input.targets | [EnvTarget!] | One of preview, production. |
input.teamIds | [ID!]! | Teams every app of which gets this variable. ONE team => it is only SUGGESTED there and the per-app link injects (ADR-0012); TWO OR MORE => it is injected into every app of every one of them, with no link, at the lowest precedence. The caller must hold manage_env across the whole of every team named here. |
input.type | EnvVarType! | One of plain, secret. |
input.value | String! |
mutation {
saveSharedVar(
input: { key: "API_BASE_URL", value: "https://api.example.com", type: plain, teamIds: [], projectIds: [], environmentIds: [], appIds: ["prj_9f1c2ab7d3e4f5a6"] }
) {
id
key
type
teamWide
}
}setSharedVarAppLink
Needs manage_env. Returns Boolean.
Link or unlink a shared variable to one app. Returns true.
| Argument | Type | Description |
|---|---|---|
appId | String! | |
linked | Boolean! | |
varId | String! |
mutation {
setSharedVarAppLink(varId: "svar_9f1c2ab7d3e4f5a6", appId: "prj_9f1c2ab7d3e4f5a6", linked: true)
}deleteSharedVar
Needs manage_env. Returns Boolean.
Delete a shared variable. Returns true.
| Argument | Type | Description |
|---|---|---|
id | String! |
mutation {
deleteSharedVar(id: "svar_9f1c2ab7d3e4f5a6")
}makeSharedVarSecret
Needs manage_env. Returns Boolean.
Make a variable Secret without changing its stored value or scope.
| Argument | Type | Description |
|---|---|---|
id | String! |
mutation {
makeSharedVarSecret(id: "svar_9f1c2ab7d3e4f5a6")
}See also
Did this page help you?