Skip to content

Add a database to an application

POST
/api/v3/organizations/{organisation}/applications/{application}/database
curl --request POST \
--url https://dashboard.quantcdn.io/api/v3/organizations/example/applications/example/database \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "engine": "mysql", "instanceClass": "db.t4g.micro", "storageGb": 20, "multiAz": false }'

Provisions a second database next to the one the application has and sets up every environment on it. Nothing the running environments use changes: DB_NEXT_HOST, DB_NEXT_PORT, DB_NEXT_DATABASE and DB_NEXT_ENGINE are added, and the existing DB_USERNAME and DB_PASSWORD are valid on both. It answers 202 at once; poll the status URL until status is ready or failed. The new database has its own user and password per environment: the application connects to the old one with DB_* and to the new one with DB_NEXT_* (DB_NEXT_USERNAME and DB_NEXT_PASSWORD are secret references). Take a backup before promoting. Repeating the request after the worker has finished resumes it, or adds an environment created since. Only one database operation runs per application at a time: a second provision, promote or delete answers 409 while one holds the lock, including a repeat of the same provision while its worker is still running. Needs the write_applications permission and the cloud:write scope.

organisation
required
string

The organisation ID

application
required
string

The application ID

Media typeapplication/json
object
engine
required
string
Allowed values: mysql postgres
instanceClass
string
default: db.t4g.micro
Allowed values: db.t4g.micro db.t4g.small db.t4g.medium db.t4g.large db.t4g.xlarge db.t4g.2xlarge
Example
db.t4g.small
storageGb

Allocated storage in GiB. Storage autoscaling is on, up to 1000.

integer
default: 20 >= 20 <= 900
multiAz
boolean

Provisioning started, resumed, or already in progress

Media typeapplication/json
object
message
string
orgName
string
appName
string
instanceId
string
engine
string
Allowed values: mysql postgres
status
string
Allowed values: provisioning ready failed
statusUrl

The API path to poll.

string
environmentVariables
Array<string>
environmentSecretReferences

DB_NEXT_USERNAME and DB_NEXT_PASSWORD: secret references into the new database’s own credentials. Never values.

Array<string>
note
string
Example
{
"engine": "mysql",
"status": "provisioning",
"statusUrl": "/api/v3/organizations/acme/applications/api/database/acme-api-db-postgres"
}

The application was not found

Another database operation holds the application’s lock (operation says which; for a provision in flight the body has instanceId and statusUrl), a different database is already pending, a previous database is still kept, or the identifier is taken. Nothing was changed

Media typeapplication/json
object
message
string
operation

409 only: the operation that holds the application’s lock.

string
Allowed values: provision promote delete
requested

409 only: the operation that was refused.

string
Allowed values: provision promote delete
instanceId

409 only: the pending or previous database that blocks the request, or the provision in flight.

string
statusUrl

409 only: for a provision in flight, the path to poll on the platform (this API serves it at the database route).

string
environments

Promote 409 only: the environments that have no user, or unreadable credentials, on the instance.

Array<string>
errors

Delete 500 only: what could not be cleaned up.

Array<string>
Example
{
"operation": "provision",
"requested": "provision"
}

The body is invalid