palbaseDocs

Palbase Machines · API

POST/databases

Open a database

Opens a database: its volume is made and it starts; it answers once its state is awake. The answer holds its owner's and its application's passwords, shown this once: no answer holds them again (a new one is made with POST /databases/{name}/password). A project has one database of a free size at a time. A size that is paid for is not open yet — none is charged for — but to the platform's own project and those named for it: another project is refused (403 size_not_available). Emits database.created.

Called by your server, with the project's secret key.

Request body

namestring · optionalThe database's name; `main` when left out.
sizestring · optionalThe database's size; `free` when left out. free: 0.25 vCPU, 512 MiB, 1 GB, put to sleep when idle (woken by the next connection in about 10 s), awake 400 hours a month at most, archived after a week asleep (its next connection brings it back from its backup); hobby: 0.25 vCPU, 512 MiB, 5 GB, put to sleep when idle, no monthly limit; starter: 1 GiB, up to 0.5 vCPU, 10 GB; standard-1x: 2 GiB, up to 1 vCPU, 25 GB; standard-2x: 4 GiB, up to 2 vCPU, 50 GB; standard-4x: 16 GiB, up to 4 vCPU; standard-8x: 32 GiB, up to 8 vCPU; standard-16x: 64 GiB, up to 16 vCPU; standard-32x: 128 GiB, up to 32 vCPU, 100 GB each (a quarter of their CPU reserved for them); dedicated-1x: 1 vCPU of its own, 4 GiB, 25 GB; dedicated-2x: 2 vCPU of its own, 8 GiB, 50 GB. The standard and dedicated sizes never sleep and live on a Premium SSD v2 disk of their own; free and hobby on the platform's SAN. The GB of a size that never sleeps are its storage unless `storage_gb` says otherwise (1 or a multiple of 5, up to 4,000), billed by the GB past its first; its size's hours are its CPU and memory. A database past its storage turns read-only — or, `storage_autoscaling` on, grows by half when 90% full. What a project's machines and databases reserve between them is held to its limit: a size that does not fit is refused (409 `machines_over_limit`).
allowstring[] · optionalWho may connect, as addresses or CIDRs (203.0.113.7, 203.0.113.0/24), 50 at most; anyone with the password when empty.
backup_daysinteger · optionalHow many days the database's backups are kept: it can be brought back to any moment of them. 1 to 35.
environmentstring · optionalThe ref of the environment called, when given: a new database is bound to the environment whose address it is made at (409 bound_to_environment for another — make it at that environment's address). Its name is the project's one: name_taken when another environment holds a database of that name.
storage_gbinteger (int64) · optionalWhat it holds, in GB: 1 or a multiple of 5, up to 4,000 — of a size on a disk of its own (400 `storage_not_adjustable` for free and hobby; 400 `invalid_storage` for another number). Its size's (`DatabaseSize.storage_bytes`) when left out. Billed by the GB-month past its first (`DatabaseSize.storage_price_micros_per_gb_month`).
storage_autoscalingboolean · optionalWhether it grows by itself: 90% full, by half, to the next multiple of 5 GB, six hours at least after it last grew; off when left out. Of a size on a disk of its own.
curl
curl -X POST "https://<your-ref>.palbase.studio/databases" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"name":"main","size":"free","allow":["string"],"backup_days":7,"environment":"string","storage_gb":1,"storage_autoscaling":false}'

Responses

201The database, starting, and its credentials

400Validation failed or a required field is missing

401Missing or invalid API key

403Not the project's secret key; or the request requires elevated owner authentication (`owner_only`); or the size is not open to the project (`size_not_available`, its reason as GET /machines/sizes and /databases/sizes say it).

409The project already has a database of this name (or one being purged), the environment as many databases as it may, or no room left for this one; a password change is still on its way to the database; or a machine is given the database; or the database is moving to another size, cannot start (a change of its size waits for a restore that brings it back), holds more than the one asked, or would have too few connections for the copies of the machines given it; or, to the console, the database is being brought back to a moment, cannot start, or has run its awake hours for the month

429Over the project's request limit, or its machine time for this period is used up

503Temporarily unavailable; retrying is safe after Retry-After

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation CreateDatabase of machines's contract.