Change a database's size
Change the database's memory size, grow its storage, or both. Send size (256mb, 512mb, 1gb, 2gb, 4gb or 8gb) or memorySizeBytes for memory, and storageBytes for storage. Changing the memory restarts the database straight away, so it cannot take connections for a short time: the answer is HTTP 202 with restarting true and an operation to poll (getProjectOperation); if the new size cannot be applied, that operation fails and its errorMessage says what happened; read getDatabase for the size the database has now. The memory can change only while the database is running (HTTP 409 database_not_running otherwise), and nothing changes while other work runs on the database, such as a backup, restore, import or another resize (HTTP 409 workload_busy or conflict). Storage can only grow: a smaller amount than the database has returns HTTP 400 storage_cannot_shrink; growing it needs no restart. Every running app and database counts its size against the plan's memory (limits.ram_mb in getCapabilities), and every one counts its storage (limits.storage_gb); a size or storage that does not fit returns HTTP 409 plan_full with details.quota saying which resource ran out and how much is free. Stopping an app, or making an app or another database smaller, frees memory. A server that cannot change database sizes yet returns HTTP 409 resize_unavailable.
/api/customer/v1/projects/{projectId}/databases/{databaseId}/sizeThis operation can remove, overwrite or interrupt resources, or grant access. Check the project and resource IDs before sending it.
Send an Idempotency-Key header. Keep the same value when retrying this exact request. A different payload needs a new key.
Path parameters
| Name | Value |
|---|---|
projectId | Required resource ID from an earlier API response. |
databaseId | Required resource ID from an earlier API response. |
Request body
Send JSON with Content-Type: application/json. Nested fields and accepted values are listed in the schema.
| Field | Type | Required |
|---|---|---|
size | "256mb" | "512mb" | "1gb" | "2gb" | "4gb" | "8gb" | No |
memorySizeBytes | 268435456 | 536870912 | 1073741824 | 2147483648 | 4294967296 | 8589934592 | No |
storageBytes | integer | No |
Full request schema
{
"type": "object",
"properties": {
"size": {
"type": "string",
"enum": [
"256mb",
"512mb",
"1gb",
"2gb",
"4gb",
"8gb"
]
},
"memorySizeBytes": {
"type": "integer",
"enum": [
268435456,
536870912,
1073741824,
2147483648,
4294967296,
8589934592
]
},
"storageBytes": {
"type": "integer",
"minimum": 1,
"maximum": 1125899906842624
}
},
"required": [],
"additionalProperties": false
}Example request
Set HCODE_BASE_URL and HCODE_API_KEY as shown in Getting started. Replace resource variables with your own IDs.
Set REQUEST_ID to a unique value for this request.
curl --request PATCH "$HCODE_BASE_URL/api/customer/v1/projects/${PROJECT_ID}/databases/${DATABASE_ID}/size" \
--header "Authorization: Bearer $HCODE_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--header "Content-Type: application/json" \
--data '{
"size": "256mb"
}' Response
The JSON shape is defined in the response schema.
Queued work returns HTTP 202 with an operation handle. Poll that handle to find out whether the work succeeded.
Response schema
{
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"size": {
"anyOf": [
{
"type": "string",
"enum": [
"256mb",
"512mb",
"1gb",
"2gb",
"4gb",
"8gb"
]
},
{
"type": "null"
}
]
},
"sizeName": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"memorySizeBytes": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
]
},
"storageBytes": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
]
},
"restarting": {
"type": "boolean"
},
"operationId": {
"type": "string"
},
"operations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"href": {
"type": "string"
}
},
"required": [
"id",
"status",
"href"
]
}
}
},
"required": [
"success"
],
"additionalProperties": true
}See errors and retries for failure responses.