PHP Client for Cloudflare API
Client Reference

D1

D1 endpoint reference.

List

Returns a list of D1 databases.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
paramsarrayNo[]Query Parameters.
php
$response = $client->d1()->list('ACCOUNT_ID', []);
View this operation on the Cloudflare API Reference

Create

Create D1 Database

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
namestringYesDatabase name Match pattern: `^[a-z0-9][a-z0-9-_]*$`
locationstring|nullNoSpecify 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. Allowed values: `wnam`,`enam`,`weur`,`eeur`,`apac`,`oc`
php
$response = $client->d1()->create('ACCOUNT_ID', 'NAME', 'LOCATION');
View this operation on the Cloudflare API Reference

Get

Returns the specified D1 database.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
databaseIdstringYesDatabase Identifier.
php
$response = $client->d1()->get('ACCOUNT_ID', 'DATABASE_ID');
View this operation on the Cloudflare API Reference

Delete

Deletes the specified D1 database.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
databaseIdstringYesDatabase Identifier.
php
$response = $client->d1()->delete('ACCOUNT_ID', 'DATABASE_ID');
View this operation on the Cloudflare API Reference

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.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
databaseIdstringYesDatabase Identifier.
currentBookmarkstring|nullNoTo poll an in-progress export, provide the current bookmark (returned by your first polling response)
noDataboolNofalseExport only the table definitions, not their contents
noSchemaboolNofalseExport only each table's contents, not its definition
tablesarrayNo[]
php
$response = $client->d1()->export('ACCOUNT_ID', 'DATABASE_ID', 'CURRENT_BOOKMARK', true, true, []);
View this operation on the Cloudflare API Reference

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.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
databaseIdstringYesDatabase Identifier.
actionstringNo- `init`: Indicates you have a new SQL file to upload
php
$response = $client->d1()->import('ACCOUNT_ID', 'DATABASE_ID', 'ACTION', 'ETAG', 'FILENAME', 'CURRENT_BOOKMARK');
View this operation on the Cloudflare API Reference

Query

Returns the query result as an object.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
databaseIdstringYesDatabase Identifier.
querystringYesYour SQL query. Supports multiple statements, joined by semicolons, which will be executed as a batch.
paramsarrayNo[]
php
$response = $client->d1()->query('ACCOUNT_ID', 'DATABASE_ID', 'QUERY', []);
View this operation on the Cloudflare API Reference

Raw

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

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount Identifier.
databaseIdstringYesDatabase Identifier.
querystringYesYour SQL query. Supports multiple statements, joined by semicolons, which will be executed as a batch.
paramsarrayNo[]
php
$response = $client->d1()->raw('ACCOUNT_ID', 'DATABASE_ID', 'QUERY', []);
View this operation on the Cloudflare API Reference
Copyright © 2026