DigitalOcean

DigitalOcean

Introduction

The DigitalOcean API allows you to manage Droplets and resources within the DigitalOcean cloud in a simple, programmatic way using conventional HTTP requests.

All of the functionality that you are familiar with in the DigitalOcean control panel is also available through the API, allowing you to script the complex actions that your situation requires.

The API documentation will start with a general overview about the design and technology that has been implemented, followed by reference information about specific endpoints.

Requests

Any tool that is fluent in HTTP can communicate with the API simply by requesting the correct URI. Requests should be made using the HTTPS protocol so that traffic is encrypted. The interface responds to different methods depending on the action required.

MethodUsage
GETFor simple retrieval of information about your account, Droplets, or environment, you should use the GET method. The information you request will be returned to you as a JSON object. The attributes defined by the JSON object can be used to form additional requests. Any request using the GET method is read-only and will not affect any of the objects you are querying.
DELETETo destroy a resource and remove it from your account and environment, the DELETE method should be used. This will remove the specified object if it is found. If it is not found, the operation will return a response indicating that the object was not found. This idempotency means that you do not have to check for a resource's availability prior to issuing a delete command, the final state will be the same regardless of its existence.
PUTTo update the information about a resource in your account, the PUT method is available. Like the DELETE Method, the PUT method is idempotent. It sets the state of the target using the provided values, regardless of their current values. Requests using the PUT method do not need to check the current attributes of the object.
PATCHSome resources support partial modification. In these cases, the PATCH method is available. Unlike PUT which generally requires a complete representation of a resource, a PATCH request is a set of instructions on how to modify a resource updating only specific attributes.
POSTTo create a new object, your request should specify the POST method. The POST request includes all of the attributes necessary to create a new object. When you wish to create a new object, send a POST request to the target endpoint.
HEADFinally, to retrieve metadata information, you should use the HEAD method to get the headers. This returns only the header of what would be returned with an associated GET request. Response headers contain some useful information about your API access and the results that are available for your request. For instance, the headers contain your current rate-limit value and the amount of time available until the limit resets. It also contains metrics about the total number of objects found, pagination information, and the total content length.

HTTP Statuses

Along with the HTTP methods that the API responds to, it will also return standard HTTP statuses, including error codes.

In the event of a problem, the status will contain the error code, while the body of the response will usually contain additional information about the problem that was encountered.

In general, if the status returned is in the 200 range, it indicates that the request was fulfilled successfully and that no error was encountered.

Return codes in the 400 range typically indicate that there was an issue with the request that was sent. Among other things, this could mean that you did not authenticate correctly, that you are requesting an action that you do not have authorization for, that the object you are requesting does not exist, or that your request is malformed.

If you receive a status in the 500 range, this generally indicates a server-side problem. This means that we are having an issue on our end and cannot fulfill your request currently.

400 and 500 level error responses will include a JSON object in their body, including the following attributes:

NameTypeDescription
idstringA short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."
messagestringA message providing additional information about the error, including details to help resolve it when possible.
request_idstringOptionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.

Example Error Response

 HTTP/1.1 403 Forbidden
{
"id": "forbidden",
"message": "You do not have access for the attempted action."
}

Responses

When a request is successful, a response body will typically be sent back in the form of a JSON object. An exception to this is when a DELETE request is processed, which will result in a successful HTTP 204 status and an empty response body.

Inside of this JSON object, the resource root that was the target of the request will be set as the key. This will be the singular form of the word if the request operated on a single object, and the plural form of the word if a collection was processed.

For example, if you send a GET request to /v2/droplets/$DROPLET_ID you will get back an object with a key called "droplet". However, if you send the GET request to the general collection at /v2/droplets, you will get back an object with a key called "droplets".

The value of these keys will generally be a JSON object for a request on a single object and an array of objects for a request on a collection of objects.

Response for a Single Object

 {
"droplet": {
"name": "example.com"
. . .
}
}

Response for an Object Collection

 {
"droplets": [
{
"name": "example.com"
. . .
},
{
"name": "second.com"
. . .
}
]
}

Meta

In addition to the main resource root, the response may also contain a meta object. This object contains information about the response itself.

The meta object contains a total key that is set to the total number of objects returned by the request. This has implications on the links object and pagination.

The meta object will only be displayed when it has a value. Currently, the meta object will have a value when a request is made on a collection (like droplets or domains).

Sample Meta Object

 {
. . .
"meta": {
"total": 43
}
. . .
}

Links & Pagination

The links object is returned as part of the response body when pagination is enabled. By default, 20 objects are returned per page. If the response contains 20 objects or fewer, no links object will be returned. If the response contains more than 20 objects, the first 20 will be returned along with the links object.

You can request a different pagination limit or force pagination by appending ?per_page= to the request with the number of items you would like per page. For instance, to show only two results per page, you could add ?per_page=2 to the end of your query. The maximum number of results per page is 200.

The links object contains a pages object. The pages object, in turn, contains keys indicating the relationship of additional pages. The values of these are the URLs of the associated pages. The keys will be one of the following:

The pages object will only include the links that make sense. So for the first page of results, no first or prev links will ever be set. This convention holds true in other situations where a link would not make sense.

Sample Links Object

 {
. . .
"links": {
"pages": {
"last": "https://api.digitalocean.com/v2/images?page=2",
"next": "https://api.digitalocean.com/v2/images?page=2"
}
}
. . .
}

Rate Limit

Requests through the API are rate limited per OAuth token. Current rate limits:

Once you exceed either limit, you will be rate limited until the next cycle starts. Space out any requests that you would otherwise issue in bursts for the best results.

The rate limiting information is contained within the response headers of each request. The relevant headers are:

More rate limiting information is returned only within burst limit error response headers:

As long as the ratelimit-remaining count is above zero, you will be able to make additional requests.

The way that a request expires and is removed from the current limit count is important to understand. Rather than counting all of the requests for an hour and resetting the ratelimit-remaining value at the end of the hour, each request instead has its own timer.

This means that each request contributes toward the ratelimit-remaining count for one complete hour after the request is made. When that request's timer runs out, it is no longer counted towards the request limit.

This has implications on the meaning of the ratelimit-reset header as well. Because the entire rate limit is not reset at one time, the value of this header is set to the time when the oldest request will expire.

Keep this in mind if you see your ratelimit-reset value change, but not move an entire hour into the future.

If the ratelimit-remaining reaches zero, subsequent requests will receive a 429 error code until the request reset has been reached.

ratelimit-remaining reaching zero can also indicate that the "burst limit" of 250 requests per minute limit was met, even if the 5,000 requests per hour limit was not. In this case, the 429 error response will include a retry-after header to indicate how long to wait (in seconds) until the request may be retried.

You can see the format of the response in the examples.

Note: The following endpoints have special rate limit requirements that are independent of the limits defined above.

Sample Rate Limit Headers

 . . .
ratelimit-limit: 1200
ratelimit-remaining: 1193
rateLimit-reset: 1402425459
. . .

Sample Rate Limit Headers When Burst Limit is Reached:

 . . .
ratelimit-limit: 5000
ratelimit-remaining: 0
rateLimit-reset: 1402425459
retry-after: 29
. . .

Sample Rate Exceeded Response

 429 Too Many Requests
{
id: "too_many_requests",
message: "API Rate limit exceeded."
}

Curl Examples

Throughout this document, some example API requests will be given using the curl command. This will allow us to demonstrate the various endpoints in a simple, textual format.

These examples assume that you are using a Linux or macOS command line. To run these commands on a Windows machine, you can either use cmd.exe, PowerShell, or WSL:

The names of account-specific references (like Droplet IDs, for instance) will be represented by variables. For instance, a Droplet ID may be represented by a variable called $DROPLET_ID. You can set the associated variables in your environment if you wish to use the examples without modification.

The first variable that you should set to get started is your OAuth authorization token. The next section will go over the details of this, but you can set an environmental variable for it now.

Generate a token by going to the Apps & API section of the DigitalOcean control panel. Use an existing token if you have saved one, or generate a new token with the "Generate new token" button. Copy the generated token and use it to set and export the TOKEN variable in your environment as the example shows.

You may also wish to set some other variables now or as you go along. For example, you may wish to set the DROPLET_ID variable to one of your Droplet IDs since this will be used frequently in the API.

If you are following along, make sure you use a Droplet ID that you control so that your commands will execute correctly.

If you need access to the headers of a response through curl, you can pass the -i flag to display the header information along with the body. If you are only interested in the header, you can instead pass the -I flag, which will exclude the response body entirely.

Set and Export your OAuth Token

export DIGITALOCEAN_TOKEN=your_token_here

Set and Export a Variable

export DROPLET_ID=1111111

Parameters

There are two different ways to pass parameters in a request with the API.

When passing parameters to create or update an object, parameters should be passed as a JSON object containing the appropriate attribute names and values as key-value pairs. When you use this format, you should specify that you are sending a JSON object in the header. This is done by setting the Content-Type header to application/json. This ensures that your request is interpreted correctly.

When passing parameters to filter a response on GET requests, parameters can be passed using standard query attributes. In this case, the parameters would be embedded into the URI itself by appending a ? to the end of the URI and then setting each attribute with an equal sign. Attributes can be separated with a &. Tools like curl can create the appropriate URI when given parameters and values; this can also be done using the -F flag and then passing the key and value as an argument. The argument should take the form of a quoted string with the attribute being set to a value with an equal sign.

Pass Parameters as a JSON Object

 curl -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "example.com", "ip_address": "127.0.0.1"}' \
-X POST "https://api.digitalocean.com/v2/domains"

Pass Filter Parameters as a Query String

 curl -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-X GET \
"https://api.digitalocean.com/v2/images?private=true"

Cross Origin Resource Sharing

In order to make requests to the API from other domains, the API implements Cross Origin Resource Sharing (CORS) support.

CORS support is generally used to create AJAX requests outside of the domain that the request originated from. This is necessary to implement projects like control panels utilizing the API. This tells the browser that it can send requests to an outside domain.

The procedure that the browser initiates in order to perform these actions (other than GET requests) begins by sending a "preflight" request. This sets the Origin header and uses the OPTIONS method. The server will reply back with the methods it allows and some of the limits it imposes. The client then sends the actual request if it falls within the allowed constraints.

This process is usually done in the background by the browser, but you can use curl to emulate this process using the example provided. The headers that will be set to show the constraints are:

You should not need to be concerned with the details of these headers, because the browser will typically do all of the work for you.

Operations

Create a model response for the given chat conversation
Generate Image, Audio, or Text-to-Speech Using fal Models
Create a model response for the given chat conversation
Generate images from text prompts
List available models
Send Prompt to a Model Using the Responses API
List 1-Click Applications
Install Kubernetes 1-Click Applications
Get User Information
List All SSH Keys
Create a New SSH Key
Retrieve an Existing SSH Key
Retrieve an Existing Action
List All Actions
Get Metadata for an Add-On Application
List Available Add-On Applications
List all Add-On Resources
Create/Provision a New Add-on Resource
Delete/Deprovision an Add-on Resource
Get details on an Add-On Resource
Update the name for an Add-On Resource
Update the plan for an Add-On Resource
List all app alerts
Retrieve Aggregate Deployment Logs
List App Deployments
Create an App Deployment
Retrieve App Health
Retrieve App Instances
Retrieve Active Deployment Aggregate Logs
Retrieve App Daily Bandwidth Metrics
List All Apps
Delete an App
Retrieve an Existing App
Update an App
Retrieve Multiple Apps' Daily Bandwidth Metrics
Create a New App
Propose an App Spec
List App Regions
List Instance Sizes
Retrieve an Instance Size
List BYOIP Prefixes
Create a BYOIP Prefix
Purge the Cache for an Existing CDN Endpoint
Delete a CDN Endpoint
Retrieve an Existing CDN Endpoint
Update a CDN Endpoint
List All CDN Endpoints
Create a New CDN Endpoint
Retrieve an Existing Certificate
List All Certificates
Create a New Certificate
Get Customer Balance
List All Invoices
Retrieve an Invoice CSV by UUID
Retrieve an Invoice by UUID
Retrieve an Invoice PDF by UUID
Retrieve an Invoice Summary by UUID
Retrieve Autoscale Configuration for a Database Cluster
Configure Autoscale Settings for a Database Cluster
List Backups for a Database Cluster
Retrieve the Public Certificate
Retrieve an Existing Database Cluster Configuration
Update the Database Configuration for an Existing Database
Retrieve the Eviction Policy for a Caching or Valkey Cluster
Configure the Eviction Policy for a Caching or Valkey Cluster
List Firewall Rules (Trusted Sources) for a Database Cluster
Update Firewall Rules (Trusted Sources) for a Database
Retrieve an Existing Database Cluster
List Indexes for a OpenSearch Cluster
List Logsinks for a Database Cluster
Create Logsink for a Database Cluster
Configure a Database Cluster's Maintenance Window
Migrate a Database Cluster to a New Region
Retrieve the Status of an Online Migration
List Connection Pools (PostgreSQL)
Retrieve Existing Connection Pool (PostgreSQL)
Add a New Connection Pool (PostgreSQL)
Promote a Read-only Replica to become a Primary Cluster
Retrieve Schema Registry Configuration for a kafka Cluster
Update Schema Registry Configuration for a kafka Cluster
Retrieve Schema Registry Configuration for a Subject of kafka Cluster
Update Schema Registry Configuration for a Subject of kafka Cluster
Create Schema Registry for Kafka Cluster
Retrieve the SQL Modes for a MySQL Cluster
List Topics for a Kafka Cluster
Create Topic for a Kafka Cluster
Upgrade Major Version for a Database
Reset a Database User's Password or Authentication Method
List All Database Clusters
Retrieve Database Clusters' Metrics Endpoint Credentials
Update Database Clusters' Metrics Endpoint Credentials
List Database Options
Create a New Database Cluster
Get Dedicated Inference CA Certificate
List Dedicated Inferences
Get Dedicated Inference GPU Model Config
Create a Dedicated Inference
List Dedicated Inference Sizes
Retrieve an Existing Domain
List All Domain Records
Create a New Domain Record
List All Domains
Create a New Domain
Acting on Tagged Droplets
Retrieve an Existing Autoscale Pool
List All Autoscale Pools
Create a New Autoscale Pool
List Backup Policies for All Existing Droplets
List Supported Droplet Backup Policies
Deleting Droplets by Tag
List Actions for a Droplet
Initiate a Droplet Action
List Backups for a Droplet
Retrieve the Backup Policy for an Existing Droplet
Delete an Existing Droplet
Destroy a Droplet and All of its Associated Resources (Dangerous)
List Associated Resources for a Droplet
Retry a Droplet Destroy with Associated Resources Request
Selectively Destroy a Droplet and its Associated Resources
Check Status of a Droplet Destroy with Associated Resources Request
List all Firewalls Applied to a Droplet
Retrieve an Existing Droplet
List All Available Kernels for a Droplet
List Neighbors for a Droplet
List Snapshots for a Droplet
List All Droplets
Create a New Droplet
Remove Droplets from a Firewall
Add Droplets to a Firewall
Retrieve an Existing Firewall
Remove Rules from a Firewall
Add Rules to a Firewall
Remove Tags from a Firewall
Add Tags to a Firewall
List All Firewalls
Create a New Firewall
Retrieve an Existing Floating IP Action
List All Actions for a Floating IP
Initiate a Floating IP Action
Retrieve an Existing Floating IP
List All Floating IPs
Create a New Floating IP
Add Function Route to an Agent
Attach Guardrails to an Agent
Attach Knowledge Bases to an Agent
List Agents
Create an Agent
Retrieve an Existing Agent
Rollback to Agent Version
List Anthropic API Keys
Create Anthropic API Key
List agents by Anthropic key
Create Presigned URLs for Evaluation Dataset File Upload
Create Evaluation Dataset
List Evaluation Metrics
Retrieve Information About an Existing Evaluation Run
Retrieve Results of an Evaluation Run
Run an Evaluation Test Case
List Evaluation Test Cases
Create Evaluation Test Case.
Retrieve Information About an Existing Evaluation Test Case
List Indexing Jobs for a Knowledge Base
List Data Sources for Indexing Job for a Knowledge Base
Start Indexing Job for a Knowledge Base
Cancel Indexing Job for a Knowledge Base
Retrieve Status of Indexing Job for a Knowledge Base
Create Presigned URLs for Data Source File Upload
List Knowledge Bases
Create a Knowledge Base
Retrieve Information About an Existing Knowledge Base
Update a Knowledge Base
List Model API Keys
Create a Model API Key
List Available Models
Get Oauth2 Dropbox Tokens
Get Oauth2 URL
List OpenAI API Keys
Create OpenAI API Key
List agents by OpenAI key
List Datacenter Regions
Create scheduled indexing for knowledge base
List Workspaces
Create a Workspace
Retrieve an Existing Workspace
List All Images
Retrieve an Existing Action
List All Actions for an Image
Initiate an Image Action
Retrieve an Existing Image
Update an Image
Create a Custom Image
Fetch Clusterlint Diagnostics for a Kubernetes Cluster
Run Clusterlint Checks on a Kubernetes Cluster
Retrieve Credentials for a Kubernetes Cluster
Delete a Kubernetes Cluster
Delete a Cluster and All of its Associated Resources (Dangerous)
Selectively Delete a Cluster and its Associated Resources
Retrieve an Existing Kubernetes Cluster
Retrieve the kubeconfig for a Kubernetes Cluster
List All Node Pools in a Kubernetes Clusters
Retrieve a Node Pool for a Kubernetes Cluster
Update a Node Pool in a Kubernetes Cluster
Add a Node Pool to a Kubernetes Cluster
Update a Kubernetes Cluster
Fetch Status Messages for a Kubernetes Cluster
Retrieve Available Upgrades for an Existing Kubernetes Cluster
Retrieve User Information for a Kubernetes Cluster
List All Kubernetes Clusters
Create a New Kubernetes Cluster
List Available Regions, Node Sizes, and Versions of Kubernetes
Remove Container Registries from Kubernetes Clusters
Add Container Registries to Kubernetes Clusters
Remove Container Registry from Kubernetes Clusters
Add Container Registry to Kubernetes Clusters
List All Load Balancers
Delete a Global Load Balancer CDN Cache
Delete a Load Balancer
Remove Droplets from a Load Balancer
Add Droplets to a Load Balancer
Remove Forwarding Rules from a Load Balancer
Add Forwarding Rules to a Load Balancer
Retrieve an Existing Load Balancer
Update a Load Balancer
Create a New Load Balancer
Retrieve an Existing Alert Policy
List Alert Policies
Create Alert Policy
Get App CPU Percentage Metrics
Get App Memory Percentage Metrics
Get App Restart Count Metrics
Get Database MySQL CPU Usage Metrics
Get Database MySQL Disk Usage Metrics
Get Database MySQL Index vs Sequential Reads Metrics
Get Database MySQL Load Average Metrics
Get Database MySQL Memory Usage Metrics
Get Database MySQL Operations Throughput Metrics
Get Database MySQL Schema Latency Metrics
Get Database MySQL Schema Throughput Metrics
Get Database MySQL Threads Active Metrics
Get Database MySQL Threads Connected Metrics
Get Database MySQL Threads Created Rate Metrics
Get Droplet Autoscale Pool Current Average CPU utilization
Get Droplet Autoscale Pool Current Size
Get Droplet Autoscale Pool Current Average Memory utilization
Get Droplet Autoscale Pool Target Average CPU utilization
Get Droplet Autoscale Pool Target Size
Get Droplet Autoscale Pool Target Average Memory utilization
Get Droplet Bandwidth Metrics
Get Droplet CPU Metrics
Get Droplet Filesystem Free Metrics
Get Droplet Filesystem Size Metrics
Get Droplet Load1 Metrics
Get Droplet Load15 Metrics
Get Droplet Load5 Metrics
Get Droplet Available Memory Metrics
Get Droplet Cached Memory Metrics
Get Droplet Free Memory Metrics
Get Droplet Total Memory Metrics
Get Load Balancer Droplets Active Connections Metrics
Get Load Balancer Droplets Downtime Status Metrics
Get Load Balancer Droplets Health Check Status Metrics
Get Load Balancer Droplets 50th Percentile HTTP Response Time Metrics
Get Load Balancer Droplets 95th Percentile HTTP Response Time Metrics
Get Load Balancer Droplets 99th Percentile HTTP Response Time Metrics
Get Load Balancer Droplets Average HTTP Response Time Metrics
Get Load Balancer Droplets HTTP Rate Of Response Code Metrics
Get Load Balancer Droplets 50th Percentile HTTP Session Duration Metrics
Get Load Balancer Droplets 95th Percentile HTTP Session Duration Metrics
Get Load Balancer Droplets Average HTTP Session Duration Metrics
Get Load Balancer Droplets Queue Size Metrics
Get Load Balancer Frontend Total Current Active Connections Metrics
Get Load Balancer Frontend Max Connections Limit Metrics
Get Load Balancer Frontend Average Percentage CPU Utilization Metrics
Get Load Balancer Frontend Firewall Dropped Bytes Metrics
Get Load Balancer Frontend Firewall Dropped Packets Metrics
Get Load Balancer Frontend HTTP Requests Metrics
Get Load Balancer Frontend HTTP Rate Of Response Code Metrics
Get Load Balancer Frontend HTTP Throughput Metrics
Get Load Balancer Frontend TCP Throughput Metrics
Get Load Balancer Frontend UDP Throughput Metrics
Get Network Load Balancer Frontend TCP Throughput Metrics
Get Network Load Balancer Frontend UDP Throughput Metrics
Get Load Balancer Frontend Current TLS Connections Rate Metrics
Get Load Balancer Frontend Closed TLS Connections For Exceeded Rate Limit Metrics
Get Load Balancer Frontend Max TLS Connections Limit Metrics
List Logging Destinations
Create Logging Destination
Lists all sinks
List NFS shares per region
Initiate an NFS action
Delete an NFS share
Get an NFS share
Create a new NFS share
List NFS snapshots per region
Get an NFS snapshot by ID
List all partner attachments
Get current BGP auth key for the partner attachment
Delete an existing partner attachment
Retrieve an existing partner attachment
Update an existing partner attachment
List remote routes for a partner attachment
Get the current service key for the partner attachment
Regenerate the service key for the partner attachment
Create a new partner attachment
Retrieve the Default Project
Patch the Default Project
Update the Default Project
List Default Project Resources
Assign Resources to Default Project
List All Projects
Create a Project
Delete an Existing Project
Retrieve an Existing Project
Assign Resources to a Project
List All Data Center Regions
List All Container Registries
List Registry Options (Subscription Tiers and Available Regions)
Create Container Registry
Delete Container Registry By Name
Get Docker Credentials By Registry Name
Get a Container Registry By Name
List All Container Registry Repository Manifests
List All Container Registry Repositories (V2)
Get Subscription Information
Update Subscription Tier
Validate a Container Registry Name
List All Droplet Neighbors
List All Reserved IPs
Create a New Reserved IP
Retrieve an Existing Reserved IP Action
List All Actions for a Reserved IP
Initiate a Reserved IP Action
Retrieve an Existing Reserved IP
List All Reserved IPv6s
Create a New Reserved IPv6
Initiate a Reserved IPv6 Action
Retrieve an Existing Reserved IPv6
List All Droplet Sizes
List All Snapshots
Retrieve an Existing Snapshot
Delete a Spaces Access Key
Get a Spaces Access Key
Update Spaces Access Keys
Update Spaces Access Keys
List Spaces Access Keys
Create a New Spaces Access Key
List All Tags
Create a New Tag
Retrieve a Tag
Retrieve an Existing Check
List All Checks
Create a New Check
Initiate A Block Storage Action By Volume Name
Delete a Block Storage Volume by Name
List All Block Storage Volumes
Create a New Block Storage Volume
Retrieve an Existing Volume Snapshot
Retrieve an Existing Volume Action
List All Actions for a Volume
Initiate A Block Storage Action By Volume Id
Delete a Block Storage Volume
Retrieve an Existing Block Storage Volume
List Snapshots for a Volume
Create Snapshot from a Volume
List All VPC NAT Gateways
Delete VPC NAT Gateway
Retrieve an Existing VPC NAT Gateway
Update VPC NAT Gateway
Create a New VPC NAT Gateway
List All VPC Peerings
Create a New VPC Peering
Retrieve an Existing VPC Peering
List All VPCs
Create a New VPC
Retrieve an Existing VPC
List the Member Resources of a VPC
Partially Update a VPC
List the Peerings of a VPC
Create a Peering with a VPC
Update a VPC