> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/api-reference/database/schemas/update-database-schema-embed.md).

# Update Database Schema Embed

Saves a schema's embed setting — which fields of each record go into the project's AI knowledge.

Turns AI embedding on or off for one collection. When it is on, the named top-level fields of each record form the text that goes into the project's AI knowledge; the record is embedded again on insert, update and delete. This is a full replace of the setting.

`PUT /{version}/database/schemas/{Id}/embed`

| Field              | Meaning                                                                                                                                                                                                                                                                                                     |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` (required)    | The schema id (`sch_…`).                                                                                                                                                                                                                                                                                    |
| `embed` (required) | `{ enabled, fields, embeddingIntegrationId, perUser }` — `fields`: top-level field names, e.g. `["title", "body"]`; `embeddingIntegrationId`: empty = the project's default embedding integration; `perUser`: `true` = each record's knowledge belongs only to its owner (needs **Records have an owner**). |

The current value is read back on the schema (`embed` on [Get Database Schema](/codemash/api-reference/database/schemas/get-database-schema.md)).

Permission: `database:update` on the schema. AI tool: `update_database_schema_embed`.

{% openapi src="/files/0gOkqzp7kyziG9XPpCBy" path="/{version}/database/schemas/{Id}/embed" method="put" %}
[norbix-hub-swagger.json](https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-7c7445e68689b62620e59cb01a3523deb46b865b%2Fnorbix-hub-swagger.json?alt=media)
{% endopenapi %}

## In Cloud

Schema builder → **Settings** tab → **Embed** (published schemas only) — see [Create a Schema](/codemash/cloud/database/collections/create-schema.md).

## Use it from code

TS `norbix.hub.database.updateDatabaseSchemaEmbed({ id, embed: { enabled: true, fields: ['title', 'body'] } })` · Python `hub.database.update_database_schema_embed(id, embed={…})` · Go `c.Hub.Database.UpdateDatabaseSchemaEmbed(…)` · .NET `UpdateDatabaseSchemaEmbedAsync(new UpdateDatabaseSchemaEmbedRequest { … })`.
