Atlas
MongoDB Developer Center
chevron-right
Developer Topics
chevron-right
Products
chevron-right
Atlas
chevron-right

Automate the Automation on MongoDB Atlas

Cassiano Ziegler BeinPublished Oct 12, 2021 • Updated May 13, 2022
Postman APIAtlas
facebook icontwitter iconlinkedin icon
random alt
Rate this article
star-empty
star-empty
star-empty
star-empty
star-empty
MongoDB Atlas is an awesome Cloud Data Platform providing an immense amount of automation to set up your databases, data lakes, charts, full-text search indexes, and more across all major cloud providers around the globe. Through the MongoDB Atlas GUI, you can easily deploy a fully scalable global cluster across several regions and even across different cloud providers in a matter of minutes. That's what I call automation. Using the MongoDB GUI is super intuitive and great, but how can I manage all these features in my own way?
The answer is simple and you probably already know it….APIs!
Did I hear API?
MongoDB Atlas has a full featured API which allows users to programmatically manage all Atlas has to offer.
The main idea is to enable users to integrate Atlas with all other aspects of your Software Development Life Cycle (SDLC), giving the ability for your DevOps team to create automation on their current processes across all their environments (Dev, Test/QA, UAT, Prod).
One example would be the DevOps teams leveraging APIs on the creation of ephemeral databases to run their CI/CD processes in lower environments for test purposes. Once it is done, you would just terminate the database deployment.
Another example we have seen DevOps teams using is to incorporate the creation of the databases needed into their Developers Portals. The idea is to give developers a self-service experience, where they can start a project by using a portal to provide all project characteristics (tech stack according to their coding language, app templates, etc.), and the portal will create all the automation to provide all aspects needed, such as a new code repo, CI/CD job template, Dev Application Servers, and a MongoDB database. So, they can start coding as soon as possible!
Even though the
MongoDB Atlas API Resources documentation
is great with lots of examples using cURL, we thought developers would appreciate it if they could also have all these in one of their favorite tools to work with APIs. I am talking about
Postman
, an API platform for building and using APIs. So, we did it! Below you will find step-by-step instructions on how to use it.
Step 1: Configure your workstation/laptop
  • Download
    and install Postman on your workstation/laptop.
  • Training
    on Postman is available if you need a refresher on how to use it.
Step 2: Configure MongoDB Atlas
  • Create a free
    MongoDB Atlas account
    to have access to a free cluster to play around in. Make sure you create an organization and a project. Don't skip that step. Here is a coupon code—GOATLAS10—for some credits to explore more features (valid as of August 2021). Watch this
    video
    to learn how to add these credits to your account.
  • Create an
    API key
    with Organization Owner privileges and save the public/private key to use when calling APIs. Also, don't forget to add your laptop/workstation IP to the API access list.
  • Create a
    database deployment
    (cluster) via the Atlas UI or the MongoDB CLI (check out the
    MongoDB CLI Atlas Quick Start
    for detailed instructions). Note that a free database deployment will allow you to run most of the API calls. Use an M10 database deployment or higher if you want to have full access to all of the APIs. Feel free to explore all of the other database deployment options, but the default options should be fine for this example.
  • Navigate to your Project Settings and retrieve your Project ID so it can be used in one of our examples below.
Finding your Project ID on MongoDB Atlas
Step 3: Configure and use Postman
  • Fork or Import the MongoDB Atlas Collection to your Postman Workspace:
    Run in Postman
  • Click on the MongoDB Atlas Collection. Under the Authorization tab, choose the Digest Auth Type and use the public key as the user and the private key as your password.
Configuring Authorization on Postman using MongoDB Atlas API key
  • Open up the Get All Clusters API call under the cluster folder.
Accessing Postman API Calls to MongoDB Atlas
  • Make sure you select the Atlas environment variables and
    update the Postman variable
    ProjectID value to your Project ID captured in the previous steps.
Setting Postman variables
Setting Postman variables in Atlas Environment variables
  • Execute the API call by hitting the Send button and you should get a response containing a list of all your clusters (database deployments) alongside the cluster details, like whether backup is enabled or the cluster is running.
Executing API call to list all MongoDB Atlas cluster in your project.
Now explore all the APIs available to create your own automation.
One last tip: Once you have tested all your API calls to build your automation, Postman allows you to export that in code snippets in your favorite programming language.
Generating Code snippet in Postman
Generating Python Code snippet in Postman
Please always refer to the online
documentation
for any changes or new resources. Also, feel free to make pull requests to update the project with new API resources, fixes, and enhancements.
Hope you enjoyed it! Please share this with your team and community. It might be really helpful for everyone!
Here are some other great posts related to this subject:
*A subset of API endpoints are supported in (free) M0, M2, and M5 clusters.

Copy Link
facebook icontwitter iconlinkedin icon
Rate this article
star-empty
star-empty
star-empty
star-empty
star-empty
Related
Article
How to Build Serverless Applications with SST and MongoDB Atlas

May 09, 2022
Tutorial
How to Query from Multiple MongoDB Databases Using MongoDB Atlas Data Lake

Jun 07, 2022
Tutorial
MongoDB Charts Embedding SDK with React

May 10, 2022
Article
Atlas Multi-Cloud Global Cluster: Always Available, Even in the Apocalypse!

May 09, 2022