D1

d1

Domain types

D1 = { created_at, file_size, name, 3 more... }
D1

Database

d1.database

Methods

Create D1 Database -> Envelope<>
post/accounts/{account_id}/d1/database

Returns the created D1 database.

Delete D1 Database -> Envelope<unknown>
delete/accounts/{account_id}/d1/database/{database_id}

Deletes the specified D1 database.

Export D1 Database As Sql -> Envelope<{ at_bookmark, error, messages, 4 more... }>
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.

Security

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example: Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY

Parameters
account_id: string

Account identifier tag.

database_id: string
Response fields
errors: Array<>
messages: Array<>
result: { at_bookmark, error, messages, 4 more... }
success: true

Whether the API call was successful

Request example
200Example
Get D1 Database -> Envelope<>
get/accounts/{account_id}/d1/database/{database_id}

Returns the specified D1 database.

Import Sql Into Your D1 Database -> Envelope<{ at_bookmark, error, filename, 6 more... }>
post/accounts/{account_id}/d1/database/{database_id}/import

Generates a temporary URL for uploading an SQL file to, then instructing the D1 to import it and polling it for status updates. Imports block the D1 for their duration.

List D1 Databases -> V4PagePaginationArray<{ created_at, name, uuid, 1 more... }>
get/accounts/{account_id}/d1/database

Returns a list of D1 databases.

Query D1 Database -> Envelope<Array<>>
post/accounts/{account_id}/d1/database/{database_id}/query

Returns the query result as an object.

Raw D1 Database Query -> Envelope<Array<{ meta, results, success }>>
post/accounts/{account_id}/d1/database/{database_id}/raw

Returns the query result rows as arrays rather than objects. This is a performance-optimized version of the /query endpoint.

Domain types

QueryResult = { meta, results, success }