Skip to content
API referencec3c8e63 · docs(api): databases

Databases

A database is a Postgres 17 database in a project, next to its cubes. Cubecen runs it with Neon, in Frankfurt (aws-eu-central-1). The Launch and Scale plans have databases; the Free plan has none.

Endpoints

A database's slug is how cubes refer to it, so no cube or other database of the project can have the same one. Creating a database answers 202 with its status at provisioning, and it is ready within a minute. Read it until then.

A cube connects through one of its variables. Put ${{ db.DATABASE_URL }} in a variable, not a secret, where db is the database's slug. The cube gets the connection as a secret when it is next built or deployed, and pull request previews never get it. A reference in a variable that a browser reads, such as one that starts with VITE_ or NEXT_PUBLIC_, is refused, because it would publish the password. See Environment. DATABASE_URL goes through a connection pooler: use it in your app. DATABASE_URL_UNPOOLED connects directly: use it for migrations, LISTEN and anything that keeps session state.

Shell
curl -sS -X PATCH "https://api.cubecen.com/v1/organizations/<org>/projects/<project>/applications/<cube>/env" \
  -H "Authorization: Bearer $CUBECEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"expected_version": "7f20b1d",
       "set": [{"key": "DATABASE_URL", "type": "variable", "value": "${{ db.DATABASE_URL }}"}]}'

To connect from outside Cubecen, such as with psql or a migration tool, read the connection. It holds the password, so it needs a Full key. No other answer holds the password. Resetting the password stops the old one at once. Every cube that refers to the database can't connect until it is deployed again, and its environment then lists the database's slug in databases_behind.

The plan limits how many databases an organization can have, and what each can use: how far its compute can scale, its storage, and its compute hours and data transfer each month. A database that uses up its compute hours, its data transfer or its storage is suspended: it keeps its data but takes no connections. Compute hours and data transfer start again on the 1st of the month at 00:00 UTC; a database that is full stays suspended until its storage limit is raised. usage is measured about every hour, so a database can go a little past a limit first.

While a cube refers to a database, the database can't be deleted and its slug can't change: referenced_by lists those cubes. Deleting a database deletes its data, and you can't undo it. Support can recover it within 7 days.

List the databases of a project

GET/v1/organizations/{org}/projects/{project}/databases
Read-only key

Returns the Postgres databases of a project, oldest first. It needs only read access.

A database is a project resource next to its cubes. The answer never holds a password: read it with getDatabaseConnection.

The list is paged. limit sets the page size, from 1 to 100, and is 20 by default. When there are more, the answer has next_cursor: send it as cursor to get the next page. The last page has no next_cursor.

Path parameters

NameTypeDescription
orgrequiredstring

The ID or slug of the organization. A key works in one organization. Another organization, by ID or by slug, is refused with 403, and so is a slug that matches no organization. An ID that matches no organization at all is 404.

projectrequiredstring

The ID or slug of the project. A slug is unique within the organization.

Query parameters

NameTypeDescription
limitinteger

How many databases to return, from 1 to 100. The default is 20.

cursorstring

The next_cursor of the previous page, to get the next one.

Responses

StatusDescription
200

A page of databases.

DatabasePage object2 fields
itemsarray of objectrequired

The databases on this page, oldest first.

items items14 fields
idstringrequired

The database's ID.

slugstringrequired

The database's slug: how cubes refer to it, as in ${{ db.DATABASE_URL }}. Unique among the cubes and databases of the project.

namestringrequired

The database's name.

statusstringrequired

provisioning while it is being made, ready, suspended (it keeps its data and takes no connections; see suspended_reason), failed (it could not be made: delete it and create it again) or deleting.

One of: provisioning, ready, suspended, failed, deleting, deleted

suspended_reasonstring | nullrequired

Why the database is suspended, while it is. quota: a monthly limit was reached; compute and transfer start again on the 1st of the month at 00:00 UTC, storage once its limit is raised. plan: the organization's plan no longer has databases. staff: Cubecen suspended it. null when it is not suspended.

grace_ends_atstring | nullrequired

Set when the organization's plan no longer has databases: the database is suspended at this time unless the plan has databases again. It stays set during the suspension. null otherwise.

delete_afterstring | nullrequired

When a database suspended for the plan is deleted, 90 days after the suspension began. null unless a deletion is scheduled.

regionstringrequired

Where the database runs: aws-eu-central-1, in Frankfurt.

postgres_versionintegerrequired

The major version of Postgres.

hoststring | nullrequired

The host that database_url connects to. It holds no secret. null before the database is ready.

referenced_byarray of objectrequired

The cubes whose variables refer to the database. While any does, it cannot be deleted and its slug cannot change.

referenced_by items3 fields
idstringrequired

The cube's ID.

slugstringrequired

The cube's slug.

namestringrequired

The cube's name.

limitsobjectrequired

What the database can use.

limits object4 fields
max_cunumberrequired

The most compute it can scale up to, in compute units: 1 unit is 1 vCPU and 4 GiB of memory.

storage_gbintegerrequired

The storage it can hold, in GB of 10^9 bytes.

compute_hoursintegerrequired

The compute it can use in a calendar month (UTC), in compute-unit hours.

transfer_gbintegerrequired

The data it can transfer in a calendar month, in GB.

usageobjectrequired

What the database used this month.

usage object6 fields
compute_hoursnumberrequired

The compute used this month, in compute-unit hours.

storage_gbnumberrequired

The storage it holds now, in GB.

transfer_gbnumberrequired

The data transferred this month, in GB.

period_startstringrequired

The start of the month, UTC.

period_endstringrequired

The start of the next month, UTC. It is not part of this one.

as_ofstring | nullrequired

When the usage was last measured. It is measured about every hour, so a database can go a little past a limit before it is suspended. null before the first measurement.

created_atstringrequired

When the database was created.

next_cursorstring

Send it as cursor to get the next page. Absent on the last page.

401

The API key is missing, unknown, expired or revoked.

403

The key may not do this. Its access level or its owner's role does not allow it, or the organization is not the key's.

404

Nothing was found at this address. An organization ID that matches no organization is 404, and so is a project, cube or other ID or slug in the path that matches nothing in the organization (or in the project or cube that the path names). An organization slug that matches nothing, and another organization by ID or by slug, is 403, not 404.

429

The key made too many requests. Wait for the number of seconds in Retry-After, then retry.

500

Something went wrong on our side. Retry the request with backoff. If it keeps failing, give support the error.requestId.

503

The service is temporarily unavailable. Retry the same request with backoff: wait a little longer after each failed attempt. The error code can differ from the one shown.

Example

Shell
curl -sS "https://api.cubecen.com/v1/organizations/<org>/projects/<project>/databases" \
  -H "Authorization: Bearer $CUBECEN_API_KEY"
Response
{
  "items": [
    {
      "id": "2c7e4b19-5a03-4d8f-9e61-b04f7a3d2c58",
      "slug": "db",
      "name": "Main DB",
      "status": "ready",
      "suspended_reason": null,
      "grace_ends_at": null,
      "delete_after": null,
      "region": "aws-eu-central-1",
      "postgres_version": 17,
      "host": "db-a1b2c3-pooler.eu-central-1.example.com",
      "referenced_by": [
        {
          "id": "f1a83d52-6e07-4b9c-8d34-7a0c9e215b68",
          "slug": "api",
          "name": "API"
        }
      ],
      "limits": {
        "max_cu": 1,
        "storage_gb": 10,
        "compute_hours": 100,
        "transfer_gb": 10
      },
      "usage": {
        "compute_hours": 12.4,
        "storage_gb": 0.3,
        "transfer_gb": 1.1,
        "period_start": "2026-10-01T00:00:00Z",
        "period_end": "2026-11-01T00:00:00Z",
        "as_of": "2026-10-25T09:00:00Z"
      },
      "created_at": "2026-10-20T10:02:11Z"
    }
  ]
}

Create a database

POST/v1/organizations/{org}/projects/{project}/databases

Adds a Postgres 17 database to the project. It needs a key with full access.

Send a name, 1 to 64 characters, and a slug: lowercase letters, digits and single hyphens. The slug is how cubes refer to the database, so it must differ from the slug of every cube and every other database of the project. A slug that is taken is refused with 409 CONFLICT.

The answer is 202 Accepted with the database in status provisioning. It becomes ready within a minute: read it with getDatabase until then.

The plan sets how many databases an organization can have and how much each can use. The Free plan has none. A database past the plan's count is refused with 402 PLAN_LIMIT_REACHED, with error.limit set to databases.

Path parameters

NameTypeDescription
orgrequiredstring

The ID or slug of the organization. A key works in one organization. Another organization, by ID or by slug, is refused with 403, and so is a slug that matches no organization. An ID that matches no organization at all is 404.

projectrequiredstring

The ID or slug of the project. A slug is unique within the organization.

Body

NameTypeDescription
namerequiredstring

The database's name, 1 to 64 characters.

slugrequiredstring

The database's slug: lowercase letters, digits and single hyphens. No cube or other database of the project can have it.

Responses

StatusDescription
202

The database is being created. Its status is provisioning.

Database object14 fields
idstringrequired

The database's ID.

slugstringrequired

The database's slug: how cubes refer to it, as in ${{ db.DATABASE_URL }}. Unique among the cubes and databases of the project.

namestringrequired

The database's name.

statusstringrequired

provisioning while it is being made, ready, suspended (it keeps its data and takes no connections; see suspended_reason), failed (it could not be made: delete it and create it again) or deleting.

One of: provisioning, ready, suspended, failed, deleting, deleted

suspended_reasonstring | nullrequired

Why the database is suspended, while it is. quota: a monthly limit was reached; compute and transfer start again on the 1st of the month at 00:00 UTC, storage once its limit is raised. plan: the organization's plan no longer has databases. staff: Cubecen suspended it. null when it is not suspended.

grace_ends_atstring | nullrequired

Set when the organization's plan no longer has databases: the database is suspended at this time unless the plan has databases again. It stays set during the suspension. null otherwise.

delete_afterstring | nullrequired

When a database suspended for the plan is deleted, 90 days after the suspension began. null unless a deletion is scheduled.

regionstringrequired

Where the database runs: aws-eu-central-1, in Frankfurt.

postgres_versionintegerrequired

The major version of Postgres.

hoststring | nullrequired

The host that database_url connects to. It holds no secret. null before the database is ready.

referenced_byarray of objectrequired

The cubes whose variables refer to the database. While any does, it cannot be deleted and its slug cannot change.

referenced_by items3 fields
idstringrequired

The cube's ID.

slugstringrequired

The cube's slug.

namestringrequired

The cube's name.

limitsobjectrequired

What the database can use.

limits object4 fields
max_cunumberrequired

The most compute it can scale up to, in compute units: 1 unit is 1 vCPU and 4 GiB of memory.

storage_gbintegerrequired

The storage it can hold, in GB of 10^9 bytes.

compute_hoursintegerrequired

The compute it can use in a calendar month (UTC), in compute-unit hours.

transfer_gbintegerrequired

The data it can transfer in a calendar month, in GB.

usageobjectrequired

What the database used this month.

usage object6 fields
compute_hoursnumberrequired

The compute used this month, in compute-unit hours.

storage_gbnumberrequired

The storage it holds now, in GB.

transfer_gbnumberrequired

The data transferred this month, in GB.

period_startstringrequired

The start of the month, UTC.

period_endstringrequired

The start of the next month, UTC. It is not part of this one.

as_ofstring | nullrequired

When the usage was last measured. It is measured about every hour, so a database can go a little past a limit before it is suspended. null before the first measurement.

created_atstringrequired

When the database was created.

400

The request is not valid. error.field names the field to blame, when there is one.

401

The API key is missing, unknown, expired or revoked.

402

The organization's plan does not allow this. error.limit, error.max, error.used and error.plan say which limit.

403

The key may not do this. Its access level or its owner's role does not allow it, or the organization is not the key's.

404

Nothing was found at this address. An organization ID that matches no organization is 404, and so is a project, cube or other ID or slug in the path that matches nothing in the organization (or in the project or cube that the path names). An organization slug that matches nothing, and another organization by ID or by slug, is 403, not 404.

409

The request conflicts with the current state of the resource. error.code says how.

413

The request body is larger than 1 MiB.

415

The request body must be JSON. Send Content-Type: application/json.

429

The key made too many requests. Wait for the number of seconds in Retry-After, then retry.

500

Something went wrong on our side. Retry the request with backoff. If it keeps failing, give support the error.requestId.

503

The service is temporarily unavailable. Retry the same request with backoff: wait a little longer after each failed attempt. The error code can differ from the one shown.

Example

Shell
curl -sS -X POST "https://api.cubecen.com/v1/organizations/<org>/projects/<project>/databases" \
  -H "Authorization: Bearer $CUBECEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"name": "Main DB", "slug": "db"}'
Response
{
  "id": "2c7e4b19-5a03-4d8f-9e61-b04f7a3d2c58",
  "slug": "db",
  "name": "Main DB",
  "status": "provisioning",
  "suspended_reason": null,
  "grace_ends_at": null,
  "delete_after": null,
  "region": "aws-eu-central-1",
  "postgres_version": 17,
  "host": null,
  "referenced_by": [],
  "limits": {
    "max_cu": 1,
    "storage_gb": 10,
    "compute_hours": 100,
    "transfer_gb": 10
  },
  "usage": {
    "compute_hours": 0,
    "storage_gb": 0,
    "transfer_gb": 0,
    "period_start": "2026-10-01T00:00:00Z",
    "period_end": "2026-11-01T00:00:00Z",
    "as_of": null
  },
  "created_at": "2026-10-25T11:05:42Z"
}

Get a database

GET/v1/organizations/{org}/projects/{project}/databases/{database-id}
Read-only key

Returns one database: its status, the cubes that refer to it, its limits and what it used this month. It needs only read access.

status is provisioning while the database is being made, then ready. suspended means it keeps its data but takes no connections: suspended_reason says why. failed means it could not be made: delete it and create it again. deleting means its deletion has started.

referenced_by lists the cubes whose variables refer to the database. While any does, it cannot be deleted and its slug cannot change.

Path parameters

NameTypeDescription
orgrequiredstring

The ID or slug of the organization. A key works in one organization. Another organization, by ID or by slug, is refused with 403, and so is a slug that matches no organization. An ID that matches no organization at all is 404.

projectrequiredstring

The ID or slug of the project. A slug is unique within the organization.

database-idrequiredstring

The ID or slug of the database. A slug is unique among the cubes and databases of the project.

Responses

StatusDescription
200

The database.

Database object14 fields
idstringrequired

The database's ID.

slugstringrequired

The database's slug: how cubes refer to it, as in ${{ db.DATABASE_URL }}. Unique among the cubes and databases of the project.

namestringrequired

The database's name.

statusstringrequired

provisioning while it is being made, ready, suspended (it keeps its data and takes no connections; see suspended_reason), failed (it could not be made: delete it and create it again) or deleting.

One of: provisioning, ready, suspended, failed, deleting, deleted

suspended_reasonstring | nullrequired

Why the database is suspended, while it is. quota: a monthly limit was reached; compute and transfer start again on the 1st of the month at 00:00 UTC, storage once its limit is raised. plan: the organization's plan no longer has databases. staff: Cubecen suspended it. null when it is not suspended.

grace_ends_atstring | nullrequired

Set when the organization's plan no longer has databases: the database is suspended at this time unless the plan has databases again. It stays set during the suspension. null otherwise.

delete_afterstring | nullrequired

When a database suspended for the plan is deleted, 90 days after the suspension began. null unless a deletion is scheduled.

regionstringrequired

Where the database runs: aws-eu-central-1, in Frankfurt.

postgres_versionintegerrequired

The major version of Postgres.

hoststring | nullrequired

The host that database_url connects to. It holds no secret. null before the database is ready.

referenced_byarray of objectrequired

The cubes whose variables refer to the database. While any does, it cannot be deleted and its slug cannot change.

referenced_by items3 fields
idstringrequired

The cube's ID.

slugstringrequired

The cube's slug.

namestringrequired

The cube's name.

limitsobjectrequired

What the database can use.

limits object4 fields
max_cunumberrequired

The most compute it can scale up to, in compute units: 1 unit is 1 vCPU and 4 GiB of memory.

storage_gbintegerrequired

The storage it can hold, in GB of 10^9 bytes.

compute_hoursintegerrequired

The compute it can use in a calendar month (UTC), in compute-unit hours.

transfer_gbintegerrequired

The data it can transfer in a calendar month, in GB.

usageobjectrequired

What the database used this month.

usage object6 fields
compute_hoursnumberrequired

The compute used this month, in compute-unit hours.

storage_gbnumberrequired

The storage it holds now, in GB.

transfer_gbnumberrequired

The data transferred this month, in GB.

period_startstringrequired

The start of the month, UTC.

period_endstringrequired

The start of the next month, UTC. It is not part of this one.

as_ofstring | nullrequired

When the usage was last measured. It is measured about every hour, so a database can go a little past a limit before it is suspended. null before the first measurement.

created_atstringrequired

When the database was created.

401

The API key is missing, unknown, expired or revoked.

403

The key may not do this. Its access level or its owner's role does not allow it, or the organization is not the key's.

404

Nothing was found at this address. An organization ID that matches no organization is 404, and so is a project, cube or other ID or slug in the path that matches nothing in the organization (or in the project or cube that the path names). An organization slug that matches nothing, and another organization by ID or by slug, is 403, not 404.

429

The key made too many requests. Wait for the number of seconds in Retry-After, then retry.

500

Something went wrong on our side. Retry the request with backoff. If it keeps failing, give support the error.requestId.

503

The service is temporarily unavailable. Retry the same request with backoff: wait a little longer after each failed attempt. The error code can differ from the one shown.

Example

Shell
curl -sS "https://api.cubecen.com/v1/organizations/<org>/projects/<project>/databases/<database-id>" \
  -H "Authorization: Bearer $CUBECEN_API_KEY"
Response
{
  "id": "2c7e4b19-5a03-4d8f-9e61-b04f7a3d2c58",
  "slug": "db",
  "name": "Main DB",
  "status": "ready",
  "suspended_reason": null,
  "grace_ends_at": null,
  "delete_after": null,
  "region": "aws-eu-central-1",
  "postgres_version": 17,
  "host": "db-a1b2c3-pooler.eu-central-1.example.com",
  "referenced_by": [
    {
      "id": "f1a83d52-6e07-4b9c-8d34-7a0c9e215b68",
      "slug": "api",
      "name": "API"
    }
  ],
  "limits": {
    "max_cu": 1,
    "storage_gb": 10,
    "compute_hours": 100,
    "transfer_gb": 10
  },
  "usage": {
    "compute_hours": 12.4,
    "storage_gb": 0.3,
    "transfer_gb": 1.1,
    "period_start": "2026-10-01T00:00:00Z",
    "period_end": "2026-11-01T00:00:00Z",
    "as_of": "2026-10-25T09:00:00Z"
  },
  "created_at": "2026-10-20T10:02:11Z"
}

Rename a database

PATCH/v1/organizations/{org}/projects/{project}/databases/{database-id}

Changes a database's name, its slug or both. It needs a key with full access.

Send only the fields to change, and at least one. The rules for each field are those of createDatabase. A slug that another cube or database of the project has is refused with 409 CONFLICT.

A slug change is refused with 409 DATABASE_REFERENCED while a cube's variables refer to the old slug: error.cubes names those cubes. Change their references first. The name can always change.

Path parameters

NameTypeDescription
orgrequiredstring

The ID or slug of the organization. A key works in one organization. Another organization, by ID or by slug, is refused with 403, and so is a slug that matches no organization. An ID that matches no organization at all is 404.

projectrequiredstring

The ID or slug of the project. A slug is unique within the organization.

database-idrequiredstring

The ID or slug of the database. A slug is unique among the cubes and databases of the project.

Body

NameTypeDescription
namestring

The new name, 1 to 64 characters.

slugstring

The new slug: lowercase letters, digits and single hyphens. Refused while cubes refer to the old one.

Responses

StatusDescription
200

The database, with the changes.

Database object14 fields
idstringrequired

The database's ID.

slugstringrequired

The database's slug: how cubes refer to it, as in ${{ db.DATABASE_URL }}. Unique among the cubes and databases of the project.

namestringrequired

The database's name.

statusstringrequired

provisioning while it is being made, ready, suspended (it keeps its data and takes no connections; see suspended_reason), failed (it could not be made: delete it and create it again) or deleting.

One of: provisioning, ready, suspended, failed, deleting, deleted

suspended_reasonstring | nullrequired

Why the database is suspended, while it is. quota: a monthly limit was reached; compute and transfer start again on the 1st of the month at 00:00 UTC, storage once its limit is raised. plan: the organization's plan no longer has databases. staff: Cubecen suspended it. null when it is not suspended.

grace_ends_atstring | nullrequired

Set when the organization's plan no longer has databases: the database is suspended at this time unless the plan has databases again. It stays set during the suspension. null otherwise.

delete_afterstring | nullrequired

When a database suspended for the plan is deleted, 90 days after the suspension began. null unless a deletion is scheduled.

regionstringrequired

Where the database runs: aws-eu-central-1, in Frankfurt.

postgres_versionintegerrequired

The major version of Postgres.

hoststring | nullrequired

The host that database_url connects to. It holds no secret. null before the database is ready.

referenced_byarray of objectrequired

The cubes whose variables refer to the database. While any does, it cannot be deleted and its slug cannot change.

referenced_by items3 fields
idstringrequired

The cube's ID.

slugstringrequired

The cube's slug.

namestringrequired

The cube's name.

limitsobjectrequired

What the database can use.

limits object4 fields
max_cunumberrequired

The most compute it can scale up to, in compute units: 1 unit is 1 vCPU and 4 GiB of memory.

storage_gbintegerrequired

The storage it can hold, in GB of 10^9 bytes.

compute_hoursintegerrequired

The compute it can use in a calendar month (UTC), in compute-unit hours.

transfer_gbintegerrequired

The data it can transfer in a calendar month, in GB.

usageobjectrequired

What the database used this month.

usage object6 fields
compute_hoursnumberrequired

The compute used this month, in compute-unit hours.

storage_gbnumberrequired

The storage it holds now, in GB.

transfer_gbnumberrequired

The data transferred this month, in GB.

period_startstringrequired

The start of the month, UTC.

period_endstringrequired

The start of the next month, UTC. It is not part of this one.

as_ofstring | nullrequired

When the usage was last measured. It is measured about every hour, so a database can go a little past a limit before it is suspended. null before the first measurement.

created_atstringrequired

When the database was created.

400

The request is not valid. error.field names the field to blame, when there is one.

401

The API key is missing, unknown, expired or revoked.

403

The key may not do this. Its access level or its owner's role does not allow it, or the organization is not the key's.

404

Nothing was found at this address. An organization ID that matches no organization is 404, and so is a project, cube or other ID or slug in the path that matches nothing in the organization (or in the project or cube that the path names). An organization slug that matches nothing, and another organization by ID or by slug, is 403, not 404.

409

The request conflicts with the current state of the resource. error.code says how.

413

The request body is larger than 1 MiB.

415

The request body must be JSON. Send Content-Type: application/json.

429

The key made too many requests. Wait for the number of seconds in Retry-After, then retry.

500

Something went wrong on our side. Retry the request with backoff. If it keeps failing, give support the error.requestId.

503

The service is temporarily unavailable. Retry the same request with backoff: wait a little longer after each failed attempt. The error code can differ from the one shown.

Example

Shell
curl -sS -X PATCH "https://api.cubecen.com/v1/organizations/<org>/projects/<project>/databases/<database-id>" \
  -H "Authorization: Bearer $CUBECEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"name": "Primary DB"}'
Response
{
  "id": "2c7e4b19-5a03-4d8f-9e61-b04f7a3d2c58",
  "slug": "db",
  "name": "Primary DB",
  "status": "ready",
  "suspended_reason": null,
  "grace_ends_at": null,
  "delete_after": null,
  "region": "aws-eu-central-1",
  "postgres_version": 17,
  "host": "db-a1b2c3-pooler.eu-central-1.example.com",
  "referenced_by": [],
  "limits": {
    "max_cu": 1,
    "storage_gb": 10,
    "compute_hours": 100,
    "transfer_gb": 10
  },
  "usage": {
    "compute_hours": 12.4,
    "storage_gb": 0.3,
    "transfer_gb": 1.1,
    "period_start": "2026-10-01T00:00:00Z",
    "period_end": "2026-11-01T00:00:00Z",
    "as_of": "2026-10-25T09:00:00Z"
  },
  "created_at": "2026-10-20T10:02:11Z"
}

Delete a database

DELETE/v1/organizations/{org}/projects/{project}/databases/{database-id}

Deletes a database and its data. It needs a key with full access. You cannot undo it. Support can recover a deleted database within 7 days.

The answer is 202 Accepted with the database in status deleting. The deletion ends within seconds, and the database is then gone from the list and from getDatabase.

A database is refused with 409 DATABASE_REFERENCED while a cube's variables refer to it: error.cubes names those cubes. Remove the references first.

Path parameters

NameTypeDescription
orgrequiredstring

The ID or slug of the organization. A key works in one organization. Another organization, by ID or by slug, is refused with 403, and so is a slug that matches no organization. An ID that matches no organization at all is 404.

projectrequiredstring

The ID or slug of the project. A slug is unique within the organization.

database-idrequiredstring

The ID or slug of the database. A slug is unique among the cubes and databases of the project.

Responses

StatusDescription
202

The deletion has started. The status is deleting.

Database object14 fields
idstringrequired

The database's ID.

slugstringrequired

The database's slug: how cubes refer to it, as in ${{ db.DATABASE_URL }}. Unique among the cubes and databases of the project.

namestringrequired

The database's name.

statusstringrequired

provisioning while it is being made, ready, suspended (it keeps its data and takes no connections; see suspended_reason), failed (it could not be made: delete it and create it again) or deleting.

One of: provisioning, ready, suspended, failed, deleting, deleted

suspended_reasonstring | nullrequired

Why the database is suspended, while it is. quota: a monthly limit was reached; compute and transfer start again on the 1st of the month at 00:00 UTC, storage once its limit is raised. plan: the organization's plan no longer has databases. staff: Cubecen suspended it. null when it is not suspended.

grace_ends_atstring | nullrequired

Set when the organization's plan no longer has databases: the database is suspended at this time unless the plan has databases again. It stays set during the suspension. null otherwise.

delete_afterstring | nullrequired

When a database suspended for the plan is deleted, 90 days after the suspension began. null unless a deletion is scheduled.

regionstringrequired

Where the database runs: aws-eu-central-1, in Frankfurt.

postgres_versionintegerrequired

The major version of Postgres.

hoststring | nullrequired

The host that database_url connects to. It holds no secret. null before the database is ready.

referenced_byarray of objectrequired

The cubes whose variables refer to the database. While any does, it cannot be deleted and its slug cannot change.

referenced_by items3 fields
idstringrequired

The cube's ID.

slugstringrequired

The cube's slug.

namestringrequired

The cube's name.

limitsobjectrequired

What the database can use.

limits object4 fields
max_cunumberrequired

The most compute it can scale up to, in compute units: 1 unit is 1 vCPU and 4 GiB of memory.

storage_gbintegerrequired

The storage it can hold, in GB of 10^9 bytes.

compute_hoursintegerrequired

The compute it can use in a calendar month (UTC), in compute-unit hours.

transfer_gbintegerrequired

The data it can transfer in a calendar month, in GB.

usageobjectrequired

What the database used this month.

usage object6 fields
compute_hoursnumberrequired

The compute used this month, in compute-unit hours.

storage_gbnumberrequired

The storage it holds now, in GB.

transfer_gbnumberrequired

The data transferred this month, in GB.

period_startstringrequired

The start of the month, UTC.

period_endstringrequired

The start of the next month, UTC. It is not part of this one.

as_ofstring | nullrequired

When the usage was last measured. It is measured about every hour, so a database can go a little past a limit before it is suspended. null before the first measurement.

created_atstringrequired

When the database was created.

401

The API key is missing, unknown, expired or revoked.

403

The key may not do this. Its access level or its owner's role does not allow it, or the organization is not the key's.

404

Nothing was found at this address. An organization ID that matches no organization is 404, and so is a project, cube or other ID or slug in the path that matches nothing in the organization (or in the project or cube that the path names). An organization slug that matches nothing, and another organization by ID or by slug, is 403, not 404.

409

The request conflicts with the current state of the resource. error.code says how.

429

The key made too many requests. Wait for the number of seconds in Retry-After, then retry.

500

Something went wrong on our side. Retry the request with backoff. If it keeps failing, give support the error.requestId.

503

The service is temporarily unavailable. Retry the same request with backoff: wait a little longer after each failed attempt. The error code can differ from the one shown.

Example

Shell
curl -sS -X DELETE "https://api.cubecen.com/v1/organizations/<org>/projects/<project>/databases/<database-id>" \
  -H "Authorization: Bearer $CUBECEN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
Response
{
  "id": "2c7e4b19-5a03-4d8f-9e61-b04f7a3d2c58",
  "slug": "db",
  "name": "Main DB",
  "status": "deleting",
  "suspended_reason": null,
  "grace_ends_at": null,
  "delete_after": null,
  "region": "aws-eu-central-1",
  "postgres_version": 17,
  "host": "db-a1b2c3-pooler.eu-central-1.example.com",
  "referenced_by": [],
  "limits": {
    "max_cu": 1,
    "storage_gb": 10,
    "compute_hours": 100,
    "transfer_gb": 10
  },
  "usage": {
    "compute_hours": 12.4,
    "storage_gb": 0.3,
    "transfer_gb": 1.1,
    "period_start": "2026-10-01T00:00:00Z",
    "period_end": "2026-11-01T00:00:00Z",
    "as_of": "2026-10-25T09:00:00Z"
  },
  "created_at": "2026-10-20T10:02:11Z"
}

Get the connection of a database

GET/v1/organizations/{org}/projects/{project}/databases/{database-id}/connection
Full key

Returns how to connect to a database from outside Cubecen, for example with psql or a migration tool: the hosts, the user, the password and two connection URLs. It needs a key with full access, because it holds the password.

database_url goes through a connection pooler: use it in applications. database_url_unpooled connects directly: use it for migrations, LISTEN and anything that keeps session state. Both require TLS (sslmode=require). The answer is never cached.

A cube does not need this: put ${{ db.DATABASE_URL }} or ${{ db.DATABASE_URL_UNPOOLED }} in one of its variables, where db is the database's slug (see updateEnvironment).

A database that is not ready yet is refused with 409 DATABASE_NOT_READY.

Path parameters

NameTypeDescription
orgrequiredstring

The ID or slug of the organization. A key works in one organization. Another organization, by ID or by slug, is refused with 403, and so is a slug that matches no organization. An ID that matches no organization at all is 404.

projectrequiredstring

The ID or slug of the project. A slug is unique within the organization.

database-idrequiredstring

The ID or slug of the database. A slug is unique among the cubes and databases of the project.

Responses

StatusDescription
200

The connection of the database. It holds the password.

DatabaseConnection object8 fields
hoststringrequired

The host for direct connections.

pooled_hoststringrequired

The host of the connection pooler.

portintegerrequired

The port, 5432.

databasestringrequired

The name of the database to connect to.

userstringrequired

The user to connect as.

passwordstringrequired

The password.

database_urlstringrequired

A URL through the connection pooler, with sslmode=require: use it in applications.

database_url_unpooledstringrequired

A URL for a direct connection, with sslmode=require: use it for migrations, LISTEN and session state.

401

The API key is missing, unknown, expired or revoked.

403

The key may not do this. Its access level or its owner's role does not allow it, or the organization is not the key's.

404

Nothing was found at this address. An organization ID that matches no organization is 404, and so is a project, cube or other ID or slug in the path that matches nothing in the organization (or in the project or cube that the path names). An organization slug that matches nothing, and another organization by ID or by slug, is 403, not 404.

409

The request conflicts with the current state of the resource. error.code says how.

429

The key made too many requests. Wait for the number of seconds in Retry-After, then retry.

500

Something went wrong on our side. Retry the request with backoff. If it keeps failing, give support the error.requestId.

503

The service is temporarily unavailable. Retry the same request with backoff: wait a little longer after each failed attempt. The error code can differ from the one shown.

Example

Shell
curl -sS "https://api.cubecen.com/v1/organizations/<org>/projects/<project>/databases/<database-id>/connection" \
  -H "Authorization: Bearer $CUBECEN_API_KEY"
Response
{
  "host": "db-a1b2c3.eu-central-1.example.com",
  "pooled_host": "db-a1b2c3-pooler.eu-central-1.example.com",
  "port": 5432,
  "database": "app",
  "user": "app",
  "password": "example-password",
  "database_url": "postgresql://app:example-password@db-a1b2c3-pooler.eu-central-1.example.com/app?sslmode=require",
  "database_url_unpooled": "postgresql://app:example-password@db-a1b2c3.eu-central-1.example.com/app?sslmode=require"
}

Reset the password of a database

POST/v1/organizations/{org}/projects/{project}/databases/{database-id}/reset-password

Gives the database a new password and returns the new connection, as getDatabaseConnection does. It needs a key with full access.

The old password stops working at once. Every cube that refers to the database cannot connect until it is deployed again: its getEnvironment then has live_env_behind set to true and the database's slug in databases_behind. Redeploy those cubes with createDeployment.

A database that is not ready yet is refused with 409 DATABASE_NOT_READY. A reset that is already running is refused with 409 BUSY: retry after the seconds in Retry-After.

Path parameters

NameTypeDescription
orgrequiredstring

The ID or slug of the organization. A key works in one organization. Another organization, by ID or by slug, is refused with 403, and so is a slug that matches no organization. An ID that matches no organization at all is 404.

projectrequiredstring

The ID or slug of the project. A slug is unique within the organization.

database-idrequiredstring

The ID or slug of the database. A slug is unique among the cubes and databases of the project.

Responses

StatusDescription
200

The new connection of the database. It holds the new password.

DatabaseConnection object8 fields
hoststringrequired

The host for direct connections.

pooled_hoststringrequired

The host of the connection pooler.

portintegerrequired

The port, 5432.

databasestringrequired

The name of the database to connect to.

userstringrequired

The user to connect as.

passwordstringrequired

The password.

database_urlstringrequired

A URL through the connection pooler, with sslmode=require: use it in applications.

database_url_unpooledstringrequired

A URL for a direct connection, with sslmode=require: use it for migrations, LISTEN and session state.

401

The API key is missing, unknown, expired or revoked.

403

The key may not do this. Its access level or its owner's role does not allow it, or the organization is not the key's.

404

Nothing was found at this address. An organization ID that matches no organization is 404, and so is a project, cube or other ID or slug in the path that matches nothing in the organization (or in the project or cube that the path names). An organization slug that matches nothing, and another organization by ID or by slug, is 403, not 404.

409

The request conflicts with the current state of the resource. error.code says how.

429

The key made too many requests. Wait for the number of seconds in Retry-After, then retry.

500

Something went wrong on our side. Retry the request with backoff. If it keeps failing, give support the error.requestId.

503

The service is temporarily unavailable. Retry the same request with backoff: wait a little longer after each failed attempt. The error code can differ from the one shown.

Example

Shell
curl -sS -X POST "https://api.cubecen.com/v1/organizations/<org>/projects/<project>/databases/<database-id>/reset-password" \
  -H "Authorization: Bearer $CUBECEN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
Response
{
  "host": "db-a1b2c3.eu-central-1.example.com",
  "pooled_host": "db-a1b2c3-pooler.eu-central-1.example.com",
  "port": 5432,
  "database": "app",
  "user": "app",
  "password": "example-new-password",
  "database_url": "postgresql://app:example-new-password@db-a1b2c3-pooler.eu-central-1.example.com/app?sslmode=require",
  "database_url_unpooled": "postgresql://app:example-new-password@db-a1b2c3.eu-central-1.example.com/app?sslmode=require"
}