Docs
Get started

API

Database users

The MongoDB users your application signs in to a database with.

On this page

The examples use the two shell variables from Authentication:

Shell
export FENVIX_API=https://api.fenvix.dev/v1/public
export FENVIX_KEY="$(read_from_your_secret_store)"   # never written in a command

List a database's users#

GET /databases/{id}/users

Works with an admin or a read_only key.

Shell
curl -sS "$FENVIX_API/databases/$DATABASE_ID/users" \
  -H "Authorization: Bearer $FENVIX_KEY"

Parameters#

Name In Required Type Notes
id path yes string —
cursor query no string The nextCursor of the previous page.
limit query no integer Default 20.

Answers#

Status Body Meaning
200 object A page of users, by name. Never a password.
401 Error No key, or the key is not valid, has expired or has been revoked.
404 Error No such database.
429 Error Too many requests. Wait for the number of seconds in Retry-After.
503 Error Database users are not available on this deployment yet.

Create a database user#

POST /databases/{id}/users

Needs an admin key. Accepts Idempotency-Key.

The password is in this answer only. Repeating the request with the same Idempotency-Key answers 409 and makes nothing.

Shell
curl -sS -X POST "$FENVIX_API/databases/$DATABASE_ID/users" \
  -H "Authorization: Bearer $FENVIX_KEY" \
  -H "Content-Type: application/json" \
  -d '{"username":"reporting"}'

Parameters#

Name In Required Type Notes
id path yes string —
Idempotency-Key header no string Repeat a request safely for 24 hours. See the Idempotency section.

Request body#

Field Required Type Notes
username yes string Pattern ^[a-z][a-z0-9_-]{2,31}$.
role no string (readWrite, read) Default readWrite.

Answers#

Status Body Meaning
201 CreatedDatabaseUser Created.
400 Error The request is not valid; field names the part that is not.
401 Error No key, or the key is not valid, has expired or has been revoked.
403 Error The key is read only.
404 Error No such database.
409 Error Conflict: the name is taken, the database is busy, or the Idempotency-Key was used for another request.
429 Error Too many requests. Wait for the number of seconds in Retry-After.
503 Error Database users are not available on this deployment yet.

Delete a database user#

DELETE /databases/{id}/users/{username}

Needs an admin key. Accepts Idempotency-Key.

Shell
curl -sS -X DELETE "$FENVIX_API/databases/$DATABASE_ID/users/$DB_USERNAME" \
  -H "Authorization: Bearer $FENVIX_KEY"

Parameters#

Name In Required Type Notes
id path yes string —
username path yes string —
Idempotency-Key header no string Repeat a request safely for 24 hours. See the Idempotency section.

Answers#

Status Body Meaning
200 object Deleted.
400 Error The request is not valid; field names the part that is not.
401 Error No key, or the key is not valid, has expired or has been revoked.
403 Error The key is read only.
404 Error No such database or user.
409 Error Conflict: the name is taken, the database is busy, or the Idempotency-Key was used for another request.
429 Error Too many requests. Wait for the number of seconds in Retry-After.
503 Error Database users are not available on this deployment yet.