Skip to main content
PUT/metadata/index/{collection}

Declare Metadata Index

Replace index by collection. (Data, Queries & Vectors) PUT /@:projectSlug/metadata/index/{collection}.

Parameters
collection *path

The collection's name.

projectSlug *path

The project's slug: the path segment after @.

It is unique within the org.

Request body
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 id.

No column may repeat.

indexedboolean

Mark the column indexed.

Default false.

Refused on a protected (encrypted) column.

Responses
HTTPK9O CodeDescription
200Success
400K9O_INVALID_FIELD_VALUEThe body is malformed: an unknown field, a wrong type, or an unsupported where operator.
401K9O_INVALID_CREDENTIALSThe caller is not authenticated.
403K9O_ACCESS_DENIEDThe caller has no role in this project.
403K9O_IAM_POLICY_DENIEDThe caller lacks migrations:run (declaring metadata columns is a schema act), or is the playground operator.
403K9O_EXTENSION_PERMISSION_DENIEDAn extension token: the Metadata API is not extension-callable yet.
404K9O_COLLECTION_NOT_FOUNDNo such collection in this project.
Response body (200)
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 indexed.

meta *any

Request metadata (request id, trace id, timing and cost) plus cursor.next: pass it as cursor to read the next page, or null when there is no next page.

TypeScript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.metadata.index.declare('<collection>', {})

Showing example in TypeScript

Request example
{
  "columns": [
    {
      "column": "string",
      "indexed": false
    }
  ]
}
Response example (200)
{
  "data": {
    "collection": "string",
    "columns": [
      {
        "column": "string",
        "indexed": false
      }
    ]
  }
}

More in Data, Queries & Vectors