Postgres Clusters
Create Postgres Cluster
Create a Managed Postgres cluster for the organization named in the request body. Provisioning is asynchronous: poll GET /v1/postgres/{id} until status == ready before calling database, user, extension, or credential endpoints.
POST
/
v1
/
postgres
Create Postgres Cluster
curl --request POST \
--url https://api.machines.dev/v1/postgres \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"org_slug": "my-org",
"plan": "basic",
"region": "iad",
"disk_size_gb": 10,
"name": "<string>",
"pg_major_version": "17",
"pool_mode": "transaction",
"postgis_enabled": true
}
'import requests
url = "https://api.machines.dev/v1/postgres"
payload = {
"org_slug": "my-org",
"plan": "basic",
"region": "iad",
"disk_size_gb": 10,
"name": "<string>",
"pg_major_version": "17",
"pool_mode": "transaction",
"postgis_enabled": True
}
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({
org_slug: 'my-org',
plan: 'basic',
region: 'iad',
disk_size_gb: 10,
name: '<string>',
pg_major_version: '17',
pool_mode: 'transaction',
postgis_enabled: true
})
};
fetch('https://api.machines.dev/v1/postgres', 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.machines.dev/v1/postgres",
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([
'org_slug' => 'my-org',
'plan' => 'basic',
'region' => 'iad',
'disk_size_gb' => 10,
'name' => '<string>',
'pg_major_version' => '17',
'pool_mode' => 'transaction',
'postgis_enabled' => true
]),
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.machines.dev/v1/postgres"
payload := strings.NewReader("{\n \"org_slug\": \"my-org\",\n \"plan\": \"basic\",\n \"region\": \"iad\",\n \"disk_size_gb\": 10,\n \"name\": \"<string>\",\n \"pg_major_version\": \"17\",\n \"pool_mode\": \"transaction\",\n \"postgis_enabled\": true\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.machines.dev/v1/postgres")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"org_slug\": \"my-org\",\n \"plan\": \"basic\",\n \"region\": \"iad\",\n \"disk_size_gb\": 10,\n \"name\": \"<string>\",\n \"pg_major_version\": \"17\",\n \"pool_mode\": \"transaction\",\n \"postgis_enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.machines.dev/v1/postgres")
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 \"org_slug\": \"my-org\",\n \"plan\": \"basic\",\n \"region\": \"iad\",\n \"disk_size_gb\": 10,\n \"name\": \"<string>\",\n \"pg_major_version\": \"17\",\n \"pool_mode\": \"transaction\",\n \"postgis_enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"attached_apps": [
{
"name": "<string>"
}
],
"cpu_kind": "shared",
"cpus": 2,
"created_at": "2023-11-07T05:31:56Z",
"disk_size_gb": 10,
"endpoints": {
"primary": {
"direct": {
"host": "<string>",
"port": 123
},
"pooler": {
"host": "<string>",
"port": 123
}
}
},
"id": "<string>",
"memory_mb": 1024,
"name": "<string>",
"organization": {
"name": "<string>",
"slug": "<string>"
},
"pg_major_version": "17",
"plan": "basic",
"postgis_enabled": true,
"region": "iad",
"replicas": 1,
"status": "ready",
"storage_provisioned_bytes": 10737418240,
"storage_used_bytes": 5368709120
}
}{
"error": "<string>",
"status": "sessions_not_terminated"
}{
"error": "<string>",
"status": "sessions_not_terminated"
}{
"error": "<string>",
"status": "sessions_not_terminated"
}{
"error": "<string>",
"status": "sessions_not_terminated"
}Authorizations
Body
application/json
Cluster details
⌘I
Create Postgres Cluster
curl --request POST \
--url https://api.machines.dev/v1/postgres \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"org_slug": "my-org",
"plan": "basic",
"region": "iad",
"disk_size_gb": 10,
"name": "<string>",
"pg_major_version": "17",
"pool_mode": "transaction",
"postgis_enabled": true
}
'import requests
url = "https://api.machines.dev/v1/postgres"
payload = {
"org_slug": "my-org",
"plan": "basic",
"region": "iad",
"disk_size_gb": 10,
"name": "<string>",
"pg_major_version": "17",
"pool_mode": "transaction",
"postgis_enabled": True
}
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({
org_slug: 'my-org',
plan: 'basic',
region: 'iad',
disk_size_gb: 10,
name: '<string>',
pg_major_version: '17',
pool_mode: 'transaction',
postgis_enabled: true
})
};
fetch('https://api.machines.dev/v1/postgres', 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.machines.dev/v1/postgres",
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([
'org_slug' => 'my-org',
'plan' => 'basic',
'region' => 'iad',
'disk_size_gb' => 10,
'name' => '<string>',
'pg_major_version' => '17',
'pool_mode' => 'transaction',
'postgis_enabled' => true
]),
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.machines.dev/v1/postgres"
payload := strings.NewReader("{\n \"org_slug\": \"my-org\",\n \"plan\": \"basic\",\n \"region\": \"iad\",\n \"disk_size_gb\": 10,\n \"name\": \"<string>\",\n \"pg_major_version\": \"17\",\n \"pool_mode\": \"transaction\",\n \"postgis_enabled\": true\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.machines.dev/v1/postgres")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"org_slug\": \"my-org\",\n \"plan\": \"basic\",\n \"region\": \"iad\",\n \"disk_size_gb\": 10,\n \"name\": \"<string>\",\n \"pg_major_version\": \"17\",\n \"pool_mode\": \"transaction\",\n \"postgis_enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.machines.dev/v1/postgres")
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 \"org_slug\": \"my-org\",\n \"plan\": \"basic\",\n \"region\": \"iad\",\n \"disk_size_gb\": 10,\n \"name\": \"<string>\",\n \"pg_major_version\": \"17\",\n \"pool_mode\": \"transaction\",\n \"postgis_enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"attached_apps": [
{
"name": "<string>"
}
],
"cpu_kind": "shared",
"cpus": 2,
"created_at": "2023-11-07T05:31:56Z",
"disk_size_gb": 10,
"endpoints": {
"primary": {
"direct": {
"host": "<string>",
"port": 123
},
"pooler": {
"host": "<string>",
"port": 123
}
}
},
"id": "<string>",
"memory_mb": 1024,
"name": "<string>",
"organization": {
"name": "<string>",
"slug": "<string>"
},
"pg_major_version": "17",
"plan": "basic",
"postgis_enabled": true,
"region": "iad",
"replicas": 1,
"status": "ready",
"storage_provisioned_bytes": 10737418240,
"storage_used_bytes": 5368709120
}
}{
"error": "<string>",
"status": "sessions_not_terminated"
}{
"error": "<string>",
"status": "sessions_not_terminated"
}{
"error": "<string>",
"status": "sessions_not_terminated"
}{
"error": "<string>",
"status": "sessions_not_terminated"
}