We do not automatically restart your application when you create/update/delete an environment variable, you have to do it yourself when all the modifications have been done. Look at the ‘restart application’ endpoint.
Environment variable attributes
field | type | description |
---|---|---|
id | string | unique ID of variable |
name | string | name |
value | string | value |
Example object:
{
"id": "541013a9736f7563d5050000",
"name": "MONGO_URL",
"value": "mongodb://user:password@host:port/db"
}
GET https://$SCALINGO_API_URL/v1/apps/[:app]/variables
All the variables are returned, without interpolating anything.
aliases
: (default: true
)
true:
SCALINGO_MONGO_URL=mongodb://user:password@host:port/db
DATABASE_URL=$SCALINGO_MONGO_URL
false
:
SCALINGO_MONGO_URL=mongodb://user:password@host:port/db
DATABASE_URL=mongodb://user:password@host:port/db
Example request
curl -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-X GET https://$SCALINGO_API_URL/v1/apps/example-app/variables
Returns 200 OK
Response
{
"variables": [
{
"id": "541013a9736f7563d5050000",
"name": "MONGO_URL",
"value": "mongodb://user:password@host:port/db"
},
{
"id": "54101384736f7563d5040000",
"name": "RAILS_PRODUCTION",
"value": "production"
}
]
}
There is a limit of 64 characters for the name of the variables and 8192 for values.
POST https://$SCALINGO_API_URL/v1/apps/[:app]/variables
Example request
curl -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-X POST https://$SCALINGO_API_URL/v1/apps/example-app/variables -d \
'{
"variable": {
"name":"RAILS_ENV",
"value":"production"
}
}'
Returns 201 Created
Response
{
"variable": {
"id": "541013a9736f7563d5050000",
"name": "RAILS_ENV",
"value": "production"
}
}
The bulk update will create or update all the variables sent in the body
PUT https://$SCALINGO_API_URL/v1/apps/[:app]/variables
Example request
curl -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-X PUT https://$SCALINGO_API_URL/v1/apps/example-app/variables -d \
'{
"variables": [{
"name":"RAILS_ENV",
"value":"production"
},{
"name":"RACK_ENV",
"value":"production"
}]
}'
Returns 200 OK
Response
{
"variables": [{
"id": "541013a9736f7563d5050000",
"name":"RAILS_ENV",
"value":"production"
},{
"id": "541013a9736f7563d5050001",
"name":"RACK_ENV",
"value":"production"
}]
}
PATCH https://$SCALINGO_API_URL/v1/apps/[:app]/variables/[:variable_id]
Update an environment variable, only the value can be updated, if your want to change the name, create a new one.
Example request
curl -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-X PATCH https://$SCALINGO_API_URL/v1/apps/example-app/variables/54101384736f7563d5040000 -d \
'{
"variable": {
"value":"staging"
}
}'
Returns 200 OK
Response
{
"variable": {
"id": "54101384736f7563d5040000",
"name": "RAILS_PRODUCTION",
"value": "staging"
}
}
DELETE https://$SCALINGO_API_URL/v1/apps/[:app]/variables/[:variable_id]
Delete definitively an environment variable of an app.
Example request
curl -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-X DELETE https://$SCALINGO_API_URL/v1/apps/example-app/variables/54101384736f7563d5040000
Returns 204 No Content
DELETE https://$SCALINGO_API_URL/v1/apps/[:app]/variables
The bulk delete will delete all the variables sent in the body.
Example request
curl -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-X DELETE https://$SCALINGO_API_URL/v1/apps/example-app/variables -d \
'{
"variable_ids": ["541013a9736f7563d5050000"]
}'
Returns 204 No Content