How to drop a database with MongoDB Atlas API

Hi there,
initially I thought that this is a quick one-liner… :
drop a specific database from an MongoDB Atlas cluster via the API
I have not found anything like this in the docs, a complete cluster can be dropped but this is not the needed use case. Just for completeness, I neither found something with mongocli.
Have I overseen a well hidden option? Any alternatives?

Hi @Michael ,

Dropping a database is a very cautious database operation that needs to be done with an admin user connected to the database.

Giving an option to do that from api is currently out of scope. We want users to own this process by either scripting it via a driver or a mongosh shell.

Now you can easily setup a web service to do that , even by using a MongoDB client on a realm webhook dependency. But providing the credential and securing the logic to avoid accedental drops is on you.


Hi thanks @Pavel_Duchovny
all ok, I have added the alternative to my CI/CD. Just one note: the deletion of a complete cluster is allowed and possible via the api and mongocli …

@Michael This is allowed as part of the provisioning toolset. Since we do not allow database creating via api its not there for deletion

Besides, dropping database have alternative but cluster drop is only via api or ui…

There is no harm in suggesting that via

Hi @Michael,

The Atlas API/UI is used for managing and monitoring clusters, which includes actions like creating and deleting clusters.

To interact with data residing in a cluster you need to use MongoDB client/driver commands (dropDatabase, in this example) or the Atlas Data Explorer.

Cluster-wide Atlas actions intentionally have a different API, access controls, and authentication approach (Atlas Users) than direct data access using Database Users.

I would think of Atlas admin users as analogous to sudo / root access for an on-premises deployment: cluster-level actions can manipulate processes like mongod but cannot remove individual database files from a running process.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.