Search + K

Command Palette

Search for a command to run...

Sign In

Create D1 Database

POST /accounts/{account_id}/d1/database
Copy endpoint
https://api.cloudflare.com/client/v4

Returns the created D1 database.

Parameters

path Path Parameters

Name Type
account_id required
type D1AccountIdentifier = string

Request Body

application/json required
{ name: D1DatabaseName

D1 database name.

type D1DatabaseName = string
;primary_location_hint?: D1PrimaryLocationHint

Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user.

type D1PrimaryLocationHint = "wnam" | "enam" | "weur" | "eeur" | "apac" | "oc"
; }

Responses

200 application/json

Returns the created D1 database's metadata

interface D1ApiResponseCommon {
errors: D1Messages
type D1Messages = { code: number;message: string; }[]
;
messages: D1Messages
type D1Messages = { code: number;message: string; }[]
;
result: {};
success: true;
}
& { result?: D1DatabaseDetailsResponse

The details of the D1 database.

interface D1DatabaseDetailsResponse {
created_at?: D1CreatedAt;
file_size?: D1FileSize;
name?: D1DatabaseName;
num_tables?: D1TableCount;
read_replication?: D1ReadReplicationDetails;
uuid?: D1DatabaseIdentifier;
version?: D1DatabaseVersion;
}
; }

Client Errors

4XX application/json

Database details response failure

interface D1ApiResponseCommonFailure {
errors: D1Messages
type D1Messages = { code: number;message: string; }[]
;
messages: D1Messages
type D1Messages = { code: number;message: string; }[]
;
result: null;
success: false;
}