---
title: D1
---

[Skip to content](#%5Ftop) 

[API Reference](https://developers.cloudflare.com/api/typescript)

Copy Markdown

Open in **Claude**

Open in **ChatGPT**

Open in **Cursor**

---

**Copy Markdown**

**View as Markdown**

# D1

##### ModelsExpand Collapse 

D1 { created\_at, file\_size, jurisdiction, 5 more } 

The details of the D1 database.

created\_at?: string

Specifies the timestamp the resource was created as an ISO8601 string.

formatdate-time

file\_size?: number

The D1 database’s size, in bytes.

jurisdiction?: "eu" | "fedramp" | "us" | null

Specify the location to restrict the D1 database to run and store data. If this option is present, the location hint is ignored.

One of the following:

"eu"

"fedramp"

"us"

name?: string

D1 database name.

num\_tables?: number

read\_replication?: ReadReplication { mode } 

Configuration for D1 read replication.

mode: "auto" | "disabled"

The read replication mode for the database. Mode ‘auto’ denotes that D1 creates replicas and automatically places them around the world. Mode ‘disabled’ denotes that no database replicas are used.

One of the following:

"auto"

"disabled"

uuid?: string

D1 database identifier (UUID).

version?: string

#### D1Database

##### [List D1 Databases](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/methods/list)

client.d1.database.list(DatabaseListParams { account\_id, name, page, per\_page } params, RequestOptionsoptions?): V4PagePaginationArray<[DatabaseListResponse](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1.database%20%3E%20%28model%29%20database%5Flist%5Fresponse%20%3E%20%28schema%29) { created\_at, jurisdiction, name, 2 more } \>

GET/accounts/{account\_id}/d1/database

##### [Get D1 Database](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/methods/get)

client.d1.database.get(stringdatabaseID, DatabaseGetParams { account\_id, fields } params, RequestOptionsoptions?): [D1](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1%20%3E%20%28model%29%20d1%20%3E%20%28schema%29) { created\_at, file\_size, jurisdiction, 5 more } 

GET/accounts/{account\_id}/d1/database/{database\_id}

##### [Create D1 Database](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/methods/create)

client.d1.database.create(DatabaseCreateParams { account\_id, name, jurisdiction, 2 more } params, RequestOptionsoptions?): [D1](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1%20%3E%20%28model%29%20d1%20%3E%20%28schema%29) { created\_at, file\_size, jurisdiction, 5 more } 

POST/accounts/{account\_id}/d1/database

##### [Update D1 Database](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/methods/update)

client.d1.database.update(stringdatabaseID, DatabaseUpdateParams { account\_id, read\_replication } params, RequestOptionsoptions?): [D1](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1%20%3E%20%28model%29%20d1%20%3E%20%28schema%29) { created\_at, file\_size, jurisdiction, 5 more } 

PUT/accounts/{account\_id}/d1/database/{database\_id}

##### [Update D1 Database partially](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/methods/edit)

client.d1.database.edit(stringdatabaseID, DatabaseEditParams { account\_id, read\_replication } params, RequestOptionsoptions?): [D1](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1%20%3E%20%28model%29%20d1%20%3E%20%28schema%29) { created\_at, file\_size, jurisdiction, 5 more } 

PATCH/accounts/{account\_id}/d1/database/{database\_id}

##### [Delete D1 Database](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/methods/delete)

client.d1.database.delete(stringdatabaseID, DatabaseDeleteParams { account\_id } params, RequestOptionsoptions?): [DatabaseDeleteResponse](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1.database%20%3E%20%28model%29%20database%5Fdelete%5Fresponse%20%3E%20%28schema%29) | null

DELETE/accounts/{account\_id}/d1/database/{database\_id}

##### [Query D1 Database](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/methods/query)

client.d1.database.query(stringdatabaseID, DatabaseQueryParamsparams, RequestOptionsoptions?): SinglePage<[QueryResult](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1.database%20%3E%20%28model%29%20query%5Fresult%20%3E%20%28schema%29) { meta, results, success } \>

POST/accounts/{account\_id}/d1/database/{database\_id}/query

##### [Raw D1 Database query](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/methods/raw)

client.d1.database.raw(stringdatabaseID, DatabaseRawParamsparams, RequestOptionsoptions?): SinglePage<[DatabaseRawResponse](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1.database%20%3E%20%28model%29%20database%5Fraw%5Fresponse%20%3E%20%28schema%29) { meta, results, success } \>

POST/accounts/{account\_id}/d1/database/{database\_id}/raw

##### [Export D1 Database as SQL](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/methods/export)

client.d1.database.export(stringdatabaseID, DatabaseExportParams { account\_id, output\_format, current\_bookmark, dump\_options } params, RequestOptionsoptions?): [DatabaseExportResponse](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1.database%20%3E%20%28model%29%20database%5Fexport%5Fresponse%20%3E%20%28schema%29) { at\_bookmark, error, messages, 4 more } 

POST/accounts/{account\_id}/d1/database/{database\_id}/export

##### [Import SQL into your D1 Database](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/methods/import)

client.d1.database.import(stringdatabaseID, DatabaseImportParamsparams, RequestOptionsoptions?): [DatabaseImportResponse](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1.database%20%3E%20%28model%29%20database%5Fimport%5Fresponse%20%3E%20%28schema%29) { at\_bookmark, error, filename, 6 more } 

POST/accounts/{account\_id}/d1/database/{database\_id}/import

##### ModelsExpand Collapse 

QueryResult { meta, results, success } 

meta?: Meta { changed\_db, changes, duration, 8 more } 

changed\_db?: boolean

Denotes if the database has been altered in some way, like deleting rows.

changes?: number

Rough indication of how many rows were modified by the query, as provided by SQLite’s `sqlite3_total_changes()`.

duration?: number

The duration of the SQL query execution inside the database. Does not include any network communication.

last\_row\_id?: number

The row ID of the last inserted row in a table with an `INTEGER PRIMARY KEY` as provided by SQLite. Tables created with `WITHOUT ROWID` do not populate this.

rows\_read?: number

Number of rows read during the SQL query execution, including indices (not all rows are necessarily returned).

rows\_written?: number

Number of rows written during the SQL query execution, including indices.

served\_by\_colo?: string

The three letters airport code of the colo that handled the query.

served\_by\_primary?: boolean

Denotes if the query has been handled by the database primary instance.

served\_by\_region?: "WNAM" | "ENAM" | "WEUR" | 3 more

Region location hint of the database instance that handled the query.

One of the following:

"WNAM"

"ENAM"

"WEUR"

"EEUR"

"APAC"

"OC"

size\_after?: number

Size of the database after the query committed, in bytes.

timings?: Timings { sql\_duration\_ms } 

Various durations for the query.

sql\_duration\_ms?: number

The duration of the SQL query execution inside the database. Does not include any network communication.

results?: Array<unknown\>

success?: boolean

DatabaseListResponse { created\_at, jurisdiction, name, 2 more } 

created\_at?: string

Specifies the timestamp the resource was created as an ISO8601 string.

formatdate-time

jurisdiction?: "eu" | "fedramp" | "us" | null

Specify the location to restrict the D1 database to run and store data. If this option is present, the location hint is ignored.

One of the following:

"eu"

"fedramp"

"us"

name?: string

D1 database name.

uuid?: string

D1 database identifier (UUID).

version?: string

DatabaseDeleteResponse \= unknown

DatabaseRawResponse { meta, results, success } 

meta?: Meta { changed\_db, changes, duration, 8 more } 

changed\_db?: boolean

Denotes if the database has been altered in some way, like deleting rows.

changes?: number

Rough indication of how many rows were modified by the query, as provided by SQLite’s `sqlite3_total_changes()`.

duration?: number

The duration of the SQL query execution inside the database. Does not include any network communication.

last\_row\_id?: number

The row ID of the last inserted row in a table with an `INTEGER PRIMARY KEY` as provided by SQLite. Tables created with `WITHOUT ROWID` do not populate this.

rows\_read?: number

Number of rows read during the SQL query execution, including indices (not all rows are necessarily returned).

rows\_written?: number

Number of rows written during the SQL query execution, including indices.

served\_by\_colo?: string

The three letters airport code of the colo that handled the query.

served\_by\_primary?: boolean

Denotes if the query has been handled by the database primary instance.

served\_by\_region?: "WNAM" | "ENAM" | "WEUR" | 3 more

Region location hint of the database instance that handled the query.

One of the following:

"WNAM"

"ENAM"

"WEUR"

"EEUR"

"APAC"

"OC"

size\_after?: number

Size of the database after the query committed, in bytes.

timings?: Timings { sql\_duration\_ms } 

Various durations for the query.

sql\_duration\_ms?: number

The duration of the SQL query execution inside the database. Does not include any network communication.

results?: Results { columns, rows } 

columns?: Array<string\>

rows?: Array<Array<number | string | unknown\>\>

One of the following:

number

string

unknown

success?: boolean

DatabaseExportResponse { at\_bookmark, error, messages, 4 more } 

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<string\>

Logs since the last time you polled

result?: Result { filename, signed\_url } 

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"

One of the following:

"complete"

"error"

success?: boolean

type?: "export"

DatabaseImportResponse { at\_bookmark, error, filename, 6 more } 

at\_bookmark?: string

The current time-travel bookmark for your D1, used to poll for updates. Will not change for the duration of the import. Only returned if an import process is currently running or recently finished.

error?: string

Only present when status = ‘error’. Contains the error message that prevented the import from succeeding.

filename?: string

Derived from the database ID and etag, to use in avoiding repeated uploads. Only returned when for the ‘init’ action.

messages?: Array<string\>

Logs since the last time you polled

result?: Result { final\_bookmark, meta, num\_queries } 

Only present when status = ‘complete’

final\_bookmark?: string

The time-travel bookmark if you need restore your D1 to directly after the import succeeded.

meta?: Meta { changed\_db, changes, duration, 8 more } 

changed\_db?: boolean

Denotes if the database has been altered in some way, like deleting rows.

changes?: number

Rough indication of how many rows were modified by the query, as provided by SQLite’s `sqlite3_total_changes()`.

duration?: number

The duration of the SQL query execution inside the database. Does not include any network communication.

last\_row\_id?: number

The row ID of the last inserted row in a table with an `INTEGER PRIMARY KEY` as provided by SQLite. Tables created with `WITHOUT ROWID` do not populate this.

rows\_read?: number

Number of rows read during the SQL query execution, including indices (not all rows are necessarily returned).

rows\_written?: number

Number of rows written during the SQL query execution, including indices.

served\_by\_colo?: string

The three letters airport code of the colo that handled the query.

served\_by\_primary?: boolean

Denotes if the query has been handled by the database primary instance.

served\_by\_region?: "WNAM" | "ENAM" | "WEUR" | 3 more

Region location hint of the database instance that handled the query.

One of the following:

"WNAM"

"ENAM"

"WEUR"

"EEUR"

"APAC"

"OC"

size\_after?: number

Size of the database after the query committed, in bytes.

timings?: Timings { sql\_duration\_ms } 

Various durations for the query.

sql\_duration\_ms?: number

The duration of the SQL query execution inside the database. Does not include any network communication.

num\_queries?: number

The total number of queries that were executed during the import.

status?: "complete" | "error"

One of the following:

"complete"

"error"

success?: boolean

type?: "import"

upload\_url?: string

The R2 presigned URL to use for uploading. Only returned when for the ‘init’ action.

#### D1DatabaseTime Travel

##### [Get D1 database bookmark](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/subresources/time%5Ftravel/methods/get%5Fbookmark)

client.d1.database.timeTravel.getBookmark(stringdatabaseID, TimeTravelGetBookmarkParams { account\_id, timestamp } params, RequestOptionsoptions?): [TimeTravelGetBookmarkResponse](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1.database.time%5Ftravel%20%3E%20%28model%29%20time%5Ftravel%5Fget%5Fbookmark%5Fresponse%20%3E%20%28schema%29) { bookmark } 

GET/accounts/{account\_id}/d1/database/{database\_id}/time\_travel/bookmark

##### [Restore D1 Database to a bookmark or point in time](https://developers.cloudflare.com/api/typescript/resources/d1/subresources/database/subresources/time%5Ftravel/methods/restore)

client.d1.database.timeTravel.restore(stringdatabaseID, TimeTravelRestoreParams { account\_id, bookmark, timestamp } params, RequestOptionsoptions?): [TimeTravelRestoreResponse](https://developers.cloudflare.com/api/typescript/resources/d1#%28resource%29%20d1.database.time%5Ftravel%20%3E%20%28model%29%20time%5Ftravel%5Frestore%5Fresponse%20%3E%20%28schema%29) { bookmark, message, previous\_bookmark } 

POST/accounts/{account\_id}/d1/database/{database\_id}/time\_travel/restore

##### ModelsExpand Collapse 

TimeTravelGetBookmarkResponse { bookmark } 

bookmark?: string

A bookmark representing a specific state of the database at a specific point in time.

TimeTravelRestoreResponse { bookmark, message, previous\_bookmark } 

Response from a time travel restore operation.

bookmark?: string

The new bookmark representing the state of the database after the restore operation.

message?: string

A message describing the result of the restore operation.

previous\_bookmark?: string

The bookmark representing the state of the database before the restore operation. Can be used to undo the restore if needed.