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.
curl --request POST \
--url https://api.machines.dev/v1/postgres \
--header 'Authorization: <api-key>' \
--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": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', '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: <api-key>",
"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", "<api-key>")
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", "<api-key>")
.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"] = '<api-key>'
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>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
A Fly API token with access to the requested organization or resource. Send it as Authorization: Bearer <Fly API token>.
Body
Cluster details
Slug of the organization that will own the cluster, or "personal" for the caller's personal organization.
"my-org"
Plan slug selecting CPU, memory, and disk sizing. Matched case-insensitively.
basic, starter, launch, scale, Performance "basic"
Fly region code where the cluster's primary runs.
"iad"
Disk size in gigabytes.
10 <= x <= 100010
Name for the cluster. A name is generated when omitted.
Postgres major version.
16, 17 "17"
Connection pooler mode.
session, transaction "transaction"
Enable PostGIS support, required to later enable PostGIS extensions.
Response
Cluster accepted for provisioning
Show child attributes
Show child attributes
curl --request POST \
--url https://api.machines.dev/v1/postgres \
--header 'Authorization: <api-key>' \
--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": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', '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: <api-key>",
"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", "<api-key>")
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", "<api-key>")
.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"] = '<api-key>'
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>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}