# 0x.cloud: rules for AI agents

API: `https://0x.cloud/v1`. Key: header `Authorization: Bearer 0x_live_...`. Reference: `https://0x.cloud/v1/openapi.json` and `https://0x.cloud/llms-full.txt`. MCP: `https://0x.cloud/v1/mcp` (OAuth 2.1 sign-in or the same Bearer key).

## Getting in

- The person already has an account: ask them to connect your MCP client through OAuth (they choose scopes, spend limit and expiry on the 0x.cloud page) or to create a key in the account area, section "API and MCP".
- No account: `POST /v1/signup` `{"email": "<the person's email>", "client": "<your program>"}` opens an account that belongs to that person and returns a key once: store it. Tell the person to open the letter from 0x.cloud and confirm the address. Until then the account may run one s1-1 or s1-2 server and top up at most $50 in all; a call beyond that answers 403 `email_not_confirmed` with a `hint`. The key spends at most $20 a month.
- `409 email_taken`: the person already has an account. Do not try other addresses: ask them for a key or for the OAuth sign-in.
- Never sign up with a disposable mailbox or an address that is not the person's own.

## Start

First call: `GET /v1/overview` (MCP `get_overview`): the key and its limits, the balance and how many days it lasts, servers with notes, what waits for the owner's answer. When you continue earlier work, read the server notes and `GET /v1/account/key/activity` (`get_my_activity`).

Before you finish, leave a note on every server you worked with: `PATCH /v1/servers/{id}` `{"note": "..."}` (`set_server_note`): what the server is for, what is deployed, what is unfinished. Never put passwords or keys there.

When an MCP tool answers with an error, read `agent_hint`: it says what to do next.

## Identifiers

Everything is named by strings like `srv_8f3k2m9x4qpz7w1c` (the first three letters are the kind). Take the identifier from an API answer and pass it as it is: numbers are not accepted.

## Before spending money

0. Check what your key may do: `GET /v1/account/key` (`get_key_info`): scopes and the spend rule.
1. Prices: `GET /v1/public/pricing` (no key) or `GET /v1/plans`.
2. Balance: `GET /v1/balance`. Not enough money: `GET /v1/payment-methods`, then `POST /v1/topups` with the amount and `method`; give the payment link to the person, they pay. `409 payments_unavailable` with `agent_hint: do_not_retry`: no online method is on now, do not retry; tell the person that support tops up the balance through a ticket.
3. Exact price: `POST /v1/servers` with `"dry_run": true` and the same `plan`, `billing_cycle`, `extra_disk_gb` you will order. The answer has the USD amount, `resources`, `pricing_fingerprint` and `pricing_expires_at`. The fingerprint is opaque and valid 10 minutes: never change or build it.
4. Show the price and the resources to the person. Only after their explicit yes create the server with the same request without `dry_run`, the unchanged `pricing_fingerprint` and an `Idempotency-Key` header.
5. `409 price_changed`: the quote expired or changed. Nothing was created or charged: show `error.quote`, get a new yes and create with a new request and a new `Idempotency-Key`. Never repeat this automatically. After an unknown network outcome repeat only the same body with the same fingerprint and idempotency key while the quote is valid.
6. A plan with `is_auto_provision: false` is issued by a person. The same `dry_run` still gives the quote. After an explicit yes to the price and to a manual issue, send `POST /v1/server-requests` with the same `plan`, `billing_cycle`, `pricing_fingerprint` and `"accept_manual_issue": true` (no `extra_disk_gb`, no `from_snapshot`). Do not promise a delivery time.
7. `402 key_spend_limit_reached` or `403 key_spend_forbidden`: the key cannot afford this. Do not look for a way around it; see "When you are refused".

## What not to promise the person

- Check `has_public_ip` and `GET /v1/servers/{id}/ips`. When the server has no public address, it cannot be reached from the internet by SSH or HTTP: you work on it through `exec` (below), the person through the web console at `https://0x.cloud/cabinet`. Do not give the person an IP address you did not read from the API, and do not probe the server from outside.
- The firewall is not inside the server but in front of it: `PUT /v1/servers/{id}/firewall` (`set_firewall`). Do not install ufw or write iptables rules: set the allowed ports through the API. Outgoing port 25 is closed on every server; ask with `POST /v1/servers/{id}/port25-request` (`request_port25`), a person decides.
- Backups are paid (+20% of the plan) with their own schedule: `/v1/servers/{id}/backups`. Snapshots ($1 a month each) live apart from the server: `/v1/snapshots`; a new server from a snapshot: `POST /v1/servers` with `from_snapshot`. `GET /v1/servers/{id}/capabilities` says what is possible now.
- `not_available` means the method is not offered: do not retry and do not look for a way around it.
- Do not promise uptime, speed or delivery times that the API does not state.

## Inside the server

You can run the server yourself: `POST /v1/servers/{id}/exec` with `{"command": "..."}` runs a command as root and returns stdout, stderr and the exit code (MCP `run_command`). No SSH, password or key: the command goes through the hypervisor. Scope: `servers.exec`.

- Without `session` every command is a new shell: write `cd /srv/app && ./deploy.sh`. With `"session": "main"` the directory and exported variables stay between calls.
- No keyboard input: `apt-get install -y`, `DEBIAN_FRONTEND=noninteractive`. Editors do not work: read and write files through `/v1/servers/{id}/files` (`read_file`, `write_file`), change them in place with `edit_file`, look around with `list_directory` and `search_files`.
- Anything longer than a minute (build, install, upgrade): `"background": true`, you get a `job_id`. Read the output as it comes: `GET /v1/servers/{id}/jobs/{job_id}?offset=<next_offset>&wait=25` (`get_job`); stop with `DELETE` of the same address (`stop_job`).
- A normal command longer than 30 seconds: set `timeout` up to 3600. `"status": "running"`: fetch the result by `command_id`.
- Short of memory, disk or CPU: `GET /v1/servers/{id}/health` (`get_server_health`), see `advice`.
- Right after a start or restart the server may answer `guest_agent_unavailable` for up to two minutes: wait `retry_after` seconds. `guest_exec_disabled`: this system refuses such commands; tell the person the web console is needed.
- Pass secrets through `"env": {"NAME": "value"}`, not in the command text: the start of a command goes to logs, `env` values do not.
- Check `exit_code`: non-zero means the command failed, the reason is usually in `stderr`.
- You are root. Do not delete data, change passwords or stop services the person did not ask about.

## Long operations

After creation or a reinstall call `GET /v1/servers/{id}/wait?timeout=25` while `"ready": false`.

Wait for everything else (snapshot ready, startup script finished, owner answered, money credited) with `GET /v1/events?wait=25&types=...` (`wait_for_event`), not with a polling loop. Pass `cursor` as `after`.

To set the server up by itself after creation, pass `startup_script` to `POST /v1/servers`: the sh script runs as root when the system is ready; its state is in the `startup` field.

## When you are refused

- 402 `key_spend_limit_reached`, 403 `key_spend_forbidden`, 403 `approval_required`, 403 `scope_escalation` or 403 `spend_limit_escalation` with an `approval` field: the owner has been asked. Tell the person and wait: `GET /v1/approvals/{id}?wait=25` (`get_approval`). After `approved` repeat the same call with the same arguments: it goes through once. After `denied` do not repeat.
- A sum above the limit needed in advance: `POST /v1/approvals` `{"amount_usd", "reason"}` (`request_approval`).
- 403 `human_only`: only the person can do this in the account area (password, two-factor protection, sign-in methods, account deletion, granting `billing.withdraw`). Tell them; do not ask for their password or codes.
- 404 `server_not_found` for a key limited to its own servers: you did not create this server and cannot see it.

## Keys you create

You may create keys for helpers (`POST /v1/api-keys`, `create_api_key`) no wider than your own key and within your own remaining limit; their spending counts against yours and they die with your key. Give a helper only the scopes its task needs, and revoke it (`revoke_api_key`) when the task is done.

## Withdrawals

Money paid in can be withdrawn in USDT (TRC20 or TON, from $10, the network fee is on the customer) with `POST /v1/withdrawals`, scope `billing.withdraw`, which only a person grants. Ask the person before requesting a withdrawal; they confirm it by the link in the email. Never send money to an address the person did not give you.

## Dangerous actions

- `DELETE /v1/servers/{id}` switches the server off; the remainder returns to the balance and the server can be restored for 24 hours with `POST /v1/servers/{id}/restore`. Delete only servers you created or the person named.
- `POST /v1/servers/{id}/install` erases the disk. Ask the person first.
- MCP tools `delete_server`, `reinstall_server`, `freeze_server`, `restore_backup`, `restore_snapshot` and `delete_snapshot` need `"confirm": true`. Set it only when the person asked for exactly that.

## Freezing

A server not needed now, but its data is: `POST /v1/servers/{id}/freeze`: the disk goes to storage, the rest of the paid period returns to the balance, storage costs 20% of the plan. Back: `POST /v1/servers/{id}/unfreeze` (2–5 minutes, data and root password stay, a server paid per period is charged a new period). Ask the person first: the server goes off.

## Temporary servers

For tasks of a few hours create the server with `"billing_cycle": "hourly"` and `"ttl_hours"` (or `"ttl_minutes"`, from 10): it deletes itself. Move or remove the timer: `PATCH /v1/servers/{id}` `{"ttl_minutes": 120}` (`0` removes it; MCP `set_server_ttl`). Done earlier: delete the server at once.

## Secrets

The root password and API keys are shown once. Never write them into logs, repositories or messages in shared chats.
