Client Reference
D1
D1 endpoint reference.
List
Returns a list of D1 databases.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
params | array | No | [] | Query Parameters. |
php
$response = $client->d1()->list('ACCOUNT_ID', []);
Create
Create D1 Database
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
name | string | Yes | Database name Match pattern: `^[a-z0-9][a-z0-9-_]*$` | |
location | string|null | No | 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. Allowed values: `wnam`,`enam`,`weur`,`eeur`,`apac`,`oc` |
php
$response = $client->d1()->create('ACCOUNT_ID', 'NAME', 'LOCATION');
Get
Returns the specified D1 database.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
databaseId | string | Yes | Database Identifier. |
php
$response = $client->d1()->get('ACCOUNT_ID', 'DATABASE_ID');
Delete
Deletes the specified D1 database.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
databaseId | string | Yes | Database Identifier. |
php
$response = $client->d1()->delete('ACCOUNT_ID', '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.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
databaseId | string | Yes | Database Identifier. | |
currentBookmark | string|null | No | To poll an in-progress export, provide the current bookmark (returned by your first polling response) | |
noData | bool | No | false | Export only the table definitions, not their contents |
noSchema | bool | No | false | Export only each table's contents, not its definition |
tables | array | No | [] |
php
$response = $client->d1()->export('ACCOUNT_ID', 'DATABASE_ID', 'CURRENT_BOOKMARK', true, true, []);
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.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
databaseId | string | Yes | Database Identifier. | |
action | string | No | - `init`: Indicates you have a new SQL file to upload |
php
$response = $client->d1()->import('ACCOUNT_ID', 'DATABASE_ID', 'ACTION', 'ETAG', 'FILENAME', 'CURRENT_BOOKMARK');
Query
Returns the query result as an object.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
databaseId | string | Yes | Database Identifier. | |
query | string | Yes | Your SQL query. Supports multiple statements, joined by semicolons, which will be executed as a batch. | |
params | array | No | [] |
php
$response = $client->d1()->query('ACCOUNT_ID', 'DATABASE_ID', 'QUERY', []);
Raw
Returns the query result rows as arrays rather than objects. This is a performance-optimized version of the /query endpoint.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
accountId | string | Yes | Account Identifier. | |
databaseId | string | Yes | Database Identifier. | |
query | string | Yes | Your SQL query. Supports multiple statements, joined by semicolons, which will be executed as a batch. | |
params | array | No | [] |
php
$response = $client->d1()->raw('ACCOUNT_ID', 'DATABASE_ID', 'QUERY', []);

