Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

Create an environment variable

POST/v1/environment-variablesCreate an environment variable

⚠️ Experimental endpoint: this API is in active development and may change at any time without notice. ⚠️

Creates a new environment variable in a project's production or preview environment, or a preview branch override when branchId is supplied. Returns 409 if a variable with the same key already exists in that scope — use PATCH to replace its value. Values are stored encrypted and are not returned by subsequent reads.

Request body

application/json
object
branchIdstring

pattern ^(br_)?([cC][^\s-]{8,}|[a-z0-9]+)$

classstringrequired

one of "production", "preview"

keystringrequired

maxLength 256 · minLength 1 · pattern ^[A-Z_][A-Z0-9_]*$

projectIdstringrequired

pattern ^(proj_)?([cC][^\s-]{8,}|[a-z0-9]+)$

valuestringrequired

minLength 1

Example request
{
  "branchId": "string",
  "class": "preview",
  "key": "string",
  "projectId": "string",
  "value": "string"
}

Responses

201Variable created.application/json
object
dataobjectrequired
Show child attributes
branchIdnull | stringrequired
classstringrequired

one of "production", "preview"

createdAtstring · date-timerequired
idstringrequired
isManagedBySystembooleanrequired
keystringrequired
projectIdstringrequired
typestringrequired

const "environment-variable"

updatedAtstring · date-timerequired
urlstring · urirequired
valueKidstringrequired
Example response
{
  "data": {
    "branchId": "string",
    "class": "preview",
    "createdAt": "2026-06-09T00:00:00Z",
    "id": "string",
    "isManagedBySystem": true,
    "key": "string",
    "projectId": "string",
    "type": "environment-variable",
    "updatedAt": "2026-06-09T00:00:00Z",
    "url": "https://example.com",
    "valueKid": "string"
  }
}
401Missing or invalid authorization token.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
404Project not found, or token does not have access to it.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
409A variable with this key already exists in this environment.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
422Invalid request.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
500Internal error while processing the encrypted variable (e.g., a master-key rotation or deploy issue prevents the project's wrapped DEK from being decrypted). Not a client-fixable condition.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
Documentation menu