Docs Menu
Docs Home
/ /
Atlas App Services
/

Roll Back a Deployment

On this page

  • Overview
  • Before You Begin
  • Procedure

You can roll back an App's configuration to a previously deployed version. App Services can automatically redeploy any of an App's 25 most recent deployments. For older deployments, you must manually get and deploy the configuration files (e.g. from source control).

A redeploy rolls back your application's configuration to match the earlier version.

You will need the following to rollback an App in the Atlas UI:

  • A MongoDB Atlas account with Project Owner permissions. To learn how to sign up for a free account, see Get Started with Atlas.

You will need the following to rollback an App with the Admin API:

  • A MongoDB Atlas account with Project Owner permissions. To learn how to sign up for a free account, see Get Started with Atlas.

  • A MongoDB Atlas Admin API public/private key pair. The API key must have Project Owner permissions to work with App Services Admin API.

  • Your App's internal ObjectId hex string and the Project ID of the Atlas Project that contains your App. To learn how to find these, see Get App Metadata.

1

You can redeploy from your App's Deployment History page. To get there, click Deployment in the left navigation menu and then select the History tab.

2

In the deployment history list, find the deployment you want to roll back to. Click the Re-Deploy button for that deployment.

3

After the deployment completes, you'll see the deployment success banner. The new deployment appears in your Deployment History.

If you have GitHub deployment enabled, it also contains a link to the commit in the GitHub repository.

In the linked GitHub repository, the commit author is the mongodb-realm bot.

Screenshot of deployment changes in GitHub
1

Call the admin user authentication endpoint with your MongoDB Atlas API key pair:

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

If authentication succeeds, the response body contains a JSON object with an access_token value:

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

The access_token grants access to the App Services Admin API. You must include it as a Bearer token in the Authorization header for all Admin API requests.

Tip

See also:

2

You need the _id of the deployment you want to redeploy. To find it, call the List Deployments endpoint, which responds with a list of the App's 25 most recent deployments.

Find the deployment you want to redeploy in the list and copy its _id.

curl -X GET \
https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/deployments \
-H 'Authorization: Bearer <access_token>'
[
{
"_id": "638662e881ad88c37dcb7656",
"app_id": "63844243ec3f52ed48923213",
"draft_id": "638662d6cc4b58e348927a7a",
"user_id": "59231005d323af2275135258",
"deployed_at": 1669751529,
"origin": "UI",
"commit": "",
"status": "successful",
"status_error_message": "",
"diff_url": "",
"name": "638662e881ad88c37dcb7656",
"remote_location": "US-VA"
},
{
"_id": "638662b2fd660afffb39df01",
"app_id": "63844243ec3f52ed48923213",
"draft_id": "638662928d19776b743d3b30",
"user_id": "593f1105d383ad2275165258",
"deployed_at": 1669751475,
"origin": "UI",
"commit": "",
"status": "successful",
"status_error_message": "",
"diff_url": "",
"name": "638662b2fd660afffb39df01",
"remote_location": "US-VA"
}
]
3

You can roll back to a previous deployment by calling the Redeploy a Deployment endpoint. Pass the _id of the deployment you want to redeploy as the deploymentId parameter.

curl -X GET \
https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/deployments/{deploymentId}/redeploy \
-H 'Authorization: Bearer <access_token>'

Back

Delete an App