Skip to main content
Rent and control Cloud machines from an agent or a script

AIDev Cloud API & MCP docs

Let an AI agent (Claude, Cursor, Codex…) or your own script rent, start, stop and terminate AIDev Cloud GPU/CPU machines with a personal token, paid from your AIDev wallet.

Updated: 08/10/2026
API v1
Contents
1. Getting started
2. Set up MCP
3. Sample workflow
4. Monthly VPS
5. REST API
6. Billing and limits
7. Error codes
8. Security

1. Getting started

  • Turn on two-factor authentication (TOTP) in your account.
  • Top up your AIDev wallet at least once.
  • Create an agent token (requires your password and a TOTP code). The token is shown only once: save it right away.

Scope

ScopeAllows
cloud:selfView plans and machines, start, stop and restart machines, manage SSH keys; for monthly VPS: quotes, ports and domains.
cloud:self:spendRent and terminate hourly machines; buy and renew monthly VPS and turn on auto-renewal (charged to your wallet).

Each token lives at most 90 days, and each account has at most 5 tokens. Rotate or revoke tokens on the same page where you create them.

Machines running Ubuntu, Debian or Windows all work with agents. On Windows, the agent signs in with an SSH key as Administrator and runs commands through PowerShell; you still connect with Remote Desktop using the password shown on the web.

2. Set up MCP

Replace <token> with your agent token (it looks like aidev_pat_…).

Claude Code (terminal)
claude mcp add --transport http aidev-cloud https://api.aidev.edu.vn/mcp --header "Authorization: Bearer <token>"
Claude Desktop: claude_desktop_config.json (requires Node.js)
{ "mcpServers": { "aidev-cloud": { "command": "npx", "args": [ "-y", "mcp-remote", "https://api.aidev.edu.vn/mcp", "--header", "Authorization:${AIDEV_AUTH}" ], "env": { "AIDEV_AUTH": "Bearer <token>" } } } }
Cursor: ~/.cursor/mcp.json
{ "mcpServers": { "aidev-cloud": { "url": "https://api.aidev.edu.vn/mcp", "headers": { "Authorization": "Bearer <token>" } } } }
Codex: ~/.codex/config.toml (set the environment variable AIDEV_TOKEN=<token>)
[mcp_servers.aidev-cloud] url = "https://api.aidev.edu.vn/mcp" bearer_token_env_var = "AIDEV_TOKEN"

The aidev-cloud Skill teaches the agent a safe rental workflow: ask you before spending money, send only public keys, terminate the machine when done.

Download the aidev-cloud Skill

3. Sample workflow

An example with an Ubuntu machine. On Windows it is the same, with the user Administrator and commands run through PowerShell.

1. Generate an SSH key (skip if ~/.ssh/aidev already exists: never overwrite an old key)
ssh-keygen -t ed25519 -f ~/.ssh/aidev -N ""
  • 2. Ask the agent: "rent an RTX 3090 machine with the key ~/.ssh/aidev.pub".
  • 3. The agent reads the hourly price (pricePerHour, or pricePerHourWithPublicIp when renting with a public IP), checks whether the plan has room (slotState) and waits for your approval.
  • 4. The agent polls the machine every 15–30 seconds until status is active and vmStatus is running. On status error it stops: the held money has been returned and nothing is charged.
5. Connect (host and port from the connections entry whose protocol is ssh, the user from sshUser)
ssh -i ~/.ssh/aidev -p <port> <sshUser>@<host>

6. When you are done, tell the agent to "terminate the machine". Only terminating stops the charge.

4. Monthly VPS

The agent can buy and renew your own monthly VPS, paid from your AIDev wallet. Discount codes and QR bank transfers are not available through the agent, and the agent cannot terminate a monthly VPS: that is done on the web only.

  • 1. The agent reads the plans (cloud_term_plans_list), then gets a quote (cloud_term_quote): plan, operating system, months, add-ons and total.
  • 2. The agent waits until you approve both the total and the terms of service, and only then buys (cloud_term_buy) with expectedTotal equal to the quoted amount.
  • 3. If the total changes in between, the order is refused (SHOP_PRICE_CHANGED) and nothing is charged; the agent quotes again and asks you again.
  • 4. Renewal (cloud_term_renew) follows the same steps. Turning on auto-renewal (cloud_term_auto_renew_set) means your wallet is charged in later periods, so the agent asks you first too.
  • 5. Each token can buy and renew at most 5 times a day (Vietnam time).

Ports and domains: cloud_my_ports_get and cloud_my_ports_set open ports within the machine’s range (send the expectedRevision you just read); cloud_my_domains_list, cloud_my_domain_add, cloud_my_domain_update, cloud_my_domain_remove and cloud_my_site_label_set manage the free vps<number> domain and custom domains (a subdomain needs only a CNAME record pointing at the machine’s fixed name; an apex domain uses an A record plus a TXT record).

5. REST API

Base URL
https://api.aidev.edu.vn/capi/v1/cloud
  • Authentication: the header Authorization: Bearer aidev_pat_…. No cookies or JWT.
  • Idempotency-Key: <uuid> is required for renting, terminating, starting, stopping and restarting machines, removing keys, buying, renewing, auto-renewal, changing ports and removing domains. On a timeout, resend the same key with the same body: a second machine is never created. The key is tied to the body; a different body needs a new key.
  • Paths carry ids; start, stop and restart send revision in the body, terminate sends ?revision=. Responses are the data of the matching MCP tool.
  • Errors come back as { code, message, details, requestId }.

Routes

RouteMCP toolScopeNotes
GET /planscloud_plans_listcloud:self?page&limit. Plans, current hourly prices, and whether each has room.
GET /plans/:idscloud_plan_getcloud:selfSelectable operating systems (images), prices with and without a public IP.
GET /instancescloud_my_instancescloud:self?status&page&limit. Defaults to active: includes powered-off machines (still billed); status=all shows every machine.
GET /instances/:idscloud_my_instance_getcloud:selfstatus, vmStatus, revision, sshUser, connections, sshKeys. No password.
POST /instancescloud_my_instance_createcloud:self:spendRent a machine, charged to the wallet (201). Every refusal happens before anything is written: no machine, no money lost. Requires Idempotency-Key.
POST /instances/:ids/startcloud_my_instance_startcloud:selfStart the machine, body { revision }. Requires Idempotency-Key.
POST /instances/:ids/stopcloud_my_instance_stopcloud:selfStop the machine (still billed), body { revision }. Requires Idempotency-Key.
POST /instances/:ids/restartcloud_my_instance_restartcloud:selfRestart, body { revision }. Requires Idempotency-Key.
DELETE /instances/:ids?revision=cloud_my_instance_terminatecloud:self:spendTerminate the machine: billing stops and the data on its disk is lost for good. Requires Idempotency-Key.
GET /ssh-keyscloud_ssh_keys_listcloud:selfSSH keys saved in the account (at most 20).
POST /ssh-keyscloud_ssh_key_addcloud:selfSave a key (201); an existing key is returned as is with existing: true. Idempotency-Key optional.
DELETE /ssh-keys/:idscloud_ssh_key_removecloud:selfRemove a key from the account (204); it is not removed from running machines. Requires Idempotency-Key.
GET /term-planscloud_term_plans_listcloud:selfMonthly VPS plans: configuration, monthly price, whether there is room, months and discounts, add-ons.
POST /term-quotecloud_term_quotecloud:selfQuote a new VPS or a renewal; returns total and expectedTotal to send back when buying.
POST /term-orderscloud_term_buycloud:self:spendBuy a VPS from the wallet (201); needs expectedTotal and acceptTerms: true. Requires Idempotency-Key.
POST /instances/:ids/renewcloud_term_renewcloud:self:spendRenew from the wallet (201); needs expectedTotal and revision. Requires Idempotency-Key.
PATCH /instances/:ids/termcloud_term_auto_renew_setcloud:self:spendTurn auto-renewal on or off and set the months per renewal. Requires Idempotency-Key.
GET /instances/:ids/portscloud_my_ports_getcloud:selfThe VPS’s ports: system ports, port range, open rules and revision.
PUT /instances/:ids/portscloud_my_ports_setcloud:selfReplace all port rules, with expectedRevision. Requires Idempotency-Key.
GET /instances/:ids/domainscloud_my_domains_listcloud:selfThe VPS’s free domain and custom domains, and the DNS records to point; rename says whether the free domain can be renamed. Domains issued by AIDev (for example vps12345678.onaidev.com) already have HTTPS from the gateway; you need not and cannot request a certificate yourself with certbot, Coolify or Traefik for this host; inside the VM, just serve HTTP on an internal port. Custom domains in gateway mode also get certificates automatically.
POST /instances/:ids/domainscloud_my_domain_addcloud:selfAdd a custom domain (201). verify returns the records to create: a subdomain needs only a CNAME to cname; an apex domain uses an A record pointing at the IP of cname plus a TXT txtName = txtValue.
PUT /instances/:ids/domains/sitecloud_my_site_label_setcloud:selfName the free domain: send a name part of 3–24 characters a-z0-9-; the system adds 4 random characters to make <name>-xxxx, so names never clash or impersonate. Send exactly vps<number> to return to the default name. The real host is in the response.
PATCH /instances/:ids/domains/:domainIdscloud_my_domain_updatecloud:selfChange a domain’s mode or internal port.
DELETE /instances/:ids/domains/:domainIdscloud_my_domain_removecloud:selfRemove a custom domain (204). Requires Idempotency-Key.

curl examples

Put the token in an environment variable
export AIDEV_TOKEN=aidev_pat_…
List plans
curl -s "https://api.aidev.edu.vn/capi/v1/cloud/plans?limit=20" -H "Authorization: Bearer $AIDEV_TOKEN"
Rent a machine (keep the same KEY if you must resend after a timeout)
KEY=$(uuidgen) curl -s -X POST "https://api.aidev.edu.vn/capi/v1/cloud/instances" -H "Authorization: Bearer $AIDEV_TOKEN" \ -H "Idempotency-Key: $KEY" -H "Content-Type: application/json" \ -d '{"planIds":"<planIds>","imageIds":"<imageIds>","sshPublicKeys":["ssh-ed25519 AAAA… you@laptop"],"expectedPricePerHour":"<price VND/hour>"}'
Start a machine
curl -s -X POST "https://api.aidev.edu.vn/capi/v1/cloud/instances/<ids>/start" -H "Authorization: Bearer $AIDEV_TOKEN" \ -H "Idempotency-Key: $(uuidgen)" -H "Content-Type: application/json" \ -d '{"revision":"<revision>"}'
Terminate a machine
curl -s -X DELETE "https://api.aidev.edu.vn/capi/v1/cloud/instances/<ids>?revision=<revision>" -H "Authorization: Bearer $AIDEV_TOKEN" \ -H "Idempotency-Key: $(uuidgen)"

OpenAPI reference

RouteRequired parametersBody
GET /capi/v1/cloud/plans——
GET /capi/v1/cloud/plans/{ids}ids (path)—
GET /capi/v1/cloud/instances——
POST /capi/v1/cloud/instancesIdempotency-Key (header)JSON
GET /capi/v1/cloud/instances/{ids}ids (path)—
DELETE /capi/v1/cloud/instances/{ids}ids (path), Idempotency-Key (header), revision (query)—
POST /capi/v1/cloud/instances/{ids}/startids (path), Idempotency-Key (header)JSON
POST /capi/v1/cloud/instances/{ids}/stopids (path), Idempotency-Key (header)JSON
POST /capi/v1/cloud/instances/{ids}/restartids (path), Idempotency-Key (header)JSON
GET /capi/v1/cloud/term-plans——
POST /capi/v1/cloud/term-quote—JSON
POST /capi/v1/cloud/term-ordersIdempotency-Key (header)JSON
POST /capi/v1/cloud/instances/{ids}/renewids (path), Idempotency-Key (header)JSON
PATCH /capi/v1/cloud/instances/{ids}/termids (path), Idempotency-Key (header)JSON
GET /capi/v1/cloud/instances/{ids}/portsids (path)—
PUT /capi/v1/cloud/instances/{ids}/portsids (path), Idempotency-Key (header)JSON
GET /capi/v1/cloud/instances/{ids}/domainsids (path)—
POST /capi/v1/cloud/instances/{ids}/domainsids (path)JSON
PUT /capi/v1/cloud/instances/{ids}/domains/siteids (path)JSON
PATCH /capi/v1/cloud/instances/{ids}/domains/{domainIds}ids (path), domainIds (path)JSON
DELETE /capi/v1/cloud/instances/{ids}/domains/{domainIds}ids (path), domainIds (path), Idempotency-Key (header)—
GET /capi/v1/cloud/ssh-keys——
POST /capi/v1/cloud/ssh-keys—JSON
DELETE /capi/v1/cloud/ssh-keys/{ids}ids (path), Idempotency-Key (header)—

Full OpenAPI document: https://api.aidev.edu.vn/capi/v1/openapi.json

6. Billing and limits

A stopped machine is still billed

Machines are billed by the hour from your AIDev wallet. A powered-off machine is still billed; only terminating stops the charge. When the wallet runs out, the system reclaims the machine, and the data on its disk is lost just as when you terminate it.

  • No limit on the number of machines.
  • By default 1000 write calls a day (Vietnam time) per token, adjustable on the token management page; reads, refused or failed calls, resends of the same request and terminations do not count toward this limit.
  • Start, stop, restart: at most 1 call per minute per machine.
  • 120 calls per minute per token.
  • CLOUD_LOW_RUNWAY: counting the new machine, the balance covers under 3 hours of running; the agent asks you again and creates the machine only if you agree.
  • INSUFFICIENT_FUNDS: top up your wallet on the web, then try again.
  • CLOUD_PRICE_CHANGED: the price changed; the agent reads it again and asks you again, and if you agree, it resends with a new Idempotency-Key.

7. Error codes

CodeWhenWhat to do
AGENT_GATEWAY_DISABLED503: the agent gateway is temporarily off.Try again later.
UNAUTHORIZED401: the token cannot be used. See details.reason.AGENT_TOKEN_INVALID (wrong, expired, revoked): create or rotate a token. CLOUD_AGENT_DISABLED: the feature is off until AIDev turns it on; a new token will not help.
AGENT_SCOPE_FORBIDDEN403: the token lacks the call’s scope.Create a token with cloud:self:spend if you need to rent or terminate machines.
AGENT_ROLE_FORBIDDEN403: the account may not use this call.Contact AIDev.
AGENT_RATE_LIMITED429: over the call limit, or more than 1 start/stop per minute for one machine.Wait details.retryAfter seconds, then try again (per-call and per-machine limits also carry details.retryAfterSeconds).
AGENT_LIMIT_UNAVAILABLE500: the call’s limit cannot be counted right now; nothing was written.Try again in about a minute, keeping the same requestId if the call has one.
VALIDATION_ERROR400: invalid parameters, including an invalid key (sshPublicKeys.<i>), more than 5 keys in one array, or no key at all.See details.issues.
RESOURCE_NOT_FOUND404: no such machine, plan or key in your account.Check the ids.
PAYLOAD_TOO_LARGE413: the REST body is larger than 100 KB.Send a smaller body.
INTERNAL_ERROR500: an error on AIDev’s side.Try again later; if it keeps happening, report it to AIDev with the requestId.
IDEMPOTENCY_KEY_REQUIRED400 (REST only): a write call is missing the Idempotency-Key header.Send a new uuid for every new call.
AGENT_REQUEST_IN_PROGRESSA call with the same requestId is still running.Wait 10–30 seconds, then resend that same requestId.
AGENT_REQUEST_ID_REUSEDThe requestId was already used for a call with different parameters.Do not change parameters when resending; a new call needs a new requestId.
AGENT_REQUEST_FAILEDA call with the same requestId failed earlier (details.originalCode).Handle it by originalCode. For a rental: check GET /instances?status=all before sending a new requestId.
AGENT_IDEMPOTENCY_UNAVAILABLEThe requestId cannot be checked right now.Try again in a few minutes.
CLOUD_PRICE_CHANGEDRental: expectedPricePerHour differs from the current price (details.pricePerHour).Read the price again and ask the account owner again; if they agree, resend with a new requestId (Idempotency-Key).
CLOUD_LOW_RUNWAYRental (409): counting the new machine, the wallet and Cloud credit cover the machines for under 3 hours (details.runwayMinutes).Tell the account owner: when the money runs out, the machine stops on its own and its data is deleted. If they agree, resend with acknowledgeLowRunway: true and a new requestId (Idempotency-Key), or top up and try again.
INSUFFICIENT_FUNDSRental: the wallet and Cloud credit do not cover the first hour (details.required, details.available).Top up your wallet on the web, then try again.
CLOUD_NO_CAPACITYRental: the plan has no free server or IP.Choose another plan or wait.
CLOUD_PUBLIC_IP_UNAVAILABLERental: no public IP is left.Rent again without usePublicIp; the price is then pricePerHour (ask the account owner again).
CLOUD_PLAN_INACTIVERental: the plan is no longer on sale.Choose another plan.
CLOUD_IMAGE_INCOMPATIBLERental: the operating system cannot be used with this plan.Choose one of that plan’s own images.
CLOUD_SSH_KEY_TOO_MANYRental: saved keys plus pasted keys exceed 5.Send 1 to 5 keys in total.
FEATURE_DISABLEDRental: AIDev has paused rentals for now.Try again later.
AGENT_STALEThe machine changed since you last read it.Read the machine again and take the new revision.
AGENT_CLOUD_VM_STATEThe machine is not in a state that allows this call.See the machine’s allowedActions.
CLOUD_INSTANCE_VM_STATE_CHANGED409, start/stop/restart: the machine’s state just changed.Read the machine again, then try again.
CLOUD_INSTANCE_ALREADY_TERMINATEDTerminate: the machine was already terminated or reclaimed.Nothing more to do.
CONFLICT_ERROR409, terminate: another operation is running on the machine.Read the machine again, then try again.
BILLING_CLOUD_CREDIT_SETTLE_RETRYTerminate: billing is not settled yet.Resend with the same old requestId.
BILLING_CLOUD_CREDIT_HOLD_STALETerminate: billing is not settled yet.Resend with the same old requestId.
CLOUD_SSH_KEY_LIMITSave key: the account already has 20 keys. An already saved key still returns 201 with existing: true.Remove keys you no longer use.
CLOUD_SSH_KEY_DUPLICATEOn the web: the key is already in the account.Use the existing key; its id is in details.ids.
CLOUD_TRUST_DISABLED409, monthly VPS: AIDev has temporarily closed these calls to agents.Do it on the web, or try again later.
SHOP_PRICE_CHANGEDBuy or renew a VPS: expectedTotal differs from the current total.Quote again and ask the account owner again; if they agree, resend with a new requestId.
CLOUD_TERM_VERIFICATION_REQUIRED403, buy a VPS: the account must be verified before buying more.The account owner leaves a phone number on the web.
CLOUD_TERM_RENEW_STALE409, renew: the machine’s expiry just changed (it may already be renewed).Read the machine again and check the new expiry before renewing again.
CLOUD_TERM_SUSPENDED_BY_STAFF403, renew: AIDev has suspended the machine (see details.reason); nothing was charged.Do not retry. The account owner contacts AIDev support; only AIDev can lift it.
CLOUD_VPS_WINDOWS_RESOURCESBuy a Windows VPS: the configuration is below what Windows needs.Choose a larger plan or add add-ons.
CLOUD_VPS_LICENSE_ACK_REQUIREDBuy a Windows VPS: the license acknowledgement is missing.Ask the account owner; if they agree, send windowsLicenseAck: true.
CLOUD_TERM_DELETE_WEB_ONLYTerminating a monthly VPS through an agent.The account owner terminates the machine on the web.
CLOUD_PORT_RULES_STALE409, ports: the port rules changed since you last read them (details.revision).Read the ports again, then resend with the new expectedRevision.
CLOUD_PORT_OUT_OF_RANGEPorts: an external port is outside the machine’s range (details.from, details.to).Choose a port within that range.
CLOUD_PORT_DUPLICATEPorts: an external port appears twice.One rule per external port.
CLOUD_SUBDOMAIN_NOT_INCLUDEDRename the free domain: the machine’s plan does not support custom names.Keep the vps<number> name, or upgrade to a plan that supports it.
CLOUD_SUBDOMAIN_VERIFICATION_REQUIREDRename the free domain: the account is not verified.The account owner verifies on the web, then tries again.
CLOUD_SUBDOMAIN_RENAME_LIMITRename the free domain: it was renamed recently.Try again after details.retryAt.
CLOUD_DOMAIN_PASSTHROUGH_VERIFICATION_REQUIREDCustom domain in passthrough mode: the account is not verified.The account owner verifies on the web, or uses gateway_ssl mode.

8. Security

  • Never send a private key to an agent or to AIDev: only the public key (.pub) leaves your machine.
  • If a token leaks, rotate or revoke it right away on the agent token page.
  • After the agent creates a machine, open the machine’s details on the web, look at the "SSH keys on the machine" block and compare the fingerprint with your key.
Show your key’s fingerprint
ssh-keygen -lf ~/.ssh/aidev.pub