Skip to content

Set environment variable

POST
/api/v1/projects/{id}/env
curl --request POST \
--url https://api.deploybase.eu/api/v1/api/v1/projects/example/env \
--header 'Authorization: <Authorization>' \
--header 'Content-Type: application/json' \
--data '{ "environment": "production", "key": "example", "targets": [ "build" ], "value": "example" }'

Creates or updates a single environment variable (upsert by key+environment). New variables default to both targets (build and runtime); an update without targets keeps the variable’s own.

id
required
string

Project ID

Environment variable

Media type application/json
object
environment
required
string
Allowed values: production preview all
key
required
string
>= 1 characters <= 255 characters
targets

Targets is where the variable is injected: “build”, “runtime” or both. Omitted, a new variable gets both and an existing one keeps its own.

Array<string>
Allowed values: build runtime
value
required
string

OK

Media type application/json
object
data
meta
object
request_id
string
timestamp
string
trace_id
string
data
object
created_at
string
environment
string
Allowed values: production preview all
id
string
key
string
project_id
string
targets
Array<string>
Allowed values: build runtime
updated_at
string
warnings

Warnings are accepted-but-risky conditions the caller should show (NODE_OPTIONS).

Array<string>

Example

{
"data": {
"environment": "production",
"targets": [
"build"
]
}
}

Bad Request

Media type application/json
object
code
string
details
error
string
meta
object
request_id
string
timestamp
string
trace_id
string

Example generated

{
"code": "example",
"details": "example",
"error": "example",
"meta": {
"request_id": "example",
"timestamp": "example",
"trace_id": "example"
}
}

Unauthorized

Media type application/json
object
code
string
details
error
string
meta
object
request_id
string
timestamp
string
trace_id
string

Example generated

{
"code": "example",
"details": "example",
"error": "example",
"meta": {
"request_id": "example",
"timestamp": "example",
"trace_id": "example"
}
}

Not Found

Media type application/json
object
code
string
details
error
string
meta
object
request_id
string
timestamp
string
trace_id
string

Example generated

{
"code": "example",
"details": "example",
"error": "example",
"meta": {
"request_id": "example",
"timestamp": "example",
"trace_id": "example"
}
}

Unprocessable Entity

Media type application/json
object
code
string
details
error
string
meta
object
request_id
string
timestamp
string
trace_id
string

Example generated

{
"code": "example",
"details": "example",
"error": "example",
"meta": {
"request_id": "example",
"timestamp": "example",
"trace_id": "example"
}
}

Live a8b7eb1d built