Docs Menu

Export a Realm App with Realm API

On this page

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

You can use the Realm Admin API to export your Realm app's configuration.

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, MongoDB Realm 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
See also:
2

To export a Realm app you will need to find the Group ID in Atlas.

Follow these steps and save the Group ID for the last step.

3

To delete a Realm app you will need to find the Application ID of the app.

To find an Application ID, make a request to the Realm 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 Realm 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": ""
}
]

Find the app you want to delete and save the _id field for the last step.

4

You can export your Realm app through the export endpoint. Include the access token from the response document of the previous step in a Bearer token Authorization header. You will also need your Group ID.

curl --request GET 'https://realm.mongodb.com/api/admin/v3.0/groups/<groupId>/apps/<appId>/export' \
--header 'Authorization: Bearer <access token>' \
--header 'Content-Type: application/json' \
--data '{"name": "<name of new app>"}'

If creation succeeds the MongoDB Realm returns a 200 response and a Zip file that contains your application's configuration.

Give Feedback
© 2021 MongoDB, Inc.

About

  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.