/metadata/index/{collection}Declare Metadata Index
Replace index by collection. (Data, Queries & Vectors) PUT /@:projectSlug/metadata/index/{collection}.
| collection * | path | The collection's name. |
| projectSlug * | path | The project's slug: the path segment after It is unique within the org. |
| columns * | object[] | The full declaration: it replaces any earlier one. At most 64 columns; an empty array clears it. |
| column * | string | An existing column of the collection, other than No column may repeat. |
| indexed | boolean | Mark the column indexed. Default false. Refused on a protected (encrypted) column. |
| HTTP | K9O Code | Description |
|---|---|---|
| 200 | Success | |
| 400 | K9O_INVALID_FIELD_VALUE | The body is malformed: an unknown field, a wrong type, or an unsupported where operator. |
| 401 | K9O_INVALID_CREDENTIALS | The caller is not authenticated. |
| 403 | K9O_ACCESS_DENIED | The caller has no role in this project. |
| 403 | K9O_IAM_POLICY_DENIED | The caller lacks migrations:run (declaring metadata columns is a schema act), or is the playground operator. |
| 403 | K9O_EXTENSION_PERMISSION_DENIED | An extension token: the Metadata API is not extension-callable yet. |
| 404 | K9O_COLLECTION_NOT_FOUND | No such collection in this project. |
| data * | object | The collection's metadata column declaration. |
| collection * | string | The collection name. |
| columns * | object[] | The declared metadata columns. The GET lists them by column name; the PUT echoes them in the order sent. Empty when none are declared. |
| column * | string | A column of the collection declared as metadata. |
| indexed * | boolean | Whether the column was declared |
| meta * | any | Request metadata (request id, trace id, timing and cost) plus |
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.metadata.index.declare('<collection>', {})Showing example in TypeScript
{
"columns": [
{
"column": "string",
"indexed": false
}
]
}{
"data": {
"collection": "string",
"columns": [
{
"column": "string",
"indexed": false
}
]
}
}