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

# Get Metadata Schema

> Read the metadata fields declared for a database.

Returns the database's declared metadata fields in `data.fields`, including each field's type and search settings. Use it to check which fields you can send in `metadata` before ingesting or updating context.

```python Python SDK theme={"dark"}
result = client.databases.get_metadata_schema(database="acme_corp")
```

```typescript TypeScript SDK theme={"dark"}
const result = await client.databases.getMetadataSchema({ database: "acme_corp" });
```

```bash cURL theme={"dark"}
curl 'https://api.hydradb.com/databases/acme_corp/metadata-schema' \
  -H "Authorization: Bearer $HYDRA_DB_API_KEY" \
  -H "API-Version: 2"
```

The field definitions have the same shape accepted by [Create Database](/api-reference/v2/endpoint/create-tenant) and [Update Metadata Schema](/api-reference/v2/endpoint/update-metadata-schema). Free-form `additional_metadata` fields are not part of this schema.

## Related resources

* [Update Metadata Schema](/api-reference/v2/endpoint/update-metadata-schema): add fields
* [Metadata guide](/essentials/v2/metadata): declare and filter metadata


## OpenAPI

````yaml api-reference/v2/openapi.json GET /databases/{database}/metadata-schema
openapi: 3.1.0
info:
  contact:
    email: support@hydradb.com
    name: HydraDB Support
  description: >-
    The HydraDB API: ingest context, query it, and manage databases, connectors
    and webhooks.
  license:
    name: Proprietary
  title: HydraDB Application API
  version: 0.1.0
servers:
  - description: Production server
    url: https://api.hydradb.com
security: []
externalDocs:
  description: ''
  url: ''
paths:
  /databases/{database}/metadata-schema:
    get:
      tags:
        - database-management
      summary: Get metadata schema
      description: Get the database metadata schema.
      parameters:
        - description: Database whose metadata schema to read.
          in: path
          name: database
          required: true
          schema:
            example: acme_corp
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/handler.Envelope-tenants_TenantMetadataSchemaResponse
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/handler.ErrorResponse'
          description: Bad Request
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/handler.ErrorResponse'
          description: Not Found
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/handler.ErrorResponse'
          description: Internal Server Error
      security:
        - BearerAuth: []
components:
  schemas:
    handler.Envelope-tenants_TenantMetadataSchemaResponse:
      properties:
        data:
          $ref: '#/components/schemas/tenants.TenantMetadataSchemaResponse'
          example:
            database: acme_corp
            fields:
              - data_type: VARCHAR
                enable_dense_embedding: true
                enable_match: true
                enable_sparse_embedding: false
                max_length: 256
                name: category
            tenant_id: acme_corp
        error:
          anyOf:
            - $ref: '#/components/schemas/handler.apiError'
              title: Error details
            - title: No error
              type: 'null'
          description: Error details on failure, or null on success.
          example: null
        meta:
          $ref: '#/components/schemas/handler.responseMeta'
          example:
            collection: team_docs
            database: acme_corp
            latency_ms: 12.3
            request_id: 9d13aef4-02f4-4e73-8c62-4c2601d04f9d
            source_type: file
            sub_tenant_id: sub_tenant_4567
            tenant_id: tenant_1234
        success:
          description: Whether the request succeeded.
          example: true
          type: boolean
      type: object
    handler.ErrorResponse:
      properties:
        data:
          description: Always `null` on this error response.
        detail:
          $ref: '#/components/schemas/handler.ErrorDetail'
          description: Structured error detail with code, message, and deprecation hints.
          example:
            deprecated: true
            deprecated_field: tenant_id
            error_code: VALIDATION_ERROR
            message: Request validation failed
            preferred_field: database
        error:
          $ref: '#/components/schemas/handler.apiError'
          description: Error message, empty string on success.
          example:
            code: DATABASE_NOT_FOUND
            message: Database not found
        meta:
          $ref: '#/components/schemas/handler.ErrorMeta'
          example:
            latency_ms: 12.3
            request_id: 9d13aef4-02f4-4e73-8c62-4c2601d04f9d
        success:
          description: Whether the request succeeded.
          example: false
          type: boolean
      type: object
    tenants.TenantMetadataSchemaResponse:
      properties:
        database:
          description: >-
            Owning database. Formerly `tenant_id`; the `tenant_id` alias is
            still accepted (deprecated).
          example: acme_corp
          type: string
        fields:
          description: Fields declared in the database metadata schema.
          example:
            - data_type: VARCHAR
              enable_dense_embedding: true
              enable_match: true
              enable_sparse_embedding: false
              max_length: 256
              name: category
          items:
            $ref: '#/components/schemas/tenants.CustomPropertyDefinition'
          type: array
          uniqueItems: false
        tenant_id:
          deprecated: true
          description: 'Deprecated: use `database`.'
          example: acme_corp
          type: string
          x-deprecated: 'true'
      type: object
    handler.apiError:
      properties:
        code:
          description: Machine-readable error code (e.g. `DATABASE_NOT_FOUND`).
          example: DATABASE_NOT_FOUND
          type: string
        details:
          additionalProperties:
            type: string
          description: >-
            Extra facts about the error, as string pairs. Omitted when there are
            none.
          type: object
        message:
          description: Human-readable description of the error.
          example: Database not found
          type: string
        param:
          description: >-
            The request field that caused the error. Omitted when no single
            field is at fault.
          type: string
      type: object
    handler.responseMeta:
      properties:
        api_version:
          description: >-
            Version of the API that served the request, for example `2.0.1`.
            Always present.
          type: string
        collection:
          description: >-
            Collection scope. Defaults to the default collection when omitted.
            Formerly `sub_tenant_id`; the `sub_tenant_id` alias is still
            accepted (deprecated).
          example: team_docs
          type: string
        database:
          description: >-
            Owning database. Formerly `tenant_id`; the `tenant_id` alias is
            still accepted (deprecated).
          example: acme_corp
          type: string
        deprecation:
          description: >-
            Migration notices for this request, present only when it used a
            deprecated route, field or selector. The status code is unaffected.
          items:
            $ref: '#/components/schemas/handler.deprecationNotice'
          type: array
          uniqueItems: false
        latency_ms:
          description: Server-side processing time in milliseconds.
          example: 12.3
          type:
            - number
            - 'null'
        request_id:
          description: Unique identifier for this request, useful for support and tracing.
          example: 9d13aef4-02f4-4e73-8c62-4c2601d04f9d
          type: string
        source_type:
          description: Type of the parent source (e.g. `file`, `slack`, `notion`).
          example: file
          type: string
        sub_tenant_id:
          deprecated: true
          description: 'Deprecated: use `collection`.'
          example: sub_tenant_4567
          type: string
          x-deprecated: 'true'
        tenant_id:
          deprecated: true
          description: 'Deprecated: use `database`.'
          example: tenant_1234
          type: string
          x-deprecated: 'true'
      type: object
    handler.ErrorDetail:
      properties:
        deprecated:
          description: Whether this response concerns a deprecated field or route.
          example: true
          type: boolean
        deprecated_field:
          description: The deprecated field name.
          example: tenant_id
          type: string
        error_code:
          description: Machine-readable error classification code.
          example: VALIDATION_ERROR
          type: string
        message:
          description: Human-readable description of the error.
          example: Request validation failed
          type: string
        preferred_field:
          description: The canonical replacement for the deprecated field.
          example: database
          type: string
        success:
          deprecated: true
          description: >-
            Deprecated: always `false`. Read the HTTP status, then `error.code`
            and `error.message`.
          example: false
          type: boolean
          x-deprecated: 'true'
      type: object
    handler.ErrorMeta:
      properties:
        api_version:
          description: Version of the API that served the request, for example `2.0.1`.
          type: string
        latency_ms:
          description: Server-side processing time in milliseconds.
          example: 12.3
          type: number
        request_id:
          description: Unique identifier for this request, useful for support and tracing.
          example: 9d13aef4-02f4-4e73-8c62-4c2601d04f9d
          type: string
      type: object
    tenants.CustomPropertyDefinition:
      properties:
        data_type:
          allOf:
            - $ref: '#/components/schemas/tenants.MetadataDataType'
          description: Data type of the metadata field, for example `VARCHAR`.
          example: VARCHAR
        enable_dense_embedding:
          description: Whether to enable semantic (dense) embedding search on this field.
          example: true
          type: boolean
        enable_match:
          description: Whether to enable exact-match filtering on this field.
          example: true
          type: boolean
        enable_sparse_embedding:
          description: Whether to enable BM25 (sparse) embedding search on this field.
          example: false
          type: boolean
        max_length:
          description: Maximum string length in bytes for VARCHAR fields.
          example: 256
          type: integer
        name:
          description: Field name. Immutable after database creation.
          example: category
          type: string
      type: object
    handler.deprecationNotice:
      properties:
        deprecated:
          description: Whether this response concerns a deprecated field or route.
          example: true
          type: boolean
        deprecated_field:
          description: The deprecated field name.
          example: tenant_id
          type: string
        deprecated_since:
          description: API version when the field was deprecated.
          example: 2.0.1
          type: string
        message:
          description: Migration guidance message.
          example: tenant_id is deprecated; use database instead.
          type: string
        preferred_field:
          description: The canonical replacement for the deprecated field.
          example: database
          type: string
      type: object
    tenants.MetadataDataType:
      description: >-
        Data type of a metadata field. `ARRAY` cannot be declared on a new
        field: for several values, declare `VARCHAR` and store them
        comma-joined.
      enum:
        - BOOL
        - INT8
        - INT16
        - INT32
        - INT64
        - FLOAT
        - DOUBLE
        - VARCHAR
        - JSON
        - ARRAY
      type: string
      x-enum-varnames:
        - DataTypeBool
        - DataTypeInt8
        - DataTypeInt16
        - DataTypeInt32
        - DataTypeInt64
        - DataTypeFloat
        - DataTypeDouble
        - DataTypeVarchar
        - DataTypeJSON
        - DataTypeArray
  securitySchemes:
    BearerAuth:
      bearerFormat: API key
      description: 'Send your API key as Authorization: Bearer <your_api_key>.'
      scheme: bearer
      type: http

````

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