> 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/collections/get-collection-indexes.md).

# Get Collection Indexes

Lists the index key patterns of a collection (read-only).

**Hub only.** Lists the MongoDB indexes of one collection, so you can check which fields are indexed before sorting or filtering on them. Read-only — indexes are created on the MongoDB side.

`GET /{version}/database/collections/{collectionName}/indexes`

The answer's `indexes` is a list of `{ name, keys: [{ field, order }] }` (`order` is `1` ascending or `-1` descending). A sort on a field is fast only when the field is the **first** key of an index.

Permission: `database:read` on the collection. AI tool: `get_collection_indexes`.

{% openapi src="/files/0gOkqzp7kyziG9XPpCBy" path="/{version}/database/collections/{collectionName}/indexes" method="get" %}
[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

The schema builder's **List** tab uses this list to mark slow sort columns — see [Schema Indexes](/codemash/cloud/database/collections/schema-indexes.md).

## Use it from code

TS `norbix.hub.database.getCollectionIndexes({ collectionName: 'orders' })` · Python `hub.database.get_collection_indexes("orders")` · Go `c.Hub.Database.GetCollectionIndexes(ctx, "orders", nil, &out)` · .NET `GetCollectionIndexesAsync(new GetCollectionIndexes { CollectionName = "orders" })` · CLI `norbix db indexes orders`.
