---
title: D1
---

[Skip to content](#_top)

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

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# D1

##### ModelsExpand Collapse

<details>

<summary>

type D1 struct{…}

The details of the D1 database.

</summary>

CreatedAt TimeOptional

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

formatdate-time

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20created_at">Link to this property</a>

FileSize float64Optional

The D1 database’s size, in bytes.

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20file_size">Link to this property</a>

<details>

<summary>

Jurisdiction D1JurisdictionOptional

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

</summary>

One of the following:

const D1JurisdictionEu D1Jurisdiction = "eu"

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%200">Link to this property</a>

const D1JurisdictionFedramp D1Jurisdiction = "fedramp"

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%201">Link to this property</a>

const D1JurisdictionUs D1Jurisdiction = "us"

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%202">Link to this property</a>

</details>

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20jurisdiction">Link to this property</a>

Name stringOptional

D1 database name.

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

DeprecatedNumTables float64Optional

The number of tables in the D1 database. This count is no longer accurate and should not be relied upon.

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20num_tables">Link to this property</a>

<details>

<summary>

ReadReplication D1ReadReplicationOptional

Configuration for D1 read replication.

</summary>

<details>

<summary>

Mode D1ReadReplicationMode

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.

</summary>

One of the following:

const D1ReadReplicationModeAuto D1ReadReplicationMode = "auto"

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20read_replication%20%3E%20(property)%20mode%20%3E%20(member)%200">Link to this property</a>

const D1ReadReplicationModeDisabled D1ReadReplicationMode = "disabled"

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20read_replication%20%3E%20(property)%20mode%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20read_replication%20%3E%20(property)%20mode">Link to this property</a>

</details>

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20read_replication">Link to this property</a>

UUID stringOptional

D1 database identifier (UUID).

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20uuid">Link to this property</a>

Version stringOptional

<a href="#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20version">Link to this property</a>

</details>

[Link to this property](<#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)>)

#### D1Database

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

client.D1.Database.List(ctx, params) (\*V4PagePaginationArray\[[DatabaseListResponse](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1.database%20%3E%20(model)%20DatabaseListResponse%20%3E%20(schema)>)], error)

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

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

client.D1.Database.Get(ctx, databaseID, params) (\*[D1](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)>), error)

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

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

client.D1.Database.New(ctx, params) (\*[D1](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)>), error)

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

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

client.D1.Database.Update(ctx, databaseID, params) (\*[D1](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)>), error)

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

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

client.D1.Database.Edit(ctx, databaseID, params) (\*[D1](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)>), error)

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

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

client.D1.Database.Delete(ctx, databaseID, body) (\*[DatabaseDeleteResponse](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1.database%20%3E%20(model)%20DatabaseDeleteResponse%20%3E%20(schema)>), error)

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

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

client.D1.Database.Query(ctx, databaseID, params) (\*SinglePage\[[QueryResult](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)>)], error)

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

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

client.D1.Database.Raw(ctx, databaseID, params) (\*SinglePage\[[DatabaseRawResponse](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1.database%20%3E%20(model)%20DatabaseRawResponse%20%3E%20(schema)>)], error)

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

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

client.D1.Database.Export(ctx, databaseID, params) (\*[DatabaseExportResponse](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1.database%20%3E%20(model)%20DatabaseExportResponse%20%3E%20(schema)>), error)

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

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

client.D1.Database.Import(ctx, databaseID, params) (\*[DatabaseImportResponse](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1.database%20%3E%20(model)%20DatabaseImportResponse%20%3E%20(schema)>), error)

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

##### ModelsExpand Collapse

<details>

<summary>

type QueryResult struct{…}

</summary>

<details>

<summary>

Meta QueryResultMetaOptional

</summary>

ChangedDB boolOptional

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

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20changed_db">Link to this property</a>

Changes float64Optional

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

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20changes">Link to this property</a>

Duration float64Optional

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

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20duration">Link to this property</a>

LastRowID float64Optional

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

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20last_row_id">Link to this property</a>

RowsRead float64Optional

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

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20rows_read">Link to this property</a>

RowsWritten float64Optional

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

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20rows_written">Link to this property</a>

ServedByColo stringOptional

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

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20served_by_colo">Link to this property</a>

ServedByPrimary boolOptional

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

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20served_by_primary">Link to this property</a>

<details>

<summary>

ServedByRegion QueryResultMetaServedByRegionOptional

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

</summary>

One of the following:

const QueryResultMetaServedByRegionWnam QueryResultMetaServedByRegion = "WNAM"

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20served_by_region%20%3E%20(member)%200">Link to this property</a>

const QueryResultMetaServedByRegionEnam QueryResultMetaServedByRegion = "ENAM"

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20served_by_region%20%3E%20(member)%201">Link to this property</a>

const QueryResultMetaServedByRegionWeur QueryResultMetaServedByRegion = "WEUR"

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20served_by_region%20%3E%20(member)%202">Link to this property</a>

const QueryResultMetaServedByRegionEeur QueryResultMetaServedByRegion = "EEUR"

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20served_by_region%20%3E%20(member)%203">Link to this property</a>

const QueryResultMetaServedByRegionApac QueryResultMetaServedByRegion = "APAC"

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20served_by_region%20%3E%20(member)%204">Link to this property</a>

const QueryResultMetaServedByRegionOc QueryResultMetaServedByRegion = "OC"

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20served_by_region%20%3E%20(member)%205">Link to this property</a>

</details>

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20served_by_region">Link to this property</a>

SizeAfter float64Optional

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

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20size_after">Link to this property</a>

<details>

<summary>

Timings QueryResultMetaTimingsOptional

Various durations for the query.

</summary>

SqlDurationMs float64Optional

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

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20timings%20%3E%20(property)%20sql_duration_ms">Link to this property</a>

</details>

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta%20%3E%20(property)%20timings">Link to this property</a>

</details>

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20meta">Link to this property</a>

Results \[]unknownOptional

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20results">Link to this property</a>

Success boolOptional

<a href="#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)%20%3E%20(property)%20success">Link to this property</a>

</details>

[Link to this property](<#(resource)%20d1.database%20%3E%20(model)%20query_result%20%3E%20(schema)>)

#### D1DatabaseTime Travel

##### [Get D1 database bookmark](https://developers.cloudflare.com/api/go/resources/d1/subresources/database/subresources/time_travel/methods/get_bookmark)

client.D1.Database.TimeTravel.GetBookmark(ctx, databaseID, params) (\*[DatabaseTimeTravelGetBookmarkResponse](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1.database.time_travel%20%3E%20(model)%20DatabaseTimeTravelGetBookmarkResponse%20%3E%20(schema)>), error)

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/go/resources/d1/subresources/database/subresources/time_travel/methods/restore)

client.D1.Database.TimeTravel.Restore(ctx, databaseID, params) (\*[DatabaseTimeTravelRestoreResponse](<https://developers.cloudflare.com/api/go/resources/d1#(resource)%20d1.database.time_travel%20%3E%20(model)%20DatabaseTimeTravelRestoreResponse%20%3E%20(schema)>), error)

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