doctl auth init

Go to Navigation


doctl auth init [flags]


This command allows you to initialize doctl with a token that allows it to query and manage your account details and resources.

The command requires and API token to authenticate, which you can generate in the control panel at

The --context flag allows you to add authentication for multiple accounts and then switch between them as needed. Provide a case-sensitive name for the context and then enter the API token you want use for that context when prompted. You can switch authentication contexts using doctl auth switch, which re-initializes doctl. You can also provide the --context flag when using any doctl command to specify the auth context for that command. This enables you to use multiple DigitalOcean accounts with doctl, or tokens that have different authentication scopes.

If the --context flag is not specified, doctl creates a default authentication context named default.

You can use doctl without initializing it by adding the --access-token flag to each command and providing an API token as the argument.


The following example initializes doctl with a token for a single account with the context your-team:

doctl auth init --context your-team


Option Description
--help , -h Help for this command
--token-validation-server The server used to validate a token
Command Description
doctl auth Display commands for authenticating doctl with an account

Global Flags

Option Description
--access-token, -t API V2 access token
--api-url, -u Override default API endpoint
--config, -c Specify a custom config file
  • macOS: ${HOME}/Library/Application Support/doctl/config.yaml
  • Linux: ${XDG_CONFIG_HOME}/doctl/config.yaml
  • Windows: %APPDATA%\doctl\config.yaml
--context Specify a custom authentication context name
--http-retry-max Set maximum number of retries for requests that fail with a 429 or 500-level error
Default: 5
--http-retry-wait-max Set the minimum number of seconds to wait before retrying a failed request
Default: 30
--http-retry-wait-min Set the maximum number of seconds to wait before retrying a failed request
Default: 1
--interactive Enable interactive behavior. Defaults to true if the terminal supports it (default false)
Default: false
--output, -o Desired output format [text|json]
Default: text
--trace Show a log of network activity while performing a command
Default: false
--verbose, -v Enable verbose output
Default: false