Connect DigitalOcean
Tasks call DigitalOcean through qbash.integrations.digitalocean with a personal access token you store on the Connectors page. The token covers the account, billing, Droplets, App Platform, managed databases, Kubernetes, DNS and uptime checks. Spaces object storage uses a separate access key pair, which you add to the same credential only if a task reads or writes Spaces.
After you connect DigitalOcean, you can add its tools to a qbash MCP server for ChatGPT, Claude and other MCP clients, or call it from a Python task. The DigitalOcean MCP server page lists what the connector can do.
The writes are limited to Droplet power actions, starting an app deployment, DNS record changes and Spaces object uploads and deletes. No method creates or destroys a Droplet, app, database or cluster.
Create a personal access token
- Sign in to the DigitalOcean control panel and select the team the task should read.
- Open API in the left menu. On the Tokens tab, click Generate New Token.
- Name the token and choose when it expires. When the token expires, calls fail until you paste a new one into the credential.
- Choose the scopes. Full Access grants every read and write on the team. Read Only grants every read and no writes. Custom Scopes lets you pick each resource, which is the safer choice for a task.
- For a reporting task, select the read scope of each resource it uses, such as
account:read,droplet:read,monitoring:read,app:read,database:read,kubernetes:read,domain:read,uptime:readandbilling:read. Keepaccount:read, because qbash checks a new token by reading the account. - Add write scopes only for the methods a task calls:
droplet:updatefordroplet_action,app:updateforcreate_app_deployment, anddomain:create,domain:updateordomain:deletefor the DNS record methods. - Click Generate Token and copy it. DigitalOcean shows the token once, and it starts with
dop_v1_.
Create Spaces keys (optional)
The Spaces methods (list_spaces_buckets, list_spaces_objects, get_spaces_object, put_spaces_object and delete_spaces_object) sign their requests with a Spaces key pair. Skip this section if no task uses them.
- In the control panel, open Spaces Object Storage, then the Access Keys tab, and click Create Access Key.
- Choose Full Access to reach every bucket, or Limited Access to grant access to named buckets. Limited access is either read only or read, write and delete. A task that only reads needs read access on its buckets. A limited key cannot list buckets, so
list_spaces_bucketsreturns an access error for it, while the other Spaces methods work on the buckets it was granted. - Name the key and create it. Copy the access key and the secret key. The secret key is shown once.
- Note the region slug of the buckets, such as
nyc3orfra1. It appears in each bucket's URL, as inmy-bucket.nyc3.digitaloceanspaces.com. One credential reads one region, so buckets in another region need a second credential.
Add the credential in qbash
- Open Connectors, then DigitalOcean, and click Connect.
- Give the credential a name and paste the personal access token. qbash checks the token with DigitalOcean before saving it.
- To use Spaces, paste the Spaces access key and secret key and enter the region slug, such as
nyc3. Fill in all three Spaces fields or leave all three blank. qbash checks new Spaces keys with DigitalOcean before saving them. - In the task editor, open Resources → Integrations, and select the credential. See Connect resources.
To edit the credential later, leave a secret blank to keep the saved one.
Call DigitalOcean from a task
This task checks an App Platform app's latest deployment and logs the end of its build output when the deployment failed. list_apps returns app ids.
app_id = "4f6c71e2-1e90-4762-9fee-6cc4a0a9f2cf"
result = qbash.integrations.digitalocean.list_app_deployments(app_id=app_id, per_page=1)
if not result["deployments"]:
qbash.log("The app has no deployments yet.")
else:
latest = result["deployments"][0]
qbash.log(f'{latest["id"]} {latest["phase"]} {latest.get("cause")}')
if latest["phase"] == "ERROR":
build = qbash.integrations.digitalocean.get_deployment_logs(
app_id=app_id,
deployment_id=latest["id"],
log_type="BUILD",
)
qbash.log(build["logs"][-4000:])
Deployments come back newest first. The SDK Reference lists every method with its parameters and return values.
Add test data
A new team has nothing to list, so most list methods return empty pages until you create these:
- A Droplet. Create the smallest Basic Droplet in any region and turn on Monitoring under advanced options, which installs the metrics agent that
get_droplet_metricsreads. Droplets bill by the hour, so destroy it when you finish testing. - An App Platform app. Create an app from a static site repository, such as DigitalOcean's sample HTML app. Static sites fall within App Platform's free allowance. To see a failed build, push a commit that breaks the build and read the ERROR deployment's logs.
- A domain. Open Networking, then Domains, and add a domain you own. DigitalOcean stores its records even before the registrar points at DigitalOcean's name servers, so
create_domain_recordandlist_domain_recordswork on a test domain. - An uptime check. Open Monitoring, then Uptime, and create a check against the app's URL for
list_uptime_checksandget_uptime_check_state. - A Spaces bucket. Create a bucket in the region on the credential and upload a small file, or write one with
put_spaces_object.
Details that affect results
- List methods take
pageandper_page, with up to 200 items per page, and returnnext_page. Passnext_pageback aspageuntil it isNone.list_databasesandlist_spaces_bucketsreturn everything in one call.list_spaces_objectspages differently: passnext_markerback asmarkerwhileis_truncatedisTrue. cpuvalues fromget_droplet_metricsare cumulative CPU seconds per mode. Compute usage from the change between two points.filesystem_freeandfilesystem_sizeare bytes, with one series per mounted filesystem. The window defaults to the last hour. An empty series list usually means the Droplet does not run the metrics agent.get_deployment_logsreads the app's active deployment when you leave outdeployment_id, and the latest deployment when none is active. A failed deployment is never the active one, so pass its id fromlist_app_deploymentsto read why it failed.- Only the last 1 MB of logs comes back, and
truncatedisTruewhen earlier lines were cut. RUN logs of a running app can come back empty, because DigitalOcean serves those as a live stream that this method does not read. droplet_actionreturns as soon as DigitalOcean accepts the action.action.statusstarts asin-progress, so read the Droplet withget_dropletto see when its status changes.- DigitalOcean allows each token 5,000 requests per hour and 250 per minute. A task that walks every page of a large list on a frequent schedule can reach the limit.
list_spaces_bucketsreturns only the buckets in the credential's region.get_spaces_objectandput_spaces_objecthandle objects up to qbash's 5 GB file limit.get_spaces_objectreturns a qbash file reference, which other methods accept as a file. Text passed ascontentis limited to 500 MB.- Balance and invoice amounts are decimal strings in US dollars, such as
"23.44". get_databaseandlist_databasesremove credentials before the result reaches the task: passwords, connection URIs, and Kafka access keys and certificates.