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

# Create a Database

> Create a new database within a database service

# Create a Database

Create a new database within a database service.

## Body Parameters

**name** `string` *required*

Name of the database. Must be unique within the parent service.

**service** `string` *required*

Fully qualified name of the parent DatabaseService.

**displayName** `string`

Human-readable display name for the database.

**description** `string`

Description of the database in Markdown format.

**retentionPeriod** `string`

Data retention period in ISO 8601 duration format, for example `P365D`.

**owners** `array`

Array of owner references (users or teams) to assign to the database.

**properties**

**id** `string`

UUID of the owner entity.

**type** `string`

Type of owner entity, for example `user`, `team`.

**name** `string`

Name of the owner entity.

**domains** `array`

Fully qualified names of the domains to assign for governance purposes.

**tags** `array`

Array of classification tags to apply to the database.

**properties**

**tagFQN** `string` *required*

Fully qualified name of the tag.

**labelType** `string`

Type of label, for example `Manual`, `Derived`, `Propagated`.

**state** `string`

State of the tag, for example `Suggested`, `Confirmed`.

**extension** `object`

Custom property values defined by your organization's metadata schema.

```python POST /v1/databases theme={null}
from metadata.sdk import configure
from metadata.sdk.entities import Databases
from metadata.generated.schema.api.data.createDatabase import CreateDatabaseRequest

configure(
    host="https://your-company.open-metadata.org/api",
    jwt_token="your-jwt-token"
)

request = CreateDatabaseRequest(
    name="analytics",
    displayName="Analytics Database",
    service="snowflake_prod",
    description="Central analytics data warehouse",
    retentionPeriod="P365D"
)

database = Databases.create(request)
print(f"Created: {database.fullyQualifiedName.root}")
```

```java POST /v1/databases theme={null}
import org.openmetadata.schema.entity.data.Database;
import org.openmetadata.sdk.fluent.builders.DatabaseBuilder;

Database database = new DatabaseBuilder(client)
    .name("analytics")
    .serviceFQN("snowflake_prod")
    .create();
```

```bash POST /v1/databases theme={null}
curl -X POST "{base_url}/api/v1/databases" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "default",
    "displayName": "Default Database",
    "service": "mysql_sample",
    "description": "Default MySQL database for sample data",
    "retentionPeriod": "P365D"
  }'
```

```json Response theme={null}
{
  "id": "1d08c2c6-cea7-4adf-9043-0f6a6aaf9721",
  "name": "default",
  "fullyQualifiedName": "mysql_sample.default",
  "displayName": "Default Database",
  "description": "Default MySQL database for sample data",
  "tags": [],
  "version": 0.1,
  "updatedAt": 1769982658682,
  "updatedBy": "admin",
  "href": "http://localhost:8585/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721",
  "owners": [],
  "service": {
    "id": "4724c3cb-d4b8-4ac0-aa55-e8bb66f01ac3",
    "type": "databaseService",
    "name": "mysql_sample",
    "fullyQualifiedName": "mysql_sample",
    "displayName": "mysql_sample",
    "deleted": false,
    "href": "http://localhost:8585/api/v1/services/databaseServices/4724c3cb-d4b8-4ac0-aa55-e8bb66f01ac3"
  },
  "serviceType": "Mysql",
  "retentionPeriod": "P365D",
  "default": false,
  "deleted": false,
  "domains": [],
  "entityStatus": "Unprocessed"
}
```

***

## Returns

Returns the created database object with all specified properties and system-generated fields.

## Response

**id** `string`

Unique identifier for the database (UUID format).

**name** `string`

Database name.

**fullyQualifiedName** `string`

Fully qualified name in format `service.database`.

**displayName** `string`

Human-readable display name.

**description** `string`

Description of the database in Markdown format.

**service** `object`

Reference to the parent database service.

**properties**

**id** `string`

UUID of the database service.

**type** `string`

Type of entity (always `databaseService`).

**name** `string`

Name of the database service.

**serviceType** `string`

Type of database service, for example Snowflake, BigQuery, PostgreSQL.

**retentionPeriod** `string`

Data retention period in ISO 8601 duration format.

**owners** `array`

List of owners assigned to the database.

**properties**

**id** `string`

UUID of the owner entity.

**type** `string`

Type of owner entity, for example `user`, `team`.

**name** `string`

Name of the owner entity.

**domains** `array`

Fully qualified name of the assigned domain.

**tags** `array`

Classification tags applied to the database.

**properties**

**tagFQN** `string`

Fully qualified name of the tag.

**labelType** `string`

Type of label, for example `Manual`, `Derived`, `Propagated`.

**state** `string`

State of the tag, for example `Suggested`, `Confirmed`.

**extension** `object`

Custom property values defined by your organization's metadata schema.

**version** `number`

Version number for the entity (starts at 0.1).

***

## Create or Update (PUT)

Use `PUT /v1/databases` instead of `POST` to perform an upsert. If a database with the same `fullyQualifiedName` already exists, it will be updated; otherwise, a new database is created. The request body is the same as `POST`.

```bash theme={null}
curl -X PUT "{base_url}/api/v1/databases" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{ ... same body as POST ... }'
```

> [!NOTE]
>
> `PUT` will not return a `409` conflict error if the entity already exists -- it will update the existing entity instead.

***

## Bulk Create or Update (PUT)

Use `PUT /v1/databases/bulk` to create or update multiple databases in a single request. The request body is an array of create request objects.

```bash theme={null}
curl -X PUT "{base_url}/api/v1/databases/bulk" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '[
    { "name": "db_one", "service": "mysql_sample" },
    { "name": "db_two", "service": "mysql_sample" }
  ]'
```

***

## Error Handling

| Code | Error Type | Description |
| - | - | - |
| `400` | `BAD_REQUEST` | Invalid request body or missing required fields |
| `401` | `UNAUTHORIZED` | Invalid or missing authentication token |
| `403` | `FORBIDDEN` | User lacks permission to create databases |
| `409` | `ENTITY_ALREADY_EXISTS` | Database with same name already exists in service (POST only) |


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