## Export D1 Database as SQL `client.d1.database.export(stringdatabaseId, DatabaseExportParamsparams, RequestOptionsoptions?): DatabaseExportResponse` **post** `/accounts/{account_id}/d1/database/{database_id}/export` 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 - `databaseId: string` D1 database identifier (UUID). - `params: DatabaseExportParams` - `account_id: string` Path param: Account identifier tag. - `output_format: "polling"` Body param: Specifies that you will poll this endpoint until the export completes - `"polling"` - `current_bookmark?: string` Body param: To poll an in-progress export, provide the current bookmark (returned by your first polling response) - `dump_options?: DumpOptions` Body param - `no_data?: boolean` Export only the table definitions, not their contents - `no_schema?: boolean` Export only each table's contents, not its definition - `tables?: Array` Filter the export to just one or more tables. Passing an empty array is the same as not passing anything and means: export all tables. ### Returns - `DatabaseExportResponse` - `at_bookmark?: string` The current time-travel bookmark for your D1, used to poll for updates. Will not change for the duration of the export task. - `error?: string` Only present when status = 'error'. Contains the error message. - `messages?: Array` Logs since the last time you polled - `result?: Result` Only present when status = 'complete' - `filename?: string` The generated SQL filename. - `signed_url?: string` The URL to download the exported SQL. Available for one hour. - `status?: "complete" | "error"` - `"complete"` - `"error"` - `success?: boolean` - `type?: "export"` - `"export"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.d1.database.export('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', output_format: 'polling', }); console.log(response.at_bookmark); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "at_bookmark": "at_bookmark", "error": "error", "messages": [ "string" ], "result": { "filename": "filename", "signed_url": "signed_url" }, "status": "complete", "success": true, "type": "export" }, "success": true } ```