> ## Documentation Index
> Fetch the complete documentation index at: https://www.unkey.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Unkey is two separate products. Compute builds, deploys, and runs apps behind a gateway. API Management issues API keys, enforces rate limits, manages identities and permissions, and reports usage. Say which product a page belongs to; a reader can use either without the other.
> Every Unkey API endpoint is an HTTP POST to https://api.unkey.com/v2/{service}.{procedure} with a root key in the Authorization: Bearer header. Root keys are workspace scoped.
> Error codes have the form err:{system}:{category}:{specific} and each has a page at /errors/{system}/{category}/{specific}.
> The word environment means production or preview in Compute. Rate limiting has four meanings on this site; the glossary lists them.

# database_already_exists

> The database is already connected to the project, or PlanetScale already has a database with that name.

> [!CAUTION]
>
> `err:unkey:data:database_already_exists`

The database you asked for already exists where you tried to add it. You get HTTP 409.

```json Example response theme={"system"}
{
  "meta": {
    "requestId": "req_2c9a0jf23l4k567"
  },
  "error": {
    "detail": "The database is already connected to this project.",
    "status": 409,
    "title": "Conflicting Resource",
    "type": "/errors/unkey/data/database_already_exists"
  }
}
```

## Likely causes

* `databases.connectDatabase`: the project already has this PlanetScale database.
* `databases.createDatabase`: the PlanetScale organization already has a database with this name.

## How to fix

1. For `databases.connectDatabase`, list the databases of the project with `databases.listDatabases`. The database is already there, so there's nothing to connect. To connect an environment to it, use its `id` with `connections.createConnection`.
2. For `databases.createDatabase`, choose another name. If the existing database is yours, connect it with `databases.connectDatabase` instead.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.