Skip to main content

DB Viewer - Document Read

Endpoint​

/o/db?db=countly&collection=members&document=507f1f77bcf86cd799439011

Overview​

Reads a single document by _id from the selected collection.

Authentication​

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

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 / dbsStringYesDatabase name.
collectionStringYesCollection name.
documentStringYes_id value. If it is a valid ObjectId string, backend converts it to ObjectId automatically.

Examples​

Read one member document​

/o/db?api_key=YOUR_API_KEY&db=countly&collection=members&document=507f1f77bcf86cd799439011

Response​

Success Response​

{
"_id": "ObjectId(507f1f77bcf86cd799439011)",
"name": "Test User",
"email": "user@example.com"
}

If not found:

{}

Response Fields​

FieldTypeDescription
(root)ObjectFull document object if found, otherwise empty object.

Error Responses​

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

Behavior​

  • If document is ObjectId-like, backend converts it to ObjectId before lookup.
  • For members collection, password and api_key are removed.
  • For auth_tokens collection, _id is redacted to ***redacted***.
  • ObjectId-like values in response are rendered as ObjectId(...) strings.
Implementation details

Database Collections

This endpoint reads from the selected db.collection.