curl --request POST \
--url https://api.camposcloud.com/v1/databases/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "main-db",
"type": "postgresql",
"memoryMB": 512,
"password": "Tr0ub4dor.Zebra-Lamp=91",
"team": "<string>",
"username": "app_user",
"database": "app_db"
}
'import requests
url = "https://api.camposcloud.com/v1/databases/create"
payload = {
"name": "main-db",
"type": "postgresql",
"memoryMB": 512,
"password": "Tr0ub4dor.Zebra-Lamp=91",
"team": "<string>",
"username": "app_user",
"database": "app_db"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'main-db',
type: 'postgresql',
memoryMB: 512,
password: 'Tr0ub4dor.Zebra-Lamp=91',
team: '<string>',
username: 'app_user',
database: 'app_db'
})
};
fetch('https://api.camposcloud.com/v1/databases/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.camposcloud.com/v1/databases/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'main-db',
'type' => 'postgresql',
'memoryMB' => 512,
'password' => 'Tr0ub4dor.Zebra-Lamp=91',
'team' => '<string>',
'username' => 'app_user',
'database' => 'app_db'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.camposcloud.com/v1/databases/create"
payload := strings.NewReader("{\n \"name\": \"main-db\",\n \"type\": \"postgresql\",\n \"memoryMB\": 512,\n \"password\": \"Tr0ub4dor.Zebra-Lamp=91\",\n \"team\": \"<string>\",\n \"username\": \"app_user\",\n \"database\": \"app_db\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.camposcloud.com/v1/databases/create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"main-db\",\n \"type\": \"postgresql\",\n \"memoryMB\": 512,\n \"password\": \"Tr0ub4dor.Zebra-Lamp=91\",\n \"team\": \"<string>\",\n \"username\": \"app_user\",\n \"database\": \"app_db\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.camposcloud.com/v1/databases/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"main-db\",\n \"type\": \"postgresql\",\n \"memoryMB\": 512,\n \"password\": \"Tr0ub4dor.Zebra-Lamp=91\",\n \"team\": \"<string>\",\n \"username\": \"app_user\",\n \"database\": \"app_db\"\n}"
response = http.request(request)
puts response.read_body{
"_id": "64b7f0c2a1b2c3d4e5f60718",
"name": "main-db",
"type": "postgresql",
"status": "active",
"restartRequired": false,
"userId": "64b7f0c2a1b2c3d4e5f60700",
"teamId": null,
"workerNodeId": {
"_id": "64b7f0c2a1b2c3d4e5f60799",
"nodeName": "node-1"
},
"allocatedMemoryMB": 512,
"allocatedVCpu": 1,
"diskLimitBytes": 10737418240,
"diskUsageBytes": 52428800,
"containerImage": "postgres:trixie",
"connection": {
"host": "db.camposcloud.com",
"port": 30001,
"username": "app_user",
"database": "app_db"
},
"currentResourceMetrics": {
"timestamp": "2025-01-01T12:00:00.000Z",
"online": true,
"uptime": 35980,
"startedAt": "2025-01-01T12:00:00.000Z",
"cpuUsagePercent": 0.42,
"memoryUsageBytes": 43671552,
"memoryLimitBytes": 268435456,
"networkRxBytes": 228961,
"networkTxBytes": 228190
},
"createdAt": "2025-01-01T12:00:00.000Z",
"updatedAt": "2025-01-01T12:00:00.000Z"
}{
"error": "password too weak. use a stronger password"
}{
"error": "Invalid developer token"
}{
"error": "User does not have an active plan."
}{
"error": "Team not found for the provided ID."
}{
"error": "Database change limit reached, please try again later"
}{
"error": "Internal server error. Please try again later."
}{
"error": "No available worker found to deploy the application. Please try again later."
}/v1/databases/create
This endpoint creates a MySQL, PostgreSQL, MongoDB or Redis database.
curl --request POST \
--url https://api.camposcloud.com/v1/databases/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "main-db",
"type": "postgresql",
"memoryMB": 512,
"password": "Tr0ub4dor.Zebra-Lamp=91",
"team": "<string>",
"username": "app_user",
"database": "app_db"
}
'import requests
url = "https://api.camposcloud.com/v1/databases/create"
payload = {
"name": "main-db",
"type": "postgresql",
"memoryMB": 512,
"password": "Tr0ub4dor.Zebra-Lamp=91",
"team": "<string>",
"username": "app_user",
"database": "app_db"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'main-db',
type: 'postgresql',
memoryMB: 512,
password: 'Tr0ub4dor.Zebra-Lamp=91',
team: '<string>',
username: 'app_user',
database: 'app_db'
})
};
fetch('https://api.camposcloud.com/v1/databases/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.camposcloud.com/v1/databases/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'main-db',
'type' => 'postgresql',
'memoryMB' => 512,
'password' => 'Tr0ub4dor.Zebra-Lamp=91',
'team' => '<string>',
'username' => 'app_user',
'database' => 'app_db'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.camposcloud.com/v1/databases/create"
payload := strings.NewReader("{\n \"name\": \"main-db\",\n \"type\": \"postgresql\",\n \"memoryMB\": 512,\n \"password\": \"Tr0ub4dor.Zebra-Lamp=91\",\n \"team\": \"<string>\",\n \"username\": \"app_user\",\n \"database\": \"app_db\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.camposcloud.com/v1/databases/create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"main-db\",\n \"type\": \"postgresql\",\n \"memoryMB\": 512,\n \"password\": \"Tr0ub4dor.Zebra-Lamp=91\",\n \"team\": \"<string>\",\n \"username\": \"app_user\",\n \"database\": \"app_db\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.camposcloud.com/v1/databases/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"main-db\",\n \"type\": \"postgresql\",\n \"memoryMB\": 512,\n \"password\": \"Tr0ub4dor.Zebra-Lamp=91\",\n \"team\": \"<string>\",\n \"username\": \"app_user\",\n \"database\": \"app_db\"\n}"
response = http.request(request)
puts response.read_body{
"_id": "64b7f0c2a1b2c3d4e5f60718",
"name": "main-db",
"type": "postgresql",
"status": "active",
"restartRequired": false,
"userId": "64b7f0c2a1b2c3d4e5f60700",
"teamId": null,
"workerNodeId": {
"_id": "64b7f0c2a1b2c3d4e5f60799",
"nodeName": "node-1"
},
"allocatedMemoryMB": 512,
"allocatedVCpu": 1,
"diskLimitBytes": 10737418240,
"diskUsageBytes": 52428800,
"containerImage": "postgres:trixie",
"connection": {
"host": "db.camposcloud.com",
"port": 30001,
"username": "app_user",
"database": "app_db"
},
"currentResourceMetrics": {
"timestamp": "2025-01-01T12:00:00.000Z",
"online": true,
"uptime": 35980,
"startedAt": "2025-01-01T12:00:00.000Z",
"cpuUsagePercent": 0.42,
"memoryUsageBytes": 43671552,
"memoryLimitBytes": 268435456,
"networkRxBytes": 228961,
"networkTxBytes": 228190
},
"createdAt": "2025-01-01T12:00:00.000Z",
"updatedAt": "2025-01-01T12:00:00.000Z"
}{
"error": "password too weak. use a stronger password"
}{
"error": "Invalid developer token"
}{
"error": "User does not have an active plan."
}{
"error": "Team not found for the provided ID."
}{
"error": "Database change limit reached, please try again later"
}{
"error": "Internal server error. Please try again later."
}{
"error": "No available worker found to deploy the application. Please try again later."
}Connecting
Useconnection.host and connection.port from the response of GET /v1/databases/{databaseId} once the status is active:
| Type | Connection string |
|---|---|
postgresql | postgresql://<username>:<password>@<host>:<port>/<database> |
mysql | mysql://<username>:<password>@<host>:<port>/<database> |
mongodb | mongodb://<username>:<password>@<host>:<port>/?authSource=admin |
redis | redis://default:<password>@<host>:<port> |
Authorizations
Body
Password of the database. 12 to 72 characters, only letters, numbers and _ . @ % + = -, starting with a letter or number. It must also be strong enough (zxcvbn score 3 or higher), otherwise the request is refused with password too weak. use a stronger password.
12 - 72^[A-Za-z0-9][A-Za-z0-9_.@%+=-]*$"Tr0ub4dor.Zebra-Lamp=91"
User that your applications will connect with. Required for mysql, postgresql and mongodb, not allowed for redis. 3 to 32 letters, numbers or _, starting with a letter. Reserved names such as root, admin, postgres and mysql are refused.
^[A-Za-z][A-Za-z0-9_]{2,31}$"app_user"
Name of the initial database. Required for mysql and postgresql, not allowed for mongodb and redis. Up to 63 letters, numbers or _, starting with a letter. Reserved names such as mysql, postgres, information_schema and admin are refused.
^[A-Za-z][A-Za-z0-9_]{0,62}$"app_db"
Response
The database that is being created.