Docs Menu

Docs HomeAtlas App Services

Export an App with Atlas App Services API

On this page

  • Prerequisites
  • Procedure
  • Authenticate a MongoDB Atlas User
  • Get the Atlas Project ID
  • Get the Application ID
  • Export Your App

You can use the App Services Admin API to export your App's configuration.

Note

Secrets Not Exported

When you export your App, the export does not include the secrets. To add your secrets to a different app, refer to the documentation on migrating configuration, including secrets, to a new App.

  • A MongoDB Atlas programmatic API key for the MongoDB Cloud account you wish to log in with. You must be a Project Owner to create an App.

1

Use your MongoDB Cloud API key pair to call the authentication endpoint:

curl --request POST \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{"username": "<Public API Key>", "apiKey": "<Private API Key>"}' \
https://realm.mongodb.com/api/admin/v3.0/auth/providers/mongodb-cloud/login

If authentication succeeds, Atlas App Services returns an access token as part of the JSON response document:

{
"access_token": "<access_token>",
"refresh_token": "<refresh_token>",
"user_id": "<user_id>",
"device_id": "<device_id>"
}

Save the access_token, which you'll use as the Bearer token to authenticate in the upcoming steps.

Tip

2

To export an App, you need the Project ID (sometimes referred to as the Group ID) of the Atlas project that contains the app. You will include this ID in the URL of API requests.

3

To export an App configuration, you need the app's Application ID. You will include this ID in the URL of API requests alongside the Project ID you just looked up.

To find an App ID, make a request to the Atlas App Services GET /groups/{groupid}/apps API endpoint.

This request has the following format, referencing the access_token and the Group ID:

curl --request GET \
--header 'Authorization: Bearer <access_token>' \
https://realm.mongodb.com/api/admin/v3.0/groups/{groupId}/apps

This will return a list of objects describing each App in the provided group. For Admin API requests, your Application ID is the ObjectId value in the _id field, not the client_app_id.

Example

[
{
"_id": "5997529e46224c6e42gb6dd9",
"group_id": "57879f6cc4b32dbe440bb8c5",
"domain_id": "5886619e46124e4c42fb5dd8",
"client_app_id": "myapp-abcde",
"name": "myapp",
"location": "US-VA",
"deployment_model": "GLOBAL",
"last_used": 1615153544,
"last_modified": 0,
"product": "standard",
"environment": ""
}
]
4

To export your App, send a request to the app's export endpoint. The endpoint URL should includes the Project ID and App ID you just looked up.

Include the access token from the response document of the previous step in a Bearer token Authorization header.

curl --request GET 'https://realm.mongodb.com/api/admin/v3.0/groups/<projectId>/apps/<appId>/export' \
--header 'Authorization: Bearer <access token>' \
--header 'Content-Type: application/json'

If the request is successful, the endpoint returns a 200 response and a .zip file that contains your application's current configuration directory.

←  Export an App with Realm CLIUpdate an App →
Give Feedback
© 2022 MongoDB, Inc.

About

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