Navigation

Get All Database Users

Note

Groups and projects are synonymous terms. Your {GROUP-ID} is the same as your project id. For existing groups, your group/project id remains the same. This page uses the more familiar term group. The endpoints are as stated on the page.

Base URL: https://cloud.mongodb.com/

The Atlas API uses HTTP Digest Authentication. Provide your Atlas username and group API key as the username and password when constructing the HTTP request.

For complete documentation on configuring API access for an Atlas group, see Configure Atlas API Access.

Syntax

GET /api/atlas/v1.0/groups/{GROUP-ID}/databaseUsers

Request Path Parameters

Parameter Required/Optional Description
GROUP-ID Required. The unique identifier for the group.

Request Query Parameters

Field Required/Optional Description
pageNum Optional.

The page to return.

Defaults to 1.

itemsPerPage Optional.

Maximum number of items to return per page.

Defaults to 100.

envelope Optional.

A boolean that specifies whether or not to wrap the response in an envelope.

Defaults to false.

pretty Optional

A boolean that specifies whether or not to return a “pretty-printed” JSON document.

Defaults to false.

Request Body Parameters

This endpoint does not use HTTP request body parameters.

Response Elements

If you set the query element envelope to true, the response is wrapped by the content object.

The HTTP response returns a JSON document that includes the following objects:

results

An array of documents, each representing one MongoDB user.

Name Description
databaseName The user’s authentication database. A user must provide both a username and authentication database to log into MongoDB. In Atlas deployments of MongoDB, the authentication database is always the admin database.
links One or more links to sub-resources and/or related resources.
groupId ID of the Atlas group the user belongs to.
username The username for authenticating to MongoDB.
roles An array of the user’s roles and the database on which the user has each role. A role allows the user to perform particular actions on the specified database. A role on the admin database can include privileges that apply to the other databases as well.
roles.databaseName The database on which the user has the specified role. A role on the admin database can include privileges that apply to the other databases.
roles.collectionName The collection on which the user has the specified role.
roles.roleName

The name of the role. The possible values are:

totalCount

The total number of items in the result set. This value may be higher than the number of objects in the results array if the entire result set is paginated.

Example Request

Request

Important

You must modify the following code block with the appropriate credentials and group ID.

curl -i -u "username:apiKey" --digest "https://cloud.mongodb.com/api/atlas/v1.0/groups/5356823b3794dee37132bb7b/databaseUsers?pretty=true"

Response

HTTP/1.1 200 OK

{
  "links" : [ ... ],
  "results" : [
    {
      "databaseName" : "admin",
      "groupId" : "5356823b3794dee37132bb7b",
      "links" : [ ... ],
      "roles" : [ {
        "databaseName" : "staging",
        "roleName" : "readWrite"
      }, {
        "databaseName" : "production",
        "roleName" : "read"
      } ],
      "username" : "susan"
    },
    ...
  ],
  "totalCount" : 4
}