---
title: Undelete D1 Database
---

[Skip to content](#_top)

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

[D1](https://developers.cloudflare.com/api/resources/d1)

[Database](https://developers.cloudflare.com/api/resources/d1/subresources/database)

Copy Markdown

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

---

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

# Undelete D1 Database

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

Restore a deleted D1 database. The database is restored with the name it had when it was deleted, unless `new_name` is provided. The restored database counts against the account’s limits. Undeleting a database that is not deleted succeeds without changes, unless `new_name` differs from its current name which errors. A database can only be undeleted within 7 days (7 \* 24 hours) of its deletion.

Once a database is undeleted, Time Travel (point-in-time recovery) cannot restore it to a bookmark or timestamp at or before the undeletion. Only states after the undeletion can be restored.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**<code>X-Auth-Email: user@example.com</code>

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### P ath ParametersExpand Collapse

account\_id: string

Account identifier tag.

maxLength32

[Link to this property](<#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(params)%20default%20%3E%20(param)%20account_id%20%3E%20(schema)>)

database\_id: string

D1 database identifier (UUID).

[Link to this property](<#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(params)%20default%20%3E%20(param)%20database_id%20%3E%20(schema)>)

##### Body ParametersJSONExpand Collapse

new\_name: optional string

Restore the database with this name instead of the name it had when it was deleted. Required if another database in the account already uses that name.

[Link to this property](<#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(params)%200%20%3E%20(param)%20new_name%20%3E%20(schema)>)

##### ReturnsExpand Collapse

<details>

<summary>

errors: array of <a href="https://developers.cloudflare.com/api/resources/$shared#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)">ResponseInfo</a> { code, message, documentation\_url, source }

</summary>

code: number

minimum1000

<a href="#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)%20%3E%20(property)%20code">Link to this property</a>

message: string

<a href="#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)%20%3E%20(property)%20message">Link to this property</a>

documentation\_url: optional string

<a href="#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)%20%3E%20(property)%20documentation_url">Link to this property</a>

<details>

<summary>

source: optional object {pointer }

</summary>

pointer: optional string

<a href="#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(property)%20pointer">Link to this property</a>

</details>

<a href="#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)%20%3E%20(property)%20source">Link to this property</a>

</details>

[Link to this property](<#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20errors>)

<details>

<summary>

messages: array of <a href="https://developers.cloudflare.com/api/resources/$shared#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)">ResponseInfo</a> { code, message, documentation\_url, source }

</summary>

code: number

minimum1000

<a href="#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)%20%3E%20(property)%20code">Link to this property</a>

message: string

<a href="#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)%20%3E%20(property)%20message">Link to this property</a>

documentation\_url: optional string

<a href="#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)%20%3E%20(property)%20documentation_url">Link to this property</a>

<details>

<summary>

source: optional object {pointer }

</summary>

pointer: optional string

<a href="#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)%20%3E%20(property)%20source%20%3E%20(property)%20pointer">Link to this property</a>

</details>

<a href="#(resource)%20%24shared%20%3E%20(model)%20response_info%20%3E%20(schema)%20%3E%20(property)%20source">Link to this property</a>

</details>

[Link to this property](<#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20messages>)

<details>

<summary>

result: <a href="https://developers.cloudflare.com/api/resources/d1#(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)">D1</a> { created\_at, file\_size, jurisdiction, 5 more }

The details of the D1 database.

</summary>

created\_at: optional string

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

formatdate-time

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20created_at">Link to this property</a>

file\_size: optional number

The D1 database’s size, in bytes.

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(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: optional "eu"or "fedramp"or "us"

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:

"eu"

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(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>

"fedramp"

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(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>

"us"

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(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.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20jurisdiction">Link to this property</a>

name: optional string

D1 database name.

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

Deprecatednum\_tables: optional number

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

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20num_tables">Link to this property</a>

<details>

<summary>

read\_replication: optional object {mode }

Configuration for D1 read replication.

</summary>

<details>

<summary>

mode: "auto"or "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.

</summary>

One of the following:

"auto"

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(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>

"disabled"

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(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.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(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.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20read_replication">Link to this property</a>

uuid: optional string

D1 database identifier (UUID).

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20d1%20%3E%20(model)%20d1%20%3E%20(schema)%20%3E%20(property)%20uuid">Link to this property</a>

version: optional string

<a href="#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(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.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20result>)

success: true

Whether the API call was successful

[Link to this property](<#(resource)%20d1.database%20%3E%20(method)%20undelete%20%3E%20(network%20schema)%20%3E%20(property)%20success>)

### Undelete D1 Database

HTTP

HTTPTypeScriptPythonGoTerraform

```
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/d1/database/$DATABASE_ID/undelete \
    -X POST \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
```

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "created_at": "2022-11-15T18:25:44.442097Z",
    "file_size": 12,
    "jurisdiction": "eu",
    "name": "my-database",
    "num_tables": 12,
    "read_replication": {
      "mode": "auto"
    },
    "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "version": "production"
  },
  "success": true
}
```

##### Returns Examples

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "created_at": "2022-11-15T18:25:44.442097Z",
    "file_size": 12,
    "jurisdiction": "eu",
    "name": "my-database",
    "num_tables": 12,
    "read_replication": {
      "mode": "auto"
    },
    "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "version": "production"
  },
  "success": true
}
```