Skip to content

Databases API

PostgreSQL and MariaDB instances

Endpoints

MethodPathDescription
POST/v1/databasesCreate database
DELETE/v1/databasesDelete database
DELETE/v1/databases/{db_type}/{db_name}Delete database
PATCH/v1/databases/{db_type}/{db_name}Update database
GET/v1/databases/{db_type}List databases by type
GET/v1/databases/enginesList database engines
POST/v1/databases/{db_type}/{db_name}/restartRestart database
GET/v1/databases/{db_type}/{db_name}/credentialsGet database credentials
POST/v1/databases/{db_type}/{db_name}/credentials/rotateRotate database credentials
GET/v1/databases/{db_type}/{db_name}/infoGet database info
POST/v1/databases/{db_type}/{db_name}/firewallAdd firewall rule
GET/v1/databases/{db_type}/{db_name}/firewallList firewall rules
DELETE/v1/databases/{db_type}/{db_name}/firewall/{rule_id}Delete firewall rule
GET/v1/databases/{db_type}/{db_name}/metricsGet database metrics
GET/v1/quotaGet database quota
GET/v1/databases/historyList database history
POST/v1/databases/{db_type}/{db_name}/snapshotsCreate snapshot
GET/v1/databases/{db_type}/{db_name}/snapshotsList snapshots
POST/v1/databases/{db_type}/{db_name}/restoreRestore from snapshot
DELETE/v1/databases/{db_type}/{db_name}/snapshots/{snapshot_id}Delete snapshot
GET/v1/databases/{db_type}/{db_name}/backup-policyGet backup policy
PUT/v1/databases/{db_type}/{db_name}/backup-policySet backup policy

POST /v1/databases

Create database

Create a new database (PostgreSQL or MariaDB)

This endpoint:

  1. Authenticates the customer via API key
  2. Checks database quota and permissions
  3. Creates a database and user on the local server
  4. Reports usage to the central server for billing
  5. Returns connection details

Requires: 'database:create' permission

Special behavior for internal API keys:

  • Internal keys can specify customer_id in request body to create databases on behalf of customers
  • Regular customer keys can only create databases for themselves (customer_id override is ignored)

Request Body:

FieldTypeDescription
db_typestringRequired. Database type (postgresql or mariadb) Values: postgresql, mariadb
requested_nameobjectOptional custom database name suffix (alphanumeric and underscore only, max 30 chars). Creates deterministic name: cust_{customer_id}_
customer_idobjectTarget customer ID (internal API keys only)

Example:

json
{
  "db_type": "postgresql",
  "requested_name": "webapp_prod_db",
  "customer_id": null
}

Response:

FieldTypeDescription
successbooleanRequired.
db_typestringRequired.
db_namestringRequired.
usernamestringRequired.
passwordstringRequired.
hoststringRequired.
portintegerRequired.
connection_stringstringRequired.
messagestringRequired.
password_generatedbooleanTrue if password was auto-generated
idempotentbooleanTrue if database already existed (no new creation)

Example:

bash
curl -X POST https://api.wayscloud.services/v1/databases \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{...}'

DELETE /v1/databases

Delete database

Delete a database (PostgreSQL or MariaDB)

This endpoint:

  1. Authenticates the customer via API key
  2. Checks permissions
  3. Verifies database ownership
  4. Deletes the database and optionally the user
  5. Reports deletion to the central server

Requires: 'database:delete' permission and database ownership

Request Body:

FieldTypeDescription
db_typestringRequired. Values: postgresql, mariadb
db_namestringRequired.
usernameobject

Example:

json
{
  "db_type": "postgresql",
  "db_name": "cust_6dd1d906_pg_webapp_prod_db",
  "username": "cust_6dd1d906_pg_webapp_prod_db"
}

Response:

FieldTypeDescription
successbooleanRequired.
messagestringRequired.

Example:

bash
curl -X DELETE https://api.wayscloud.services/v1/databases \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{...}'

DELETE /v1/databases/{db_type}/

Delete database

Delete a database (RESTful endpoint with path parameters)

This is an alternative RESTful endpoint that accepts database info via URL path instead of request body. It calls the same underlying delete logic.

Args: db_type: Either 'postgresql' or 'mariadb' db_name: Database name (with customer prefix) username: Optional username to delete (query parameter)

Requires: 'database:delete' permission and database ownership

Response:

FieldTypeDescription
successbooleanRequired.
messagestringRequired.

Example:

bash
curl -X DELETE https://api.wayscloud.services/v1/databases/{db_type}/{db_name} \
  -H "X-API-Key: YOUR_API_KEY"

PATCH /v1/databases/{db_type}/

Update database

Update database settings (scaling)

Currently supports:

  • connection_limit: Adjust the maximum number of simultaneous connections
  • description: Add or update a description/notes for this database

Other scaling options (RAM, storage) require support intervention as they involve infrastructure changes.

Request Body:

FieldTypeDescription
connection_limitobjectMaximum connections allowed (10-1000)
descriptionobjectOptional description/notes for this database

Example:

json
{
  "connection_limit": 200,
  "description": "Increased connection limit for production traffic"
}

Response:

FieldTypeDescription
successboolean
messagestring

Example:

bash
curl -X PATCH https://api.wayscloud.services/v1/databases/{db_type}/{db_name} \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{...}'

GET /v1/databases/

List databases by type

List all databases of a specific type

Args: db_type: Either 'postgresql' or 'mariadb' customer_id: Optional query parameter for internal keys to filter by specific customer

Requires: 'database:read' permission

Special behavior for internal API keys:

  • Internal keys can specify customer_id query parameter to list databases for specific customer
  • Regular customer keys can only list their own databases (customer_id parameter is ignored)

Response:

FieldTypeDescription
db_typestringRequired.
databasesarrayRequired.

Example:

bash
curl https://api.wayscloud.services/v1/databases/{db_type} \
  -H "X-API-Key: YOUR_API_KEY"

GET /v1/databases/engines

List database engines

List all supported database engines

Returns available database types with their versions and capabilities. Requires service API key.

Response:

FieldTypeDescription
enginesarray

Example:

bash
curl https://api.wayscloud.services/v1/databases/engines \
  -H "X-API-Key: YOUR_API_KEY"

POST /v1/databases/{db_type}/{db_name}/restart

Restart database

Terminate all active connections to a database

This is useful when you need to force-disconnect all clients, for example before maintenance or schema changes.

Warning: This will immediately disconnect all active clients. Applications should be prepared to reconnect automatically.

Note: This doesn't restart the database server itself, only terminates connections to this specific database.

Response:

FieldTypeDescription
successboolean
messagestring

Example:

bash
curl -X POST https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/restart \
  -H "X-API-Key: YOUR_API_KEY"

GET /v1/databases/{db_type}/{db_name}/credentials

Get database credentials

Get database credentials metadata (without password)

Returns connection info for the database without exposing the password. To get a new password, use POST /credentials/rotate.

Security Note: This endpoint intentionally does NOT return the password. Passwords are only shown when first created or when rotated.

Args: db_type: Either 'postgresql' or 'mariadb' db_name: Database name (with customer prefix)

Requires: 'database:read' permission and database ownership

Response:

FieldTypeDescription
hoststringDatabase server hostname
portintegerDatabase port
databasestringDatabase name
usernamestringDatabase username
passwordstringDatabase password (only shown once at creation)
connection_stringstringComplete connection string

Example:

bash
curl https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/credentials \
  -H "X-API-Key: YOUR_API_KEY"

POST /v1/databases/{db_type}/{db_name}/credentials/rotate

Rotate database credentials

Rotate database password and return new credentials

Generates a new secure password for the database user and updates it in both the database server and Vault.

Warning: This will invalidate the old password immediately. All existing connections using the old password will fail.

Args: db_type: Either 'postgresql' or 'mariadb' db_name: Database name (with customer prefix)

Returns: New credentials including the new password and connection string

Response:

FieldTypeDescription
successbooleanRequired.
db_namestringRequired.
usernamestringRequired.
passwordstringRequired.
hoststringRequired.
portintegerRequired.
connection_stringstringRequired.
created_atobject

Example:

bash
curl -X POST https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/credentials/rotate \
  -H "X-API-Key: YOUR_API_KEY"

GET /v1/databases/{db_type}/{db_name}/info

Get database info

Get detailed information about a database

Returns:

  • Database size (MB)
  • Current connection count
  • Connection limit
  • Owner
  • Creation timestamp (if available from Vault)

Args: db_type: Either 'postgresql' or 'mariadb' db_name: Database name (with customer prefix)

Requires: 'database:read' permission and database ownership

Response:

FieldTypeDescription
db_namestringRequired.
db_typestringRequired.
size_mbobject
connection_countobject
connection_limitobject
created_atobject
ownerobject

Example:

bash
curl https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/info \
  -H "X-API-Key: YOUR_API_KEY"

POST /v1/databases/{db_type}/{db_name}/firewall

Add firewall rule

Add an IP address to the firewall whitelist for a specific database

Creates a UFW firewall rule to allow the specified IP address to connect to this database. Rules are applied immediately at the network level.

Path Parameters:

  • db_type: Database type (postgresql or mariadb)
  • db_name: Technical database name (e.g., cust_abc123_pg_20251109_xyz)

Request Body:

  • ip_address: IPv4 address or CIDR block (e.g., "192.168.1.1" or "10.0.0.0/24")
  • description: Optional description for the rule

Note: The database must belong to the authenticated customer.

Request Body:

FieldTypeDescription
ip_addressstringRequired. IP address or CIDR block to whitelist
descriptionobjectOptional rule description (e.g., 'Office network')

Example:

json
{
  "ip_address": "192.0.2.100/32",
  "description": "Office VPN connection"
}

Response:

FieldTypeDescription
rule_idstringRequired. Unique rule identifier (UUID)
db_namestringRequired. Database name
db_typestringRequired. Database type
ip_addressstringRequired. IP address or CIDR block
portintegerRequired. Database port
descriptionobjectOptional rule description
created_atstringRequired.

Example:

bash
curl -X POST https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/firewall \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{...}'

GET /v1/databases/{db_type}/{db_name}/firewall

List firewall rules

List all firewall rules for a specific database

Returns all IP addresses that are whitelisted for this database.

Path Parameters:

  • db_type: Database type (postgresql or mariadb)
  • db_name: Technical database name

Note: The database must belong to the authenticated customer.

Response:

FieldTypeDescription
rulesarrayRequired.
totalintegerRequired. Total number of rules

Example:

bash
curl https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/firewall \
  -H "X-API-Key: YOUR_API_KEY"

DELETE /v1/databases/{db_type}/{db_name}/firewall/

Delete firewall rule

Remove a specific firewall rule from a database

Removes the UFW firewall rule and deletes it from the database. The rule is verified to be removed before updating the database.

Path Parameters:

  • db_type: Database type (postgresql or mariadb)
  • db_name: Technical database name
  • rule_id: UUID of the firewall rule to delete

Note: The database must belong to the authenticated customer.

Response:

FieldTypeDescription
successboolean
messagestring

Example:

bash
curl -X DELETE https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/firewall/{rule_id} \
  -H "X-API-Key: YOUR_API_KEY"

GET /v1/databases/{db_type}/{db_name}/metrics

Get database metrics

Get performance metrics for a specific database

Returns storage usage, connection counts, and query statistics. Data is pulled from the central metrics database.

Note: Metrics are collected every 5 minutes by the background collector.

Response:

FieldTypeDescription
database_idstring
storage_gbnumberStorage used in GB
backup_gbnumberBackup storage in GB
active_connectionsintegerCurrent active connections
max_connectionsintegerMaximum connections allowed
total_queriesintegerTotal queries executed
queries_per_secnumberQueries per second
cache_hit_rationumberCache hit ratio percentage
cpu_percentnumberCPU usage percentage
memory_percentnumberMemory usage percentage
measured_atstring

Example:

bash
curl https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/metrics \
  -H "X-API-Key: YOUR_API_KEY"

GET /v1/quota

Get database quota

Get database quota and usage summary for customer

Shows RAM allocation, storage usage, and estimated monthly cost.

Response:

FieldTypeDescription
usedintegerNumber of databases created
limitintegerMaximum databases allowed
storage_used_gbnumber
storage_limit_gbnumber

Example:

bash
curl https://api.wayscloud.services/v1/quota \
  -H "X-API-Key: YOUR_API_KEY"

GET /v1/databases/history

List database history

List database history (for billing and audit)

Shows all databases ever created by the customer, including deleted ones. Useful for billing reconciliation and audit purposes.

Response:

Example:

bash
curl https://api.wayscloud.services/v1/databases/history \
  -H "X-API-Key: YOUR_API_KEY"

POST /v1/databases/{db_type}/{db_name}/snapshots

Create snapshot

Create a snapshot (backup) of a database

This creates an immediate backup of the database. Snapshots are stored on disk and can be restored later.

Args: db_type: Either 'postgresql' or 'mariadb' db_name: Database name (with customer prefix) request: Snapshot creation request (optional description)

Requires: 'database:read' permission and database ownership

Request Body:

FieldTypeDescription
descriptionobjectOptional description of snapshot

Example:

json
{
  "description": "Before major schema migration"
}

Response:

FieldTypeDescription
successbooleanRequired.
snapshot_idstringRequired.
db_namestringRequired.
db_typestringRequired.
size_mbobject
created_atstringRequired.
descriptionobject
messagestringRequired.

Example:

bash
curl -X POST https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/snapshots \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{...}'

GET /v1/databases/{db_type}/{db_name}/snapshots

List snapshots

List all snapshots for a database

Returns all snapshots (backups) created for this database, sorted by creation time (newest first).

Args: db_type: Either 'postgresql' or 'mariadb' db_name: Database name (with customer prefix)

Requires: 'database:read' permission and database ownership

Response:

FieldTypeDescription
db_namestringRequired.
db_typestringRequired.
snapshotsarrayRequired.

Example:

bash
curl https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/snapshots \
  -H "X-API-Key: YOUR_API_KEY"

POST /v1/databases/{db_type}/{db_name}/restore

Restore from snapshot

Restore a database from a snapshot

This replaces the current database contents with the snapshot. WARNING: This operation cannot be undone! Consider creating a snapshot first.

Args: db_type: Either 'postgresql' or 'mariadb' db_name: Database name (with customer prefix) request: Restore request (snapshot_id, optional target_db_name)

Requires: 'database:update' permission and database ownership

Request Body:

FieldTypeDescription
snapshot_idstringRequired. Snapshot ID to restore from
target_db_nameobjectOptional: Restore to new database name

Example:

json
{
  "snapshot_id": "snap_20251126_143000_a1b2c3d4",
  "target_db_name": "webapp_restored_db"
}

Response:

FieldTypeDescription
successbooleanRequired.
db_namestringRequired.
snapshot_idstringRequired.
messagestringRequired.

Example:

bash
curl -X POST https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/restore \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{...}'

DELETE /v1/databases/{db_type}/{db_name}/snapshots/

Delete snapshot

Delete a snapshot

Permanently deletes a snapshot file from disk. This operation cannot be undone.

Args: db_type: Either 'postgresql' or 'mariadb' db_name: Database name (with customer prefix) snapshot_id: Snapshot ID to delete

Requires: 'database:delete' permission and database ownership

Response:

FieldTypeDescription
successboolean
messagestring

Example:

bash
curl -X DELETE https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/snapshots/{snapshot_id} \
  -H "X-API-Key: YOUR_API_KEY"

GET /v1/databases/{db_type}/{db_name}/backup-policy

Get backup policy

Get backup policy for a database

Returns the automated backup configuration for this database.

Args: db_type: Either 'postgresql' or 'mariadb' db_name: Database name (with customer prefix)

Requires: 'database:read' permission and database ownership

Response:

FieldTypeDescription
db_namestringRequired.
db_typestringRequired.
enabledbooleanRequired.
frequencystringRequired.
retention_daysintegerRequired.
time_of_dayobject
last_backupobject
next_backupobject

Example:

bash
curl https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/backup-policy \
  -H "X-API-Key: YOUR_API_KEY"

PUT /v1/databases/{db_type}/{db_name}/backup-policy

Set backup policy

Set backup policy for a database

Configure automated backups for this database.

Args: db_type: Either 'postgresql' or 'mariadb' db_name: Database name (with customer prefix) request: Backup policy configuration

Requires: 'database:update' permission and database ownership

Request Body:

FieldTypeDescription
enabledbooleanRequired. Enable/disable automated backups
frequencystringBackup frequency Values: hourly, daily, weekly
retention_daysintegerHow many days to keep backups
time_of_dayobjectTime for daily backups (HH:MM format)

Example:

json
{
  "enabled": true,
  "frequency": "daily",
  "retention_days": 7,
  "time_of_day": "02:00"
}

Response:

FieldTypeDescription
db_namestringRequired.
db_typestringRequired.
enabledbooleanRequired.
frequencystringRequired.
retention_daysintegerRequired.
time_of_dayobject
last_backupobject
next_backupobject

Example:

bash
curl -X PUT https://api.wayscloud.services/v1/databases/{db_type}/{db_name}/backup-policy \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{...}'

WAYSCloud AS