Skip to main content

Create Database

Create new PostgreSQL or MariaDB databases via API.

Endpoint

POST /v1/databases

Request

{
"db_type": "postgresql",
"db_name": "my_app_db"
}

Parameters

  • db_type - postgresql or mariadb
  • db_name - Database name (alphanumeric + underscores)

cURL Example

curl -X POST "https://api.wayscloud.services/v1/databases" \
-H "Authorization: Bearer wayscloud_database_abc123_YourSecretKey" \
-H "Content-Type: application/json" \
-d '{
"db_type": "postgresql",
"db_name": "my_production_db"
}'

Response

{
"success": true,
"message": "Database created successfully",
"database": {
"db_name": "my_production_db",
"db_type": "postgresql",
"host": "172.29.1.10",
"port": 5432,
"username": "user_abc123",
"status": "active"
}
}

Python Example

import requests
import os

API_KEY = os.getenv('WAYSCLOUD_API_KEY')

response = requests.post(
'https://api.wayscloud.services/v1/databases',
headers={'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json'},
json={'db_type': 'postgresql', 'db_name': 'my_app_db'}
)

result = response.json()
print(f"Database created: {result['database']['db_name']}")
print(f"Host: {result['database']['host']}")
print(f"Port: {result['database']['port']}")

Naming Rules

  • Alphanumeric characters and underscores only
  • Must start with a letter
  • Max 63 characters
  • Cannot use reserved words

Next Steps