> **For AI agents:** The documentation index is at [https://docs.digitalocean.com/llms.txt](https://docs.digitalocean.com/llms.txt). Markdown versions of pages use the same URL with `index.html.md` in place of the HTML page (for example, append `index.html.md` to the directory path instead of opening the HTML document). # How to Manage Deployments in App Platform App Platform is a fully managed Platform-as-a-Service (PaaS) that deploys applications from Git repositories or container images. It automatically builds, deploys, and scales components while handling all underlying infrastructure. You can view a deployment’s logs to check for error messages and rollback deployments as needed. ## View Your App’s Deployment Logs Using Automation To retrieve logs for a specific deployment using the CLI or API, you need to provide the deployment’s ID. You can retrieve a list of deployments and their IDs using the CLI’s `doctl apps list-deployments` command or the [`/v2/apps/{app_id}/deployments` endpoint](https://docs.digitalocean.com/reference/api/reference/apps/index.html.md#apps_list_deployments). ## How to View a Deployment’s Logs Using the DigitalOcean CLI 1. [Install `doctl`](https://docs.digitalocean.com/reference/doctl/how-to/install/index.html.md), the official DigitalOcean CLI. 2. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with `doctl`. 3. Use the token to grant `doctl` access to your DigitalOcean account. ```shell doctl auth init ``` 4. Finally, run `doctl apps logs`. Basic usage looks like this, but you can [read the usage docs](https://docs.digitalocean.com/reference/doctl/reference/apps/logs/index.html.md) for more details: ```shell doctl apps logs [flags] ``` The following example retrieves the build logs for the app with the ID `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` and the component `web`: ```shell doctl apps logs f81d4fae-7dec-11d0-a765-00a0c91e6bf6 web --type build ``` ## How to View a Deployment’s Logs Using the DigitalOcean API 1. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with the API. 2. Send a GET request to [`https://api.digitalocean.com/v2/apps/{app_id}/deployments/{deployment_id}/logs`](https://docs.digitalocean.com/reference/api/reference/apps/index.html.md#apps_get_logs_aggregate). ### cURL Using cURL: ```shell curl -X GET \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ "https://api.digitalocean.com/v2/apps/{app_id}/deployments/{deployment_id}/logs" ``` ### Python Using [PyDo](https://github.com/digitalocean/pydo), the official DigitalOcean API client for Python: ```python import os from pydo import Client client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN")) get_resp = client.apps.get_logs_aggregate(app_id="b6bdf840", deployment_id="a6adf840") ``` ## View Your App’s Deployment Logs Using the Control Panel To view your app’s deployments, go to the [**Apps** page](https://cloud.digitalocean.com/apps), select your app, then click the **Activity** tab. The app’s deployment history displays. Click **View details** on any active deployment to see its real-time logs. ![The Activity page showing a live deployment.](https://docs.digitalocean.com/screenshots/app-platform/activity-deployments.ed85685872ab0642a6874507d7b827fa9e01d7d223c6bc83d8a43709c59eb44b.png) The deployment marked **Live app** is the currently live deployment served at your app’s URL. Click the commit link to view the commit that triggered the deployment, or hover over the `-m` flag to see the commit message. To manually redeploy your app, click the **Actions** menu in the top-right corner, then select **Deploy**. This pulls the latest code from the apps’s associated source repo, builds a new container image, and deploys it. If your Node.JS app fails to build due to `node_modules` caching issues, you can [force clear the cache and start a new build](https://docs.digitalocean.com/products/app-platform/reference/buildpacks/nodejs/index.html.md#clearing-the-cache). ## Roll Back to a Previous Deployment You can undo a faulty deployment by rolling back your app to a previous deployment. This lets you recover from accidentally deploying code with errors or an app spec that causes failures. You can roll back to any of the ten most recent successful deployments. To roll back an app, the deployment must be in the same region as the app and use the same database resources and configuration. Rolling back an app restores the app’s code, configuration, and app spec, but does not affect database data. To roll back database data, restore it from a backup as described in the [Managed Databases documentation](https://docs.digitalocean.com/products/databases/index.html.md). ### Roll Back a Deployment Using the API To rollback a deployment using the API, provide the app’s ID and the ID of the deployment you want roll back to. Use the `/v2/apps` endpoint to retrieve a list of apps and their IDs, and use the `/v2/apps/{app_id}/deployments` endpoint to retrieve a list of deployments for a specific app. ## How to Rollback a Deployment Using the DigitalOcean API 1. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with the API. 2. Send a POST request to [`https://api.digitalocean.com/v2/apps/{app_id}/rollback`](https://docs.digitalocean.com/reference/api/reference/apps/index.html.md#apps_create_rollback). ### cURL Using cURL: ```shell curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ -d '{ "deployment_id": "3aa4d20e-5527-4c00-b496-601fbd22520a" }' \ "https://api.digitalocean.com/v2/apps/{app_id}/rollback" ``` ### Python Using [PyDo](https://github.com/digitalocean/pydo), the official DigitalOcean API client for Python: ```python import os from pydo import Client client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN")) create_resp = client.apps.create_rollback(app_id="b6bdf840") ``` ### Roll Back a Deployment Using the Control Panel To roll back an app, go to the [**Apps** page](https://cloud.digitalocean.com/apps), select your app, then click the **Activity** tab. In the **Activity** list, click **Rollback** beside the deployment you want to roll back. The **Rollback** window shows a comparison between the current deployment and the selected deployment: - Expand resources in the tree to see whether source code or resource settings have changed. For source code changes, you can click the commit hash to view the commit that triggered the deployment. You can also hover over the `-m` flag to see the commit message. ![The Rollback window showing an example app and a components whose resource settings changed.](https://docs.digitalocean.com/screenshots/app-platform/rollback-app.5842d8a359dd78f30fac4f7fbe9d07b130fff8aaaec6c372e9f6d794178a1bed.png) - Expand **ALL SETTINGS DIFF** to see the diff between your current and previous deployment’s app spec. Additions and deletions are shown using `+` and `-`. - Expand **MORE OPTIONS** and optionally clear the **Automatically Deploy Code Changes** checkbox to disable automatic redeploys until the cause for the rollback is resolved. Click **Rollback** to start the rollback deployment. The new deployment duplicates the old one, preserving both the code and configuration from the selected deployment.