Create a bouncer
curl --request POST \
--url https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"target": "<string>",
"bouncer_size": "<string>",
"replicas_per_cell": 123
}
'import requests
url = "https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers"
payload = {
"name": "<string>",
"target": "<string>",
"bouncer_size": "<string>",
"replicas_per_cell": 123
}
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: '<string>',
target: '<string>',
bouncer_size: '<string>',
replicas_per_cell: 123
})
};
fetch('https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers', 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.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers",
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' => '<string>',
'target' => '<string>',
'bouncer_size' => '<string>',
'replicas_per_cell' => 123
]),
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.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"target\": \"<string>\",\n \"bouncer_size\": \"<string>\",\n \"replicas_per_cell\": 123\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.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"target\": \"<string>\",\n \"bouncer_size\": \"<string>\",\n \"replicas_per_cell\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers")
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\": \"<string>\",\n \"target\": \"<string>\",\n \"bouncer_size\": \"<string>\",\n \"replicas_per_cell\": 123\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"sku": {
"name": "<string>",
"display_name": "<string>",
"cpu": "<string>",
"ram": 123,
"sort_order": 123
},
"replicas_per_cell": 123,
"created_at": "<string>",
"updated_at": "<string>",
"deleted_at": "<string>",
"actor": {
"id": "<string>",
"display_name": "<string>",
"avatar_url": "<string>"
},
"branch": {
"id": "<string>",
"name": "<string>",
"created_at": "<string>",
"updated_at": "<string>",
"deleted_at": "<string>"
},
"parameters": [
{
"id": "<string>",
"namespace": "pgbouncer",
"name": "<string>",
"display_name": "<string>",
"category": "<string>",
"description": "<string>",
"immutable": true,
"default_value": "<string>",
"value": "<string>",
"required": true,
"created_at": "<string>",
"updated_at": "<string>",
"restart": true,
"max": 123,
"min": 123,
"step": 123,
"url": "<string>",
"options": [
"<string>"
],
"actor": {
"id": "<string>",
"display_name": "<string>",
"avatar_url": "<string>"
}
}
]
}Dedicated PgBouncers
Create a bouncer
Authorization
A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
Service Token Accesses
write_database
OAuth Scopes
| Resource | Scopes |
|---|---|
| Organization | write_databases |
| Database | write_database |
POST
/
organizations
/
{organization}
/
databases
/
{database}
/
branches
/
{branch}
/
bouncers
Create a bouncer
curl --request POST \
--url https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"target": "<string>",
"bouncer_size": "<string>",
"replicas_per_cell": 123
}
'import requests
url = "https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers"
payload = {
"name": "<string>",
"target": "<string>",
"bouncer_size": "<string>",
"replicas_per_cell": 123
}
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: '<string>',
target: '<string>',
bouncer_size: '<string>',
replicas_per_cell: 123
})
};
fetch('https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers', 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.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers",
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' => '<string>',
'target' => '<string>',
'bouncer_size' => '<string>',
'replicas_per_cell' => 123
]),
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.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"target\": \"<string>\",\n \"bouncer_size\": \"<string>\",\n \"replicas_per_cell\": 123\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.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"target\": \"<string>\",\n \"bouncer_size\": \"<string>\",\n \"replicas_per_cell\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.planetscale.com/v1/organizations/{organization}/databases/{database}/branches/{branch}/bouncers")
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\": \"<string>\",\n \"target\": \"<string>\",\n \"bouncer_size\": \"<string>\",\n \"replicas_per_cell\": 123\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"sku": {
"name": "<string>",
"display_name": "<string>",
"cpu": "<string>",
"ram": 123,
"sort_order": 123
},
"replicas_per_cell": 123,
"created_at": "<string>",
"updated_at": "<string>",
"deleted_at": "<string>",
"actor": {
"id": "<string>",
"display_name": "<string>",
"avatar_url": "<string>"
},
"branch": {
"id": "<string>",
"name": "<string>",
"created_at": "<string>",
"updated_at": "<string>",
"deleted_at": "<string>"
},
"parameters": [
{
"id": "<string>",
"namespace": "pgbouncer",
"name": "<string>",
"display_name": "<string>",
"category": "<string>",
"description": "<string>",
"immutable": true,
"default_value": "<string>",
"value": "<string>",
"required": true,
"created_at": "<string>",
"updated_at": "<string>",
"restart": true,
"max": 123,
"min": 123,
"step": 123,
"url": "<string>",
"options": [
"<string>"
],
"actor": {
"id": "<string>",
"display_name": "<string>",
"avatar_url": "<string>"
}
}
]
}Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
Path Parameters
Organization name slug from list_organizations. Example: acme.
Database name slug from list_databases. Example: app-db.
Branch name from list_branches. Example: main.
Body
application/json
Response
Returns the new bouncer
The ID of the bouncer
The name of the bouncer
Show child attributes
Show child attributes
The instance type the bouncer targets
Available options:
primary, replica, replica_az_affinity The count of replicas in each cell
When the bouncer was created
When the bouncer was updated
When the bouncer was deleted
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
⌘I

