DigitalOcean personal access tokens are generated in the Control Panel under Account → API → Tokens → Generate New Token. You choose a name, an expiration and scopes, and the token is shown only once. Scopes cannot be edited after creation.
DigitalOcean key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| Personal access token Scopes cannot be changed after creation. The docs do not list the expiration intervals. | — | Yes | Custom scopes, Read Only (`api:read`) or Full Access (`api:write`), limited by your team role | You choose the expiration when generating; after that the token stops working and is removed |
How to create a DigitalOcean key
- In the DigitalOcean Control Panel, go to Account → API, then the Tokens tab.
- In Personal access tokens, click Generate New Token.
- Enter a token name, choose an expiration, and select scopes.
- Click Generate Token and save the token immediately; it is shown only once.
Open DigitalOcean's key settings
Limiting what the key can do
Choose Custom Scopes for specific permissions (for example database:create), Read Only (api:read) for read access to all resources your team role allows, or Full Access (api:write). Available scopes depend on your team role, and scopes cannot be edited later, so create a new token to change them.
How to rotate a DigitalOcean key
- From the … menu next to the token on the Tokens tab, choose Regenerate, or generate a new token.
- Update your applications with the new token.
- Delete the old token if you generated a new one instead of regenerating.
How to revoke a DigitalOcean key
- In the Control Panel go to Account → API → Tokens.
- Open the … menu next to the token and choose Delete; deleting revokes its access.
If your DigitalOcean key leaked
- Delete the exposed token from the Tokens tab.
- Generate a replacement with the narrowest scopes and a short expiry.
- Review your account's resources for anything you did not create.
Environment variables and CLI
doctl (doctl): doctl auth init --context <NAME> prompts you to paste an API token
Things that catch people out
- The token is displayed only once.
- Scopes cannot be edited after creation.
- Expired tokens are removed from your account and can no longer authenticate.
Using your DigitalOcean key with AI agents
A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.
BotPassword works this way. For a DigitalOcean key, these intents fit:
| Intent | What BotPassword does |
|---|---|
list_credentials | Lists the credentials this agent is granted and what it may do with each. Never values. |
run_with | Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output. |
http_request | Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused. |
cli_login | Lets git, Docker, the AWS CLI and kubectl log in through bpw's credential helper, so the token is fetched when the tool needs it and not written into its config. The helper hands the value to the tool, so the grant is always disclosing. Other tools use run_with; OAuth device logins are planned. |
rotate | Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet. |
store_secret | Saves a value the agent already holds as a new vault item. |
DigitalOcean also publishes its own MCP server. Whatever server the agent uses, keep the credential it authenticates with out of the agent's context.
Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents
Frequently asked questions
Where do I find my DigitalOcean API token?
It is shown only once when you generate it under Account → API → Tokens. If lost, regenerate it or create a new one.
How do I revoke a DigitalOcean API token?
On the Tokens tab, open the … menu beside the token and choose Delete.
How do I log in to doctl?
Run doctl auth init --context <NAME> and paste your API token when prompted.
Can I limit what a DigitalOcean token can do?
Yes. Choose Read Only, Full Access or custom scopes when you generate it.
Can an AI agent use my DigitalOcean key without seeing it?
Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with list_credentials, run_with, http_request, so the agent gets the result and never the value.