API V1
  • Global information
  • Authentication
  • Data format
  • Rate Limit
  • Errors
  • Pagination
RESOURCES
  • Addon providers
  • Addons
  • Alerts
  • Applications
  • Audit Logs
  • Autoscalers
  • Billing
  • Collaborators
  • Container Sizes
  • Cron Tasks
  • Data Access Consents
  • Databases
  • Deployment
  • Domains
  • Environment variables
    • List environment variables of an app
    • Add environment variables to an app
    • Bulk update of the environment of an app
    • Update an environment variable
    • Delete an environment variable
    • Bulk delete environment variables of an app
  • Event Categories
  • Event Types
  • Events
  • Invoices
  • SSH Keys
  • Log Drains
  • Application Logs
  • Metrics
  • Notification Platforms
  • Notifiers
  • One-off Containers
  • Operations
  • Projects
  • Referral
  • Regions
  • SCM Integrations
  • Integration Link
  • Sources
  • Stacks
  • Tokens
  • User Account
LINKS
  • Addon Provider API
  • Database API
  • One-click Deployment API
  • scalingo.json Schema
  • Main site
  • Dashboard

Environment variables

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"
}

List environment variables of an app

GET https://$SCALINGO_API_URL/v1/apps/[:app]/variables

All the variables are returned, without interpolating anything.

Parameters

  • 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"
        }
    ]
}

Add environment variables to an app

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"
    }
}

Bulk update of the environment of an app

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"
    }]
}

Update an environment variable

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 an environment variable

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

Bulk delete environment variables of an app

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