Add a database to an application
const url = 'https://dashboard.quantcdn.io/api/v3/organizations/example/applications/example/database';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"engine":"mysql","instanceClass":"db.t4g.micro","storageGb":20,"multiAz":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The organisation ID
The application ID
Request Bodyrequired
Section titled “Request Bodyrequired”object
Example
db.t4g.smallAllocated storage in GiB. Storage autoscaling is on, up to 1000.
Responses
Section titled “Responses”Provisioning started, resumed, or already in progress
object
The API path to poll.
DB_NEXT_USERNAME and DB_NEXT_PASSWORD: secret references into the new database’s own credentials. Never values.
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
object
409 only: the operation that holds the application’s lock.
409 only: the operation that was refused.
409 only: the pending or previous database that blocks the request, or the provision in flight.
409 only: for a provision in flight, the path to poll on the platform (this API serves it at the database route).
Promote 409 only: the environments that have no user, or unreadable credentials, on the instance.
Delete 500 only: what could not be cleaned up.
Example
{ "operation": "provision", "requested": "provision"}The body is invalid
