Compose Database-as-a-Service Help and Documentation

Everything you need to know about Compose, Hosted or Enterprise, is here in our help system. Whether you run one database for your businesses' sole application or six different databases to support an entire corporation, we've got the information you need.

MongoDB Users

❗️

This is the older REST API and is now deprecated.

Go to the dedicated apidocs.compose.com for details of the current API which works with all Compose databases with the exception of the MongoDB Classic deployments.

📘

Base URL

All MongoDB user endpoint URLs begin with:

/deployments/:account/:deployment/mongodb/:database

To improve readability, we’ve substituted a . for this string in the descriptions below.

EndpointDescription
GET ./usersList all users
POST ./usersCreate a user
PUT ./users/:userUpdate a user
DELETE ./users/:userDelete a user

Common Parameters

ParamDescription
:accountAn account slug
:deploymentA deployment id or name
:databaseThe name of a database on :deployment
:userThe username of a user in :collection

GET ./users

GET /deployments/:account/:deployment/mongodb/:database/users

Get a list of all the users for your database.

Request

curl -i -X GET 'https://api.compose.io/deployments/your-account/deployment-1/mongodb/database-1/users' \
-H 'Content-Type: application/json' \
-H 'Accept-Version: 2014-06' \
-H 'Authorization: Bearer [OAUTH_TOKEN]'

Response

[
  {
    user: "name",
    pwd: "nonce",
    readOnly: false
  },
  // ...
]

POST ./users

POST /deployments/:account/:deployment/mongodb/:database/users

Creates a user with the proper authorizations on the specified database.

Parameters

NameTypeDescription
usernameStringUsername for the new user
passwordStringPassword for the new user
readOnlyBooleanShould the user only have read access to the database? Defaults to false

Request

curl -i -X POST 'https://api.compose.io/deployments/your-account/deployment-1/mongodb/database-1/users' \
-H 'Content-Type: application/json' \
-H 'Accept-Version: 2014-06' \
-H 'Authorization: Bearer [OAUTH_TOKEN]' \
-d '{"username":"john_smith","password":"super secure","readOnly":true}'

Response

{
  "ok": 1
}

PUT ./users/:user

PUT /deployments/:account/:deployment/mongodb/:database/users/:user

Replaces the user's details with the supplied parameters.

Parameters

NameTypeDescription
passwordStringPassword for the new user
readOnlyBooleanShould the user only have read access to the database?

Request

curl -i -X PUT 'https://api.compose.io/deployments/your-account/deployment-1/mongodb/database-1/users/user-1' \
-H 'Content-Type: application/json' \
-H 'Accept-Version: 2014-06' \
-H 'Authorization: Bearer [OAUTH_TOKEN]' \
-d '{"password":"ok, really secure now"}'

Response

{
  "ok": 1
}

DELETE ./users/:user

DELETE /deployments/:account/:deployment/mongodb/:database/users/:user

Delete a database user.

Request

curl -i -X DELETE 'https://api.compose.io/deployments/your-account/deployment-1/mongodb/database-1/users/user-1' \
-H 'Content-Type: application/json' \
-H 'Accept-Version: 2014-06' \
-H 'Authorization: Bearer [OAUTH_TOKEN]'

Response

{
  "ok": 1
}

Still Need Help?

If this article didn't solve things, summon a human and get some help!

Updated about a year ago

MongoDB Users


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.