/ api reference
Environment variables
Variables are managed per project, one entry per key, with a value in each environment that has it. Values are encrypted at rest, and a secret's value is never returned by any route.
A deployment reads its variables when it's built: redeploy after a change.
- get/projects/{projectId}/variablesList variables
- post/projects/{projectId}/variablesCreate variables
- patch/projects/{projectId}/variables/{key}Update a variable
- delete/projects/{projectId}/variables/{key}Delete a variable
List variables
/api/v1/projects/{projectId}/variablesOne entry per key, with its value in each of the project's environments. A secret's value is never returned, by this route or any other; sameValue says whether every environment holds the same one. value at the top level is set when sameValue is true and the variable is not secret.
Requires Viewer key or above (workspace.read)
Parameters
projectIdstringin pathrequired
Responses
200The project's environments and variables.Response fields
environmentsobject[]required3 fields
idstringrequirednamestringrequiredactiveDeploymentIdstring | nullrequired
variablesobject[]required8 fields
keystringrequiredsecretbooleanrequirednotestring | nullrequiredtargets("build" | "runtime")[]requiredsameValuebooleanrequiredvaluestringupdatedAtstringrequiredenvironmentsobject[]required4 fields
environmentIdstringrequiredsecretbooleanrequiredvaluestringupdatedAtstringrequired
404No such project in this workspace.
Create variables
/api/v1/projects/{projectId}/variablesSets up to 100 variables, with the same values, in each of environmentIds. Values are encrypted at rest. All or nothing: if a key already exists in one of the environments, nothing is written and the 409 lists every conflict. targets says where the values are available: build (the install and build commands, where a framework can inline them into your files) and/or runtime (the deployed app); runtime when left out. A secret is runtime only. Each variable can set its own secret and targets; the request-level ones apply to the variables that don't. A running deployment reads new values only once redeployed, and a build variable only once rebuilt.
Requires Developer key or above (variables.write)
Parameters
projectIdstringin pathrequired
Body
secretbooleanThe type of every variable that doesn't set its own.
targets("build" | "runtime")[]Where the value is available: `build` (the install and build commands) and/or `runtime` (the deployed app). A secret is `runtime` only.
at least 1 item · at most 2 items
environmentIdsstring[]requiredat least 1 item
variablesobject[]requiredat least 1 item · at most 100 items
5 fields
keystringrequiredmatches ^[A-Z_][A-Z0-9_]*$
valuestringrequiredat most 4096 characters
notestring | nullat most 500 characters
secretbooleanThis variable's type, over the request's `secret`.
targets("build" | "runtime")[]Where the value is available: `build` (the install and build commands) and/or `runtime` (the deployed app). A secret is `runtime` only.
at least 1 item · at most 2 items
Responses
201The created variables.Response fields
variablesobject[]required8 fields
keystringrequiredsecretbooleanrequirednotestring | nullrequiredtargets("build" | "runtime")[]requiredsameValuebooleanrequiredvaluestringupdatedAtstringrequiredenvironmentsobject[]required4 fields
environmentIdstringrequiredsecretbooleanrequiredvaluestringupdatedAtstringrequired
400A malformed or reserved key (HIRAISHIP,HIRAISHIP_*,PATH,HOME, the proxy variables).404No such project in this workspace.409Some keys already exist in the chosen environments.Body: see Errors
422A secret with thebuildtarget, an environment of another project, the same key twice, or more than an environment's 100 variables.
Update a variable
/api/v1/projects/{projectId}/variables/{key}Every field is optional. key renames it, secret: true hides its values from now on, and environments is the full set of environments the variable is kept in: one left out loses it, one with no value keeps its own, and an added one with no value takes the value the others share (when they differ, it needs one). targets replaces where the variable is available. A secret can never become a plain variable again, and can never have the build target.
Requires Developer key or above (variables.write)
Parameters
projectIdstringin pathrequiredkeystringin pathrequired
Body
keystringmatches ^[A-Z_][A-Z0-9_]*$
secretbooleantargets("build" | "runtime")[]Where the value is available: `build` (the install and build commands) and/or `runtime` (the deployed app). A secret is `runtime` only.
at least 1 item · at most 2 items
notestring | nullat most 500 characters
environmentsobject[]at least 1 item
2 fields
environmentIdstringrequireduuid
valuestringat most 4096 characters
Responses
200The variable.Response fields
keystringrequiredsecretbooleanrequirednotestring | nullrequiredtargets("build" | "runtime")[]requiredsameValuebooleanrequiredvaluestringupdatedAtstringrequiredenvironmentsobject[]required4 fields
environmentIdstringrequiredsecretbooleanrequiredvaluestringupdatedAtstringrequired
404No such project in this workspace, or no variable with that key.409The new key already exists in one of the environments.Body: see Errors
422A secret turned back into a plain variable, a secret with thebuildtarget, an environment of another project, an added environment with novaluewhile the others differ, or more than 100 variables in one environment.
Delete a variable
/api/v1/projects/{projectId}/variables/{key}Removes the key from every environment of the project.
Requires Developer key or above (variables.write)
Parameters
projectIdstringin pathrequiredkeystringin pathrequired
Responses
204Deleted.404Project not found, or no variable with that key.