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.
Endpoint | Description |
---|---|
GET ./users | List all users |
POST ./users | Create a user |
PUT ./users/:user | Update a user |
DELETE ./users/:user | Delete a user |
Common Parameters
Param | Description |
---|---|
:account | An account slug |
:deployment | A deployment id or name |
:database | The name of a database on :deployment |
:user | The 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
Name | Type | Description |
---|---|---|
username | String | Username for the new user |
password | String | Password for the new user |
readOnly | Boolean | Should 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
Name | Type | Description |
---|---|---|
password | String | Password for the new user |
readOnly | Boolean | Should 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