Docs Menu

Realm CLI Authenticate With API Token

On this page

  • Overview
  • Generate an API Key
  • Navigate to MongoDB Cloud Access Manager
  • Create an API Key
  • Configure Your API Access List
  • Authenticate with an API Key
  • Authenticate a CLI User

MongoDB provides the Realm Command Line Interface (realm-cli) to manage your Realm apps programmatically. You can authenticate a MongoDB Cloud User with an API key for your project. Generate an API key through the access manager in your MongoDB Cloud account.


The MongoDB Cloud Access Manager allows you to manage access to your project for users, teams, and API Keys. Use the Project Access Manager by clicking the Project Access tab on the access manager dropdown on your screen's top left-hand side.

Click Access Manager
click to enlarge

Project Users can log in using the Realm CLI tool with a Project API Key. Create a project API Key by clicking the grey Create API Key button on the right-hand side of the Project Access Manager.

Click Access Manager
click to enlarge

Clicking this button will navigate you to the "Create API Key" screen. Set a description for your key and a project permission. The various project permissions are described on the right hand side of the screen and can be changed at a later time. Copy the public key to use later in order to log in. Click next to continue configuring your key details.

Click Access Manager
click to enlarge

Copy your Private Key to a safe location for later use. For security, the Private Key will not be visible again after initialization. Another security feature is the API Access List. Creating an API Access List entry ensures that API calls originate from permitted IPs.

The IP Address of the user who will be using the API Key is required to use the key. Click the Add Access List Entry button. Type in the IP Address or click the Use Current IP Address buttton and click save. Finally, click the done button on your screen's lower right-hand to finish setting up your API key.

Click Access Manager
click to enlarge

Using your newly created public and private key, log in by running the command below.

realm-cli login --api-key="<my api key>" --private-api-key="<my private api key>"

You should see the following result:

you have successfully logged in as <your public key>
Welcome to the MongoDB Realm Docs →
Give Feedback
© 2022 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.