Skip to main content

DB Viewer - Indexes Read

Endpoint

/o/db?db=countly&collection=members&action=get_indexes

Overview

Returns index definitions for the selected MongoDB collection.

Authentication

Countly API supports three authentication methods:

  1. api_key=YOUR_API_KEY
  2. auth_token=YOUR_AUTH_TOKEN
  3. countly-token: YOUR_AUTH_TOKEN

Permissions

Requires DB Viewer access (dbviewer read right for app-scoped users).

Request Parameters

ParameterTypeRequiredDescription
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.
db / dbsStringYesMongoDB database name.
collectionStringYesCollection name.
actionStringYesMust be get_indexes.

Response

Success Response

{
"limit": 3,
"start": 1,
"end": 3,
"total": 3,
"pages": 1,
"curPage": 1,
"collections": [
{
"v": 2,
"key": {"_id": 1},
"name": "_id_"
}
]
}

Response Fields

FieldTypeDescription
limitNumberCount of returned index definitions.
startNumberAlways 1 in this endpoint output.
endNumberLast index row number.
totalNumberTotal index count.
pagesNumberAlways 1 for this output shape.
curPageNumberAlways 1.
collectionsArrayIndex definitions from MongoDB collection.indexes().

Error Responses

  • 401
{
"result": "User does not have right to view this collection"
}
  • 404
{
"result": "Database not found."
}

On index-read failure, this handler returns raw string output:

"Somethings went wrong"

Behavior/Processing

  • Runs only when action=get_indexes with db and collection provided.
  • Uses MongoDB collection.indexes() and wraps results in DB Viewer pagination envelope.
  • Access is checked per collection for non-admin users.

Database Collections

This endpoint reads index metadata from the selected MongoDB collection.

Examples

Read indexes for a collection

/o/db?api_key=YOUR_API_KEY&db=countly&collection=members&action=get_indexes

Last Updated

2026-03-07