response = client.databases.update_metadata_schema(
"acme_corp",
add_fields=[
{"name": "region", "data_type": "VARCHAR"},
{"name": "priority", "data_type": "INT64"},
],
)
const response = await client.databases.updateMetadataSchema({
database: "acme_corp",
addFields: [
{ name: "region", dataType: "VARCHAR" },
{ name: "priority", dataType: "INT64" },
],
});
curl -X PATCH 'https://api.hydradb.com/databases/acme_corp/metadata-schema' \
-H "Authorization: Bearer $HYDRADB_API_KEY" \
-H "API-Version: 2" \
-H "Content-Type: application/json" \
-d '{
"add_fields": [
{
"name": "region",
"data_type": "VARCHAR"
},
{
"name": "priority",
"data_type": "INT64"
}
]
}'
{
"database": "acme_corp",
"tenant_id": "acme_corp",
"added_fields": ["region", "priority"]
}
{
"success": false,
"data": null,
"error": {
"code": "INTERNAL_ERROR",
"message": "Schema conflict: field \"region\" already exists in the schema with a different definition. Resubmitting a field with its existing definition is accepted as a no-op, but an existing field cannot be modified. See https://docs.hydradb.com/api-reference/v2/endpoint/patch-metadata-schema for usage details. Re-send the field with its existing definition to make this a no-op, or use a different field name."
},
"meta": {
"request_id": "9d13aef4-02f4-4e73-8c62-4c2601d04f9d",
"latency_ms": 4.8
}
}
Databases
Update Metadata Schema
Add new database metadata schema fields after database creation.
PATCH
/
databases
/
{database}
/
metadata-schema
response = client.databases.update_metadata_schema(
"acme_corp",
add_fields=[
{"name": "region", "data_type": "VARCHAR"},
{"name": "priority", "data_type": "INT64"},
],
)
const response = await client.databases.updateMetadataSchema({
database: "acme_corp",
addFields: [
{ name: "region", dataType: "VARCHAR" },
{ name: "priority", dataType: "INT64" },
],
});
curl -X PATCH 'https://api.hydradb.com/databases/acme_corp/metadata-schema' \
-H "Authorization: Bearer $HYDRADB_API_KEY" \
-H "API-Version: 2" \
-H "Content-Type: application/json" \
-d '{
"add_fields": [
{
"name": "region",
"data_type": "VARCHAR"
},
{
"name": "priority",
"data_type": "INT64"
}
]
}'
{
"database": "acme_corp",
"tenant_id": "acme_corp",
"added_fields": ["region", "priority"]
}
{
"success": false,
"data": null,
"error": {
"code": "INTERNAL_ERROR",
"message": "Schema conflict: field \"region\" already exists in the schema with a different definition. Resubmitting a field with its existing definition is accepted as a no-op, but an existing field cannot be modified. See https://docs.hydradb.com/api-reference/v2/endpoint/patch-metadata-schema for usage details. Re-send the field with its existing definition to make this a no-op, or use a different field name."
},
"meta": {
"request_id": "9d13aef4-02f4-4e73-8c62-4c2601d04f9d",
"latency_ms": 4.8
}
}
Adds fields to a database’s metadata schema after creation. The call is additive only: it cannot delete or rename fields, change the type or flags of an existing field, or add dense or sparse search fields. Get Metadata Schema returns the current schema in the same field shape.
Each
Apart from a malformed body and a missing database, this endpoint currently returns
response = client.databases.update_metadata_schema(
"acme_corp",
add_fields=[
{"name": "region", "data_type": "VARCHAR"},
{"name": "priority", "data_type": "INT64"},
],
)
const response = await client.databases.updateMetadataSchema({
database: "acme_corp",
addFields: [
{ name: "region", dataType: "VARCHAR" },
{ name: "priority", dataType: "INT64" },
],
});
curl -X PATCH 'https://api.hydradb.com/databases/acme_corp/metadata-schema' \
-H "Authorization: Bearer $HYDRADB_API_KEY" \
-H "API-Version: 2" \
-H "Content-Type: application/json" \
-d '{
"add_fields": [
{
"name": "region",
"data_type": "VARCHAR"
},
{
"name": "priority",
"data_type": "INT64"
}
]
}'
{
"database": "acme_corp",
"tenant_id": "acme_corp",
"added_fields": ["region", "priority"]
}
{
"success": false,
"data": null,
"error": {
"code": "INTERNAL_ERROR",
"message": "Schema conflict: field \"region\" already exists in the schema with a different definition. Resubmitting a field with its existing definition is accepted as a no-op, but an existing field cannot be modified. See https://docs.hydradb.com/api-reference/v2/endpoint/patch-metadata-schema for usage details. Re-send the field with its existing definition to make this a no-op, or use a different field name."
},
"meta": {
"request_id": "9d13aef4-02f4-4e73-8c62-4c2601d04f9d",
"latency_ms": 4.8
}
}
Request body
| Name | Description |
|---|---|
| New metadata schema fields to append. Must contain at least one field. A field that already exists with an identical definition is skipped, so you can resend your full field list. |
add_fields[] item uses the same field shape as database_metadata_schema on Create Database:
| Field | Description |
|---|---|
| New metadata key. Must start with a letter, contain only letters, numbers, and underscores (up to 255 characters), and not be a reserved system name. | |
VARCHAR, BOOL, INT8, INT16, INT32, INT64, FLOAT, DOUBLE, JSON, or friendly aliases such as string, integer, float, boolean, object. Defaults to VARCHAR. ARRAY is not supported and is rejected with 400; for multi-value fields declare VARCHAR and store the values comma-joined. | |
Max length for VARCHAR. Default 1024; maximum 65535. | |
Rejected with 400 on a new field. Dense semantic-search fields can only be declared at database creation. | |
Rejected with 400 on a new field. Sparse keyword-search fields can only be declared at database creation. |
Rules
- Conflicts: An existing field name cannot be reused with a different definition, case-insensitively. A field that differs from the existing one in type,
max_length, or flags returns409, as does one name declared twice in a request with different definitions. - Resending: A field resent with its identical definition is a no-op, including an existing field that already has dense or sparse flags.
- Field limit: A database can have at most 32 custom metadata fields. Skipped fields do not count toward the new total.
- Reserved names: Names such as
source_id,chunk_id,metadata, anddocument_metadataare rejected.
Response
A success returnsdatabase, the deprecated tenant_id, and added_fields directly, without the success/data envelope. added_fields lists only the fields this call added, so an empty list means the database already had everything you sent. Errors use the standard error envelope.
Errors
| Status | When it happens |
|---|---|
400 | Invalid request body (INVALID_INPUT), empty add_fields, invalid field name or type, ARRAY, too many fields, or an embedding flag on a new field. |
404 | Database not found (DATABASE_NOT_FOUND). |
409 | A field conflicts with an existing field or with another entry in the same request, or the database changed during the request (retry this last case). |
500 | Saving the schema failed. Retry. |
error.code: "INTERNAL_ERROR" for 400, 409, and 500 alike. Branch on the HTTP status and read error.message, which names the field and the rule it broke.
Related resources
- Before this: Get Metadata Schema: read the current fields
- Before this: Create Database: declare the initial schema, including dense and sparse search fields
- After this: Ingest Context: send values for the new fields in
metadata - After this: Query: filter on the new fields with
metadata_filters - Guide: Metadata Filters
Authorizations
Body
application/json
Metadata schema fields to add
New metadata fields to add to the database schema. Additive only: no deletes, renames or type changes.
Show child attributes
Show child attributes
Example:
[ { "data_type": "VARCHAR", "enable_dense_embedding": true, "enable_match": true, "enable_sparse_embedding": false, "max_length": 256, "name": "category" } ]
Response
OK
Was this page helpful?
