Search + K

Command Palette

Search for a command to run...

Sign In

Export D1 Database as SQL

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

Returns a URL where the SQL contents of your D1 can be downloaded. Note: this process may take some time for larger DBs, during which your D1 will be unavailable to serve queries. To avoid blocking your DB unnecessarily, an in-progress export must be continually polled or will automatically cancel.

Parameters

path Path Parameters

Name Type
account_id required
type D1AccountIdentifier = string
database_id required
type D1DatabaseIdentifier = string

Request Body

application/json required
{ current_bookmark?: string;dump_options?: { no_data?: boolean;no_schema?: boolean;tables?: string[]; };output_format: "polling"; }

Responses

200 application/json

Polled successfully, task no longer running (errored or complete)

interface D1ApiResponseCommon {
errors: D1Messages
type D1Messages = { code: number;message: string; }[]
;
messages: D1Messages
type D1Messages = { code: number;message: string; }[]
;
result: {};
success: true;
}
& { result?: {
at_bookmark?: string;
error?: string;
messages?: string[];
result?: { filename?: string;signed_url?: string; };
status?: "complete" | "error";
success?: boolean;
type?: "export";
}
; }
202 application/json

Polled successfully, task is currently running

interface D1ApiResponseCommon {
errors: D1Messages
type D1Messages = { code: number;message: string; }[]
;
messages: D1Messages
type D1Messages = { code: number;message: string; }[]
;
result: {};
success: true;
}
& { result?: {
at_bookmark?: string;
messages?: string[];
status?: "active";
success?: boolean;
type?: "export";
}
; }

Client Errors

4XX application/json

Poll failed (API error)

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