To delete a project, the following criteria must be true:
-
The project must have no resources in it. To empty out the resources in a project, you can either destroy them or move them into a new project.
-
The project must not be the default project. You can set a different project as the default on the Settings tab of that project.
Delete a Project Using the Control Panel
To delete an empty, non-default project, visit the project’s Settings tab.
In the Delete project section, click Delete Project. When prompted, click Confirm Delete. This permanently removes the project from your account.
Delete a Project Using Automation
How to Delete a Project Using the DigitalOcean CLI
- Install
doctl
, the official DigitalOcean CLI.
- Create a personal access token and save it for use with
doctl
.
- Use the token to grant
doctl
access to your DigitalOcean account.
- Finally, run
doctl projects delete
. Basic usage looks like this, but you can read the usage docs for more details:
doctl projects delete <project-id> [<project-id> ...] [flags]
The following example deletes the project with the ID f81d4fae-7dec-11d0-a765-00a0c91e6bf6
:
doctl projects delete f81d4fae-7dec-11d0-a765-00a0c91e6bf6
How to Delete a Project Using the DigitalOcean API
- Create a personal access token and save it for use with the API.
- Send a DELETE request to
https://api.digitalocean.com/v2/projects/{project_id}
.
cURL
Using cURL:
curl -X DELETE -H 'Content-Type: application/json' -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/projects/4e1bfbc3-dc3e-41f2-a18f-1b4d7ba71679"
Go
Using Godo, the official DigitalOcean API client for Go:
import (
"context"
"os"
"github.com/digitalocean/godo"
)
func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")
client := godo.NewFromToken(token)
ctx := context.TODO()
_, err := client.Projects.Delete(ctx, '4e1bfbc3-dc3e-41f2-a18f-1b4d7ba71679')
}
Ruby
Using DropletKit, the official DigitalOcean API client for Ruby:
require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)
client.projects.delete(id: '4e1bfbc3-dc3e-41f2-a18f-1b4d7ba71679')
Python
Using PyDo, the official DigitalOcean API client for Python:
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
resp = client.projects.delete(project_id="fda9fda")