Skip to main content
POST
/
databases
Create database
curl --request POST \
  --url https://cloud.laravel.com/api/databases \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "config": {
    "suspend_seconds": 123,
    "retention_days": 123
  },
  "cluster_id": 123
}
'
import requests

url = "https://cloud.laravel.com/api/databases"

payload = {
"name": "<string>",
"config": {
"suspend_seconds": 123,
"retention_days": 123
},
"cluster_id": 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>',
config: {suspend_seconds: 123, retention_days: 123},
cluster_id: 123
})
};

fetch('https://cloud.laravel.com/api/databases', 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://cloud.laravel.com/api/databases",
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>',
'config' => [
'suspend_seconds' => 123,
'retention_days' => 123
],
'cluster_id' => 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://cloud.laravel.com/api/databases"

payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"config\": {\n \"suspend_seconds\": 123,\n \"retention_days\": 123\n },\n \"cluster_id\": 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://cloud.laravel.com/api/databases")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"config\": {\n \"suspend_seconds\": 123,\n \"retention_days\": 123\n },\n \"cluster_id\": 123\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://cloud.laravel.com/api/databases")

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 \"config\": {\n \"suspend_seconds\": 123,\n \"retention_days\": 123\n },\n \"cluster_id\": 123\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "id": "<string>",
    "type": "databases",
    "attributes": {
      "name": "<string>",
      "created_at": "2023-11-07T05:31:56Z",
      "config": {
        "suspend_seconds": 123,
        "retention_days": 123
      },
      "connection": {
        "hostname": "<string>",
        "username": "<string>",
        "password": "<string>"
      }
    },
    "relationships": {
      "schemas": {
        "data": [
          {
            "type": "databaseSchemas",
            "id": "<string>"
          }
        ]
      },
      "databases": {
        "data": [
          {
            "type": "databaseSchemas",
            "id": "<string>"
          }
        ]
      }
    }
  },
  "included": [
    {
      "id": "<string>",
      "type": "databaseSchemas",
      "attributes": {
        "name": "<string>",
        "status": "<string>",
        "created_at": "2023-11-07T05:31:56Z"
      },
      "relationships": {
        "database": {
          "data": {
            "type": "databases",
            "id": "<string>"
          }
        },
        "environments": {
          "data": [
            {
              "type": "environments",
              "id": "<string>"
            }
          ]
        }
      }
    }
  ]
}
{
"message": ""
}
{
"message": "<string>",
"errors": {}
}

Authorizations

Authorization
string
header
required

The Bearer Token generated on the Cloud UI.

Body

application/json
type
enum<string>
required
Available options:
laravel_mysql_84,
laravel_mysql_8,
aws_rds_mysql_8,
aws_rds_postgres_18,
neon_serverless_postgres_18,
neon_serverless_postgres_17,
neon_serverless_postgres_16
name
string
required
Required string length: 3 - 40
Pattern: ^[a-z0-9_-]+$
region
enum<string>
required
Available options:
us-east-2,
us-east-1,
ca-central-1,
eu-central-1,
eu-west-1,
eu-west-2,
me-central-1,
ap-southeast-1,
ap-southeast-2,
ap-northeast-1
config
Neon Serverless Postgres · object
required

Configuration object. Fields vary based on database type.

cluster_id
integer | null

Response

DatabaseResource

data
DatabaseResource · object
required
included
DatabaseSchemaResource · object[]