Xuda logo Xuda Docs User Guides
/
xuda.io
← All guides External VPS

Xuda External VPS API Reference

Source file: xuda-external-vps-api-reference.md

Xuda External VPS API Reference

This reference covers the full method surface of Xuda External VPS: connecting a Linux server you already own over SSH, reading its live metrics, driving its filesystem and services remotely, publishing it on a public HTTPS URL, minting tokenized developer SSH access, managing the account's SSH keys, and handing the whole thing to an AI agent over Xuda's MCP layer. It is written for developers and agent builders who want to script against a connected server instead of clicking through the dashboard. Forty-three methods are documented here: thirty-four a developer API key can call, and nine that only a signed-in dashboard session can. Every method key, parameter name, type and required flag below is taken from the shipped method contract.

How To Call These Methods

Every method here is a CPI method. CPI methods are dispatched by name over the Xuda API and MCP layer, and the normal credential for that layer is the account API key. For the transport-level detail, including how requests are framed and how the MCP layer exposes methods, see /api-mcp-integration.

Three things shape what you can actually automate with External VPS.

Connecting a server is a dashboard-only action. create_external_vps and verify_external_vps_ssh are both flagged private, so an API key cannot register a new server or run the SSH verification. Bring the server online through the connect wizard once, then automate everything after that with a key.

Almost everything after connection is API-key reachable. The file surface, the service actions, the metrics sampler, the public web URL, developer SSH accesses, session and command history, the access opt-ins, the stored diagnose report and app deletion are all non-private, so a full-access API key or an allowlisted custom key can call them, and the MCP layer registers each one as a tool. Five methods are marked mcp: true and are shaped deliberately as agent tools: the app or the account they act on is resolved from the key, never from the model.

Access is opt-in per feature. External VPS is one of only two app types where the consent gate actually blocks. Five named scopes exist (files, backup, metrics, ask_ai, diagnose), and a call into a scope that has not been granted returns { code: -91, consent_required: true, scope } instead of doing the work. Consents are granted and revoked through save_deploy_settings and their current state is readable on get_app_info.

What The Availability Labels Mean

Every method below carries exactly one availability line. Read it first, because it tells you whether you can call the method from your own code today.

  • Availability: API key means an external developer API key or the MCP layer can call it. Thirty-four External VPS methods carry this label.
  • Availability: Dashboard session means a signed-in user in the Xuda dashboard can call it, and an API key cannot. The method is flagged private: true, which excludes it from the API-key catalog and refuses API-key callers. Nine methods carry this label.
  • Availability: Public endpoint means no authentication at all. No External VPS method carries this label.
  • Availability: Operator only means Xuda staff, listed only for completeness. No External VPS method carries this label.

One note on the clearance values quoted in the per-method notes: user means an authenticated account, admin means an app-admin token and is NOT a Xuda superuser, and user_access means any principal with access to the app.

Method Index

Method What It Does
create_external_vps Registers a server you already own and returns the one-line authorize command.
verify_external_vps_ssh Proves SSH reachability, captures the host fingerprint and specs, and activates the app.
get_app_info Reads the whole server record, including hosting details and the consent state.
get_app_server_usage Samples live CPU, memory, disk and network over SSH and returns the time series.
vps_fs_list Lists a directory on the server over SFTP.
vps_fs_read Reads one file, detecting text, image and binary content.
vps_fs_write Creates or overwrites one file.
vps_fs_write_batch Writes many files over a single SFTP session.
vps_fs_mkdir Creates a directory and any missing parents.
vps_fs_rename Renames or moves a file or directory within the server.
vps_fs_delete Deletes a file, or a directory recursively.
vps_fs_search Searches a subtree by file name or by file contents.
vps_fs_disk_usage Returns one-level disk usage of a directory, largest first.
vps_fs_tail Returns the tail of a file, with an offset for incremental log following.
vps_fs_service_action Runs one bounded service action from a frozen allowlist.
vps_enable_web_url Publishes the server on a public HTTPS xuda.app URL.
vps_disable_web_url Stops serving the public URL and pulls the router index.
vps_set_web_port Changes the upstream port and scheme the public URL proxies to.
vps_ssh_access_create Creates a named SSH over WebSocket developer access and mints its one-time token.
vps_ssh_access_list Lists every developer access with status and live online state.
vps_ssh_access_update Edits an access label or expiry.
vps_ssh_access_rotate Regenerates an access token, invalidating the previous one.
vps_ssh_access_set_status Suspends or re-activates an access at the tunnel.
vps_ssh_access_delete Deletes an access and kills its token immediately.
vps_ssh_session_events Lists tunnelled SSH and SFTP session envelopes.
vps_ssh_command_log Reads the in-server command history for interactive sessions.
vps_ssh_command_log_set Turns the in-server command log on or off.
save_deploy_settings The single write path for access opt-ins and the Auto Diagnose add-on.
get_vps_diagnose_report Returns the last stored Auto Diagnose report.
get_logs Queries the per-app action history.
destroy_app Deletes the Xuda app without touching the remote machine.
agent_firewall_list Agent tool: lists open inbound ports on the key's app.
agent_firewall_open Agent tool: opens inbound TCP ports.
agent_firewall_close Agent tool: closes inbound TCP ports.
agent_domain_list Agent tool: lists the account's registered domains.
agent_domain_connect Agent tool: points one of the account's domains at the key's app.
get_ssh_keys Reads the account's stored SSH public keys.
save_ssh_key Validates and stores an SSH public key on the account.
set_ssh_key_enabled Switches a stored key on, or off and off every server.
delete_ssh_key Soft-deletes an SSH key document.
get_ssh_key_events Reads the account SSH access log.
assign_ssh_keys Installs stored public keys on the connected server.
revoke_ssh_keys Removes exactly those key lines from the server's authorized_keys.

create_external_vps

Create External VPS

Registers a third-party VPS the user already owns as an external_vps app (SSH inventory). It creates the app document in a pending state (app_status_code: 2, "pending ssh verification") and returns a one-line bootstrap command that authorizes Xuda's platform public key on the target server. It stores no password and no private key. The response is { code: 1, data: { app_id, app_obj: { _id }, bootstrap_command, ssh_user, host, port } }. If the platform public key is unavailable the app is still created, bootstrap_command is null and the response carries warning: 'platform ssh key unavailable'. Fields are accepted both nested under data and flat.

Availability: Dashboard session

Parameters

Name Type Required Description
data.app_name string Yes Display name for the external VPS.
data.host string Yes Hostname or IP address of the external server.
data.port number No SSH port (default 22). Must be an integer between 1 and 65535.
data.ssh_user string No Login user on the target server (default root).
data.provider_label string No Optional free-text label for the server's provider. Stored on app_hosting_server.provider_label and used as the Region label when it is not the literal external.

Notes

  • Clearance user. Flagged private: true, so this is a dashboard-session method and an API key cannot register a server.
  • No min_plan gate, and creating an External VPS is free: the app is created with no server slug, so the cost calculator computes a monthly total of zero and writes no app_cost record.
  • The plan project cap does not apply. validate_user_plan enforces caps on master projects and team shares only, so there is no plan quota on the number of connected servers.
  • data.logs_manager (boolean) is undeclared in the method contract but accepted by the implementation and persisted as logs_manager on the app document. It no longer gates anything: the Logs tab always shows.
  • The returned bootstrap_command appends Xuda's platform public key to ~/.ssh/authorized_keys on the customer's own machine. Show it to the customer to read before they run it. Nothing else is exchanged.

verify_external_vps_ssh

Verify External VPS SSH

Verifies SSH reachability of an external_vps app using Xuda's platform key, non-interactively (BatchMode=yes, StrictHostKeyChecking=accept-new, bounded ConnectTimeout). On success it captures the host key fingerprint plus basic server info (uname, hostname, login user, df, free, vCPU count, total memory, total disk) and marks the app active (app_status_code: 3). On failure it leaves the app pending (app_status_code: 2) and records the reason in app_hosting_server.last_verify_error. Success returns { code: 1, data: { server_info, fingerprint, hostname } }.

Availability: Dashboard session

Parameters

Name Type Required Description
app_id string Yes Id of the external_vps app to verify.

Notes

  • Clearance user. Flagged private: true, so an API key cannot call it. No min_plan.
  • Safe to repeat. Verification is idempotent: a failed attempt leaves the app pending and a later attempt against the same app promotes it once the key is in place.
  • The connect timeout is bounded by the platform external_vps.ssh_timeout setting, which is 10 seconds on production. The command never prompts and never hangs.
  • A failure returns a human-readable reason such as "unreachable or key not authorized yet", and the stored last_verify_error is truncated to 500 characters.
  • Verification honors the app's own ssh_user and port. Note that the file methods do not, see Known Gaps That Affect Integrations.

get_app_info

Get App Info

Returns the full app record the dashboard renders, including app_hosting_server (ip, port, ssh_user, hostname, fingerprint, last_verified_ts, vcpus, memory, disk, region_name), app_status_code, vps_web, keys, and, for server-shaped apps, DATA.vps_access_scopes (the catalog plus the dialog copy) and DATA.vps_access_consents (the current grant state for all five scopes) plus DATA.vps_access_enforced.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes The application whose data will be retrieved.

Notes

  • Clearance user_access. Not private, so an API key and the MCP layer can call it. No min_plan.
  • This is the method to poll for connection state: app_status_code is 2 while the server is pending SSH verification and 3 once it is verified.
  • Read DATA.vps_access_consents before calling anything that touches the server. It tells you which of the five scopes are granted and will therefore not answer -91.
  • The scope catalog it returns carries the dialog title, the read-write badge and the reason sentence for each scope, served from the backend, so a client never has to hard-code that copy.

get_app_server_usage

Get App Server Usage

Returns the usage time series for the server. For an external_vps this branches to the SSH sampler: it opens one SSH session, takes two /proc/stat and /proc/net/dev readings one second apart plus free -b, df -B1 -P /, nproc and hostname, appends the sample to the rolling usage document, backfills vCPU, memory, disk and region onto the app document when they changed, and returns bandwidthMetrics (inbound and outbound in Mbps), cpuMetrics (idle and busy series), availableMemoryMetrics, freeMemoryMetrics, totalMemoryMetrics and diskMetrics in Prometheus matrix shape with unix-second timestamps.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application this request targets.
ts_start number Yes Start timestamp (unix seconds).
ts_end number Yes End timestamp (unix seconds).

Notes

  • Clearance admin. Not private, API key reachable. No min_plan.
  • Consent gate: blocked with { code: -91, consent_required: true, scope: 'metrics' } when the Overview metrics opt-in has not been granted. External VPS is the only app type where this gate still blocks, because it is the only case where reading metrics means connecting to a machine Xuda does not run.
  • Every call is a live sample, not a cached read. There is no agent on the box, so each call costs one SSH session and at least one second of wall clock for the two-reading window. The connect timeout for the sampler is 6 seconds.
  • Every sample is stored, so history gets denser the more often you poll. The rolling usage document keeps the most recent 2000 samples per server and drops older ones.
  • The dashboard's Live toggle polls this method every two minutes. Pick a comparable interval rather than a tight loop.

The File Methods As A Group

The eleven vps_fs_* methods share one contract, so it is stated once here and not repeated eleven times below.

  • All eleven have clearance user, are not private, are API-key and MCP reachable, and carry no min_plan.
  • All eleven require the files opt-in on an External VPS. Without it they answer { code: -91, consent_required: true, scope: 'files' }. files is the only read-write scope of the five.
  • app_id is declared optional on most of them because the dashboard supplies it from context. Always send it from your own code.
  • Paths are absolute. The default working path is /root where a path is optional.
  • The whole surface is bounded on purpose: 5 MB inline read, 128 files and 64 MB decoded per batch upload, 300 search results, a 25 second exec timeout, 512 KB of captured output, a 64 KB first tail page and 256 KB per further page.

vps_fs_list

VPS Files: list directory

Lists a directory on the server over SFTP and returns typed entries sorted directories first then case-insensitively by name. Each entry carries name, path, type (dir or file), is_symlink, size, mtime (milliseconds) and mode (octal string). Symlinks and .. are collapsed with realpath when possible.

Availability: API key

Parameters

Name Type Required Description
app_id string No Unique identifier of the application this request targets.
path string No Absolute directory path to list. Defaults to /root.

Notes

  • Requires the files opt-in. See The File Methods As A Group.
  • mtime is in milliseconds while the usage series uses unix seconds. Do not mix the two.

vps_fs_read

VPS Files: read file

Reads one file over SFTP. It detects text, image and other binary content: images come back base64 with a mime type, binaries are detected with a NUL-byte sniff of the first 8000 bytes, and text comes back as UTF-8 with a guessed syntax language.

Availability: API key

Parameters

Name Type Required Description
app_id string No Unique identifier of the application this request targets.
path string Yes Absolute path of the file to read.

Notes

  • Requires the files opt-in.
  • Files larger than 5 MB return { too_large: true } instead of content. Handle that flag rather than assuming content is always present.

vps_fs_write

VPS Files: write file

Creates or overwrites one file over SFTP. The parent directory must already exist. Returns the path and the byte count written.

Availability: API key

Parameters

Name Type Required Description
app_id string No Unique identifier of the application this request targets.
path string Yes Absolute path of the file to write.
content string No File contents. Empty when omitted.
encoding string No Content encoding: utf8 (default) or base64.

Notes

  • Requires the files opt-in, which is the read-write scope.
  • Overwrite, not append. There is no read-modify-write protection, so two writers racing on one path will lose one of the two versions.
  • Call vps_fs_mkdir first if the parent directory may not exist.

vps_fs_write_batch

VPS Files: batch upload

Writes many files over a single SFTP session, creating parent directories as needed, which is the fast path for folder uploads. Everything is decoded and validated up front, then written one by one. Returns { written, failed, results: [{ path, ok, size | error }] }.

Availability: API key

Parameters

Name Type Required Description
app_id string No Unique identifier of the application this request targets.
files array Yes Array of { path, content, encoding } objects to write. Every path must be absolute.

Notes

  • Requires the files opt-in.
  • Limits: at most 128 files per call, at most 5 MB per file and at most 64 MB decoded per batch. Split larger uploads yourself.
  • Not atomic. A single failed file does not abort the rest, so always read failed and the per-path results array rather than treating a code: 1 envelope as full success.

vps_fs_mkdir

VPS Files: create directory

Creates a directory over SFTP, walking and creating each missing parent in turn, then confirms the result really is a directory, so a file already sitting at that path returns a clear error.

Availability: API key

Parameters

Name Type Required Description
app_id string No Unique identifier of the application this request targets.
path string Yes Absolute directory path to create.

Notes

  • Requires the files opt-in.
  • Effectively idempotent for a path that is already a directory. A path already occupied by a file is refused with an explicit error.

vps_fs_rename

VPS Files: rename / move

Renames or moves a file or directory within the server over SFTP.

Availability: API key

Parameters

Name Type Required Description
app_id string No Unique identifier of the application this request targets.
from string Yes Absolute source path.
to string Yes Absolute destination path.

Notes

  • Requires the files opt-in.
  • Both paths must be absolute and neither may be /.

vps_fs_delete

VPS Files: delete

Deletes a file or a directory over SFTP. Directories are removed recursively, and lstat is used so a symlink is unlinked rather than followed.

Availability: API key

Parameters

Name Type Required Description
app_id string No Unique identifier of the application this request targets.
path string Yes Absolute path of the file or directory to delete.

Notes

  • Requires the files opt-in.
  • Recursive and not recoverable. Deleting the filesystem root is refused outright, but nothing else is protected, so validate the path before you send it from an agent.

vps_fs_search

VPS Files: search

Searches a subtree either by file name (find -iname) or by file contents (grep -IniHF, case-insensitive fixed string, binaries skipped, files over 8 MB skipped). node_modules and .git are excluded and the search stays on one filesystem (-mount).

Availability: API key

Parameters

Name Type Required Description
app_id string No Application identifier.
path string No Directory to search under. Defaults to /root.
query string Yes Search text, minimum 2 characters.
mode string No name (default) or content.

Notes

  • Requires the files opt-in.
  • Capped at 300 results. The response flags capped and timed_out, so check both before treating a result set as complete.
  • The query must be at least 2 characters and is shell-escaped. Content mode is a fixed-string match, not a regular expression.

vps_fs_disk_usage

VPS Files: disk usage

Returns one-level disk usage of a directory: every immediate child (files and directories) with its total size in bytes, largest first, plus the directory's own total. Implemented with find -maxdepth 1 -type d plus du -ab --max-depth=1.

Availability: API key

Parameters

Name Type Required Description
app_id string No Application identifier.
path string No Directory to measure. Defaults to /root.

Notes

  • Requires the files opt-in.
  • Capped at 600 du lines, and it walks the real filesystem, so a large tree can run into the 25 second exec timeout. Measure a subdirectory at a time on big disks.

vps_fs_tail

VPS Files: tail file

Returns the tail of a file for live log following. With no offset it returns the last 64 KB plus the file's current size as offset. Pass that offset back on the next poll to get only what was appended.

Availability: API key

Parameters

Name Type Required Description
app_id string No Application identifier.
path string Yes Absolute path of the file to tail.
from_offset number No Byte offset returned by a previous poll.

Notes

  • Requires the files opt-in.
  • Incremental polling contract: keep the returned offset and send it as from_offset next time. Each incremental page returns at most 256 KB.
  • If the file shrank, because of rotation or truncation, the response sets reset: true and restarts from the new tail. Clear your buffered view when you see that flag.

vps_fs_service_action

VPS Files: service action

Runs one bounded service action after a config edit. Either action selects a fixed command (nginx_test, nginx_reload, apache_test, apache_reload, caddy_reload, systemd_daemon_reload) or verb plus unit runs systemctl <verb> <unit>. Returns { action, ok, exit_code, output }.

Availability: API key

Parameters

Name Type Required Description
app_id string No Application identifier.
action string No Fixed action key, for example nginx_reload.
verb string No systemctl verb: status, reload, restart, start or stop.
unit string No systemd unit name, required when verb is used.

Notes

  • Requires the files opt-in.
  • This is an allowlist, not a shell. Six fixed actions plus systemctl with five permitted verbs. The unit name must match ^[A-Za-z0-9._@:-]+$ and is shell-escaped. Anything else is refused, so there is no arbitrary command runner on this surface, by design.
  • Bounded at a 25 second exec timeout and 512 KB of captured output. A long systemctl restart can exceed the timeout even when the unit eventually comes up, so re-check with verb: 'status' rather than assuming failure.

vps_enable_web_url

VPS: enable web URL

Gives the server a public https://<sub>.xuda.app URL that reverse-proxies through the Xuda router to its own web server. The subdomain is the app id, allocated once and kept stable. Returns { subdomain, port, https, url }.

Availability: API key

Parameters

Name Type Required Description
app_id string No Application identifier.
port number No Upstream web port on the VPS to proxy to (default 80, range 1-65535).
https boolean No Proxy to https on the upstream instead of http (default false).

Notes

  • Clearance user. Not private, API key reachable. No min_plan, and the public URL costs nothing.
  • Idempotent per app. The subdomain is derived from the app id, so re-enabling always returns the same hostname.
  • Not automatic. Nothing provisions the web URL when a server is verified, so an integration that expects a public address must call this method explicitly.
  • Certificates and the public address are handled at the Xuda router. The server needs no dedicated IP and no certificate work of its own.

vps_disable_web_url

VPS: disable web URL

Stops serving the public xuda.app URL and pulls the router index immediately, while keeping the subdomain reserved on the app document for a later re-enable.

Availability: API key

Parameters

Name Type Required Description
app_id string No Application identifier.

Notes

  • Clearance user. Not private, API key reachable. No min_plan.
  • The subdomain is reserved, not released, so a later vps_enable_web_url restores the same hostname.
  • Disabling the web URL also removes the public hostname that the SSH over WebSocket tunnel rides on. Check for live developer accesses before you turn it off.

vps_set_web_port

VPS: set web port

Changes the upstream port, and optionally the scheme, that the public xuda.app URL proxies to inside the server.

Availability: API key

Parameters

Name Type Required Description
app_id string No Application identifier.
port number Yes Upstream web port on the VPS (1-65535).
https boolean No Proxy to https on the upstream instead of http.

Notes

  • Clearance user. Not private, API key reachable. No min_plan.
  • The port is the port your own web server listens on inside the box, not the public port. The public side is always HTTPS on 443.

vps_ssh_access_create

VPS SSH: add developer access

Creates a named SSH-over-WebSocket developer access, mints a one-time connection token and returns the plaintext token plus ready-to-paste connect commands exactly once. Optionally sets an expiry. The tunnel terminates at wss://<sub>.xuda.app/__xuda_ssh and the developer runs a local websocat listener on 127.0.0.1:2222.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Application identifier.
label string No Human-friendly name for the access, for example a developer name.
expires_at number No Optional expiry as epoch milliseconds. The router refuses the token after this time.

Notes

  • Clearance user. Not private, API key reachable. No min_plan.
  • The plaintext token is returned exactly once and only its SHA-256 hash is stored. If you do not capture it from this response you cannot recover it, only rotate it with vps_ssh_access_rotate.
  • Not idempotent. Every call mints a new access, so retrying a timed-out request creates a duplicate. Reconcile with vps_ssh_access_list rather than blindly retrying.
  • expires_at is enforced at the tunnel itself, not just in the UI.
  • The tunnel is end-to-end encrypted. Xuda records session envelopes only and never sees the commands or file names inside.

vps_ssh_access_list

VPS SSH: list developer accesses

Lists every SSH and SFTP over WebSocket developer access for the server: label, creation date, expiry, active or suspended status and live online state.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Application identifier.

Notes

  • Clearance user. Read only and owner-gated. Not private, API key reachable. No min_plan.
  • It never returns the token itself. For an existing access the connect command carries the placeholder YOUR_CONNECTION_TOKEN, which you substitute yourself.

vps_ssh_access_update

VPS SSH: edit developer access

Edits a named developer access: change its label, its expiry, or both. It does not change the token.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Application identifier.
id string Yes Identifier of the access to edit.
label string No New label.
expires_at number No New expiry as epoch milliseconds, or null to clear it.

Notes

  • Clearance user. Not private, API key reachable. No min_plan.
  • Pass expires_at: null to clear an expiry. Omitting the field leaves the existing expiry alone.
  • To change the credential rather than the metadata, use vps_ssh_access_rotate.

vps_ssh_access_rotate

VPS SSH: regenerate access token

Regenerates the connection token for an existing named access, invalidating the previous one, and returns the new plaintext token and connect commands once.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Application identifier.
id string Yes Identifier of the access to regenerate.

Notes

  • Clearance user. Not private, API key reachable. No min_plan.
  • The previous token stops working as soon as the new one is minted. Anyone still using it is refused at the tunnel, so hand out the new token before you rotate a token in active use.
  • The new plaintext is shown once, exactly as on create.

vps_ssh_access_set_status

VPS SSH: suspend or activate access

Suspends or re-activates a named developer access.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Application identifier.
id string Yes Identifier of the access.
status string Yes Either active or suspended.

Notes

  • Clearance user. Not private, API key reachable. No min_plan.
  • A suspended access is refused by the router immediately, not just hidden in the UI. This is the fastest reversible kill switch for one developer.
  • Idempotent: setting the status a second time to the same value is harmless.

vps_ssh_access_delete

VPS SSH: delete developer access

Deletes a named developer access. Its token stops working immediately.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Application identifier.
id string Yes Identifier of the access to delete.

Notes

  • Clearance user. Not private, API key reachable. No min_plan.
  • Not reversible. Use vps_ssh_access_set_status with suspended when you want to be able to restore the same access later.

vps_ssh_session_events

VPS SSH: session history

Lists every SSH or SFTP session opened against the server through the secure tunnel: which access was used, the client address, when it started and ended, how long it lasted and how much data moved each way.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Application identifier.
limit number No Maximum number of sessions to return (default 100, max 500).

Notes

  • Clearance user. Read only and owner-gated. Not private, API key reachable. No min_plan.
  • Session envelopes only. The tunnel is end-to-end encrypted, so commands and file names are never visible to the platform. Use vps_ssh_command_log if you need what was actually typed.
  • Only sessions that went through the Xuda tunnel appear here. A developer connecting straight to the server's own IP is invisible to this log.

vps_ssh_command_log

VPS SSH: command history

Lists the commands run over SSH on the server, read live from the server's own command log.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Application identifier.
limit number No Maximum number of commands to return (default 300).

Notes

  • Clearance user. Read only and owner-gated. Not private, API key reachable. No min_plan.
  • It requires the in-server command log to be switched on with vps_ssh_command_log_set, and it only covers interactive shell sessions.
  • Flagged security: true in the method contract, so calls are security-audited.

vps_ssh_command_log_set

VPS SSH: switch command history on or off

Turns the in-server command log on or off. When on, every command typed in an interactive SSH session is recorded on the server itself so the owner can review it.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Application identifier.
enabled boolean No True to start recording commands, false to stop.

Notes

  • Clearance user. Owner-gated and off by default. Not private, API key reachable. No min_plan.
  • Flagged security: true, so calls are security-audited.
  • The log lives on the customer's own server, not in Xuda. Switching it on writes to a machine you do not own unless you are the owner, which is why the method is owner-gated.

save_deploy_settings

Save Deploy Settings

The single write path for an External VPS's per-feature access opt-ins and for the Auto Diagnose add-on. Granting stamps deploy_data.access_consents[<scope>] = { granted: true, granted_at, granted_by_uid, scope }. Revoking stamps granted: false plus revoked_at and revoked_by_uid. For the diagnose scope the legacy deploy_data.diagnose_access_consent is mirrored so the daily job keeps working.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application this request targets.
access_consent object No Not declared in config, accepted by the implementation: { scope, granted } for a single grant or revoke. Valid scopes: files, backup, metrics, ask_ai, diagnose.
access_consents object No Not declared in config, accepted by the implementation: { <scope>: granted, ... } for a bulk save.
enable_auto_diagnose boolean No Not declared in config, accepted by the implementation: turns the Auto Diagnose add-on on or off.
diagnose_checks object No Not declared in config, accepted by the implementation: { standard, ai_logs, ai_custom }.
diagnose_custom_prompt string No Not declared in config, accepted by the implementation: custom AI check prompt, up to 500 characters in the UI.
diagnose_access_consent boolean No Not declared in config, accepted by the implementation: read-only diagnostics consent, required to enable Auto Diagnose.

Notes

  • Clearance admin. Not private, API key reachable. No min_plan.
  • Only app_id is declared in the method's config field list. Every other key above is read directly off the request body by the implementation, so treat those as accepted-but-undeclared rather than as a frozen contract.
  • Enabling Auto Diagnose without consent returns { code: -91, consent_required: true, scope: 'diagnose' }. Send diagnose_access_consent in the same save, or grant the diagnose scope first.
  • Revoking the backup scope while a Full Stack VPS marketplace listing depends on it returns { code: -92, marketplace_locked: true }.
  • Auto Diagnose is a paid add-on at $5 a month per server, billed as the auto_diagnose add-on line. AI checks inside it additionally draw on the account's metered AI credits.
  • Broadcast and security flagged, so a save is pushed to connected dashboard sessions and audited.

get_vps_diagnose_report

Get VPS Diagnose Report

Returns the last stored Auto Diagnose report for the server, or null. A report contains ran_ts, an overall mode (ok, warn or error), the per-check verdicts (cpu_load, memory, disk, services), an optional ai block with summary and findings, and issue_count.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes The VPS or app whose stored Auto Diagnose report to return.

Notes

  • Clearance user. Read only and owner-gated. Not private, API key reachable. No min_plan.
  • It reads the report already saved on the app document. It performs no SSH and no file access, so it never triggers a consent refusal and never costs a connection.
  • You cannot trigger a run from the API. The run itself is a daily internal sweep and is not registered as a callable method, so poll ran_ts rather than expecting an on-demand diagnosis.
  • A run with no AI credit is skipped with insufficient_credits rather than failing, so an ai block can be absent on an otherwise healthy report.

get_logs

Get Logs

Queries logs of a given type within a timestamp range, with optional search, paging and status filters. For an External VPS the Logs tab calls it with log_type: 'app_log' plus the app id, which returns the universal per-app action history from the central log store.

Availability: API key

Parameters

Name Type Required Description
log_type string Yes The docType of logs to query, for example account_log or app_log.
log_date_from number Yes Lower bound timestamp (inclusive) of the log time range.
log_date_to number Yes Upper bound timestamp (inclusive) of the log time range.

Notes

  • Clearance user. Not private, API key reachable. No min_plan.
  • This is Xuda's own action history for the app, not the server's syslog. To read logs written on the machine itself, tail the file with vps_fs_tail.

destroy_app

Destroy App

Permanently deletes the application. For an external_vps the DigitalOcean teardown branch is explicitly skipped, so the remote server is never destroyed or modified.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application to permanently delete.

Notes

  • Clearance admin. Not private, API key reachable. No min_plan.
  • Asynchronous. The delete is queued as a job, while the pre_destroy_app hook stamps app_cost.terminated_ts synchronously so billing surfaces update instantly. Poll rather than assuming the app is gone when the call returns.
  • Security flagged and broadcast.
  • Deleting the Xuda app removes only Xuda's own document. To cut Xuda's access to the machine as well, remove Xuda's key line from ~/.ssh/authorized_keys on the server, or revoke the access scopes first.

agent_firewall_list

Firewall: list open ports

Lists the inbound firewall rules (open ports) for the app the caller's scoped key is bound to. Designed as an AI agent tool: the target app comes from the API key, never from the model.

Availability: API key

Parameters

This method takes no parameters. The app is taken from the scoped API key.

Notes

  • Clearance user. Not private, API key reachable, and marked mcp: true so it is registered as an MCP tool. No min_plan.
  • Important for External VPS: this method resolves the app and then requires app_hosting_server.droplet.id. An external server has no droplet, so today it returns "this project has no VPS provisioned yet, so there is no firewall to manage". Manage the firewall on the machine itself instead.

agent_firewall_open

Firewall: open ports

Opens inbound TCP ports on the current app's cloud firewall so a service becomes reachable from outside. On the first firewall attach it seeds port 22 so an agent can never lock the owner out.

Availability: API key

Parameters

Name Type Required Description
ports array of string Yes TCP ports to open, for example ["80","443"]. Ranges like "8000-8100" are allowed.

Notes

  • Clearance user. Not private, API key reachable, marked mcp: true. No min_plan.
  • Same External VPS caveat as agent_firewall_list: it requires a DigitalOcean droplet id and therefore does not operate on an external server today.

agent_firewall_close

Firewall: close ports

Closes inbound TCP ports on the current app's cloud firewall. It refuses to close port 22 through the agent path.

Availability: API key

Parameters

Name Type Required Description
ports array of string Yes TCP ports to close, for example ["9090"].

Notes

  • Clearance user. Not private, API key reachable, marked mcp: true. No min_plan.
  • Same External VPS caveat: it requires a droplet id.

agent_domain_list

Domains: list

Lists the account's registered domains with name, status, connection type and which app each is attached to. Account scoped from the API key.

Availability: API key

Parameters

This method takes no parameters. The account is taken from the scoped API key.

Notes

  • Clearance user. Not private, API key reachable, marked mcp: true. No min_plan.
  • Purchasing a domain is deliberately not exposed to agents. This tool reads only.

agent_domain_connect

Domains: connect to this VPS

Points one of the account's own domains at the app the key is bound to, via Cloudflare DNS, with an optional subdomain. Ownership of both the domain and the app is re-checked server side.

Availability: API key

Parameters

Name Type Required Description
domain string Yes A domain the account owns, exactly as returned by agent_domain_list.
subdomain string No Optional subdomain label to point instead of the apex, for example app for app.example.com.

Notes

  • Clearance user. Not private, API key reachable, marked mcp: true. No min_plan.
  • Attaching replaces any existing record on that exact hostname.
  • Important for External VPS: the record builder treats only vps and managed_vps as A-record targets, so for an external_vps it falls through to a proxied CNAME to the app's access URL or <app_id>.xuda.app rather than an A record to the server's own IP. Do not assume a custom domain resolves straight to your server's address.

get_ssh_keys

Get Ssh Keys

Returns the account's stored SSH public keys (name, fingerprint metadata, enabled state, expiry, and which servers each is currently installed on).

Availability: Dashboard session

Parameters

This method takes no fields. It is scoped to the calling account.

Notes

  • Clearance user. Flagged private: true, so an API key cannot call it. No min_plan.
  • The whole SSH key surface, all seven methods below and including this one, is dashboard-session only. Key material is managed by a signed-in human, never by an agent.

save_ssh_key

Save Ssh Key

Validates and stores an SSH public key on the account, with an optional expiry and on or off switch.

Availability: Dashboard session

Parameters

Name Type Required Description
ssh_key_name string Yes Display label for the SSH public key.
ssh_key_content string Yes The SSH public key string to validate and store.
expires_at number No Optional expiry (epoch milliseconds). After this moment the key is refused on assign and automatically removed from every server. Null or 0 clears the expiry.
enabled boolean No On or off switch. Off means the key cannot be assigned to servers.

Notes

  • Clearance user. Flagged private: true. No min_plan.
  • Public keys only. Nothing here accepts or stores a private key.
  • Expiry is swept hourly. An expired key is revoked from every server it was installed on without any further action from you.

set_ssh_key_enabled

Set SSH Key Enabled

On or off switch for a stored SSH key.

Availability: Dashboard session

Parameters

Name Type Required Description
ssh_key_id string Yes Identifier of the SSH key document.
enabled boolean Yes true = on, false = off (removes the key from every server).

Notes

  • Clearance user. Flagged private: true. No min_plan.
  • Switching OFF also removes the key from every server it is installed on, so access stops immediately. This is the panic switch for a compromised laptop.
  • Switching ON does not reinstall the key anywhere. Re-assign it per server with assign_ssh_keys.

delete_ssh_key

Delete Ssh Key

Soft-deletes an SSH key document from the account.

Availability: Dashboard session

Parameters

Name Type Required Description
ssh_key_id string Yes Identifier of the SSH key document to soft-delete.

Notes

  • Clearance user. Flagged private: true. No min_plan.
  • Deleting the record is not the same as cutting access. Switch the key off first, or revoke it per server, if the goal is to stop it working on machines it is already installed on.

get_ssh_key_events

Get SSH Key Events

The account's SSH access log: every key grant, revoke, on or off flip, expiry and delete, newest first.

Availability: Dashboard session

Parameters

Name Type Required Description
ssh_key_id string No Optional filter to one key.
app_id string No Optional filter to one server.
limit number No Max rows (default 200, cap 1000).

Notes

  • Clearance user. Flagged private: true. No min_plan.
  • This is the key-level audit trail. For tunnel connections use vps_ssh_session_events, and for typed commands use vps_ssh_command_log. The three logs cover different things.

assign_ssh_keys

Assign SSH Keys

Installs the given SSH public keys on the app's hosting server. external_vps is explicitly allowed by the app-type guard, and for an external server the copy honors the app's own ssh_user and port rather than assuming root@ip:22.

Availability: Dashboard session

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the target deployment or server app to assign the SSH keys to.
ssh_keys array Yes Array of xuda_ssh_keys document ids whose public keys are copied onto the server.

Notes

  • Clearance admin. Flagged private: true, so an API key cannot install keys on a server. No min_plan.
  • Keys that are switched off or expired are refused loudly, naming the key, rather than being silently skipped.
  • Successfully installed key ids are merged onto app_obj.keys, and each grant is written to the account SSH access log.
  • The Advanced tab does not currently render the Assign SSH Keys row for an External VPS, so this method is reachable from a dashboard session but has no button on the External VPS screens yet.

revoke_ssh_keys

Revoke SSH Keys

The exact reverse of assign_ssh_keys. On a non-farm server, which includes every External VPS, it edits authorized_keys over SSH line-exactly: only the stored public key line is dropped and every other key on the server survives.

Availability: Dashboard session

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the target server app to remove the SSH keys from.
ssh_keys array Yes Array of xuda_ssh_keys document ids whose public keys are removed from the server.

Notes

  • Clearance admin. Flagged private: true. No min_plan.
  • Line-exact. Keys you added by hand on the server are never touched.
  • It also updates app_obj.keys and writes a revoke entry to the account SSH access log.
  • The hourly key-expiry sweep calls this method for you when a stored key passes its expires_at.

The Consent Scopes

Five named scopes gate the server-touching features. External VPS is one of only two app types where the gate actually blocks, and it is the only app type where the metrics and backup scopes still block, because it is the only case where Xuda reaches into a machine it does not run.

Scope Access What it gates
files read-write Every vps_fs_* method.
backup read-only The backup path.
metrics read-only get_app_server_usage on an External VPS.
ask_ai read-only The AI panel's reads of the server.
diagnose read-only Auto Diagnose and its daily run.

Grants and revokes go through save_deploy_settings, using access_consent for one scope or access_consents for a bulk save. Current state is readable on get_app_info under DATA.vps_access_consents, alongside DATA.vps_access_scopes (the catalog and its dialog copy) and DATA.vps_access_enforced. Every grant is stamped with who granted it and when, and every revoke with who revoked it and when.

Errors

Code Meaning
-91 Consent refusal. The payload is { code: -91, consent_required: true, scope }, naming the scope to grant.
-92 Marketplace lock. Returned when revoking the backup scope while a Full Stack VPS marketplace listing depends on it, as { code: -92, marketplace_locked: true }.

Other refusals arrive as readable messages rather than codes:

  • A failed verify_external_vps_ssh returns a human-readable reason such as "unreachable or key not authorized yet", and stores it, truncated to 500 characters, on app_hosting_server.last_verify_error.
  • agent_firewall_list, agent_firewall_open and agent_firewall_close on an External VPS return "this project has no VPS provisioned yet, so there is no firewall to manage", because they require a DigitalOcean droplet id.
  • vps_fs_read does not error on a large file. It returns { too_large: true } with no content, and the client is expected to download instead.
  • vps_fs_write_batch reports per-file failures inside results and a failed count on an otherwise successful envelope.
  • Auto Diagnose skips an AI check with insufficient_credits rather than failing the run.

No External VPS method carries a min_plan key, so the platform's membership plan gate never fires for this product.

Plan Gates And Cost

  • Connecting and running an External VPS is free. The app is created with no server slug, so the monthly cost computes to zero and no billing record is created at all.
  • No min_plan on any method. None of create_external_vps, verify_external_vps_ssh, the vps_fs_* family, the web URL methods, the SSH access methods or the diagnose method carries one.
  • No plan quota on connected servers. The plan's project cap applies to master projects and team shares, not to external_vps apps.
  • The membership plan table lists an "outsourced server" row that reads as unavailable on the lower tiers, but no code path gates External VPS on that flag. Treat it as plan-table copy, not an enforced gate.
  • Auto Diagnose is the one paid add-on, at $5 a month per server, billed as the auto_diagnose add-on line. AI checks inside it consume the account's metered AI credits on top of that.

Rate Limits

There is no published per-method request limit on this surface. What bounds it in practice is physical: every file, service and metrics call opens a real SSH or SFTP session to the customer's own machine, and each one carries its own timeout and output cap. Poll get_app_server_usage on the order of the dashboard's own two minute Live interval rather than in a tight loop, and prefer vps_fs_write_batch over many single writes.

The SSH over WebSocket tunnel endpoint at wss://<sub>.xuda.app/__xuda_ssh is separately rate limited at the router, matches the presented token against the stored hash, and is pinned to the app's own IP so it cannot be pointed anywhere else.

Idempotency And Repeat-Safety

  • Verification is safe to repeat. A failed verify_external_vps_ssh leaves the app pending, and a later call promotes it once the key is in place.
  • The public URL is idempotent per app. The subdomain is derived from the app id, so enabling, disabling and re-enabling always return the same hostname. Disabling reserves the subdomain rather than releasing it.
  • Creating a developer access is not idempotent. Every vps_ssh_access_create mints a new access and a new token, so reconcile with vps_ssh_access_list instead of retrying blindly.
  • Access tokens are shown once. Only the SHA-256 hash is stored. A lost token can only be replaced with vps_ssh_access_rotate, which invalidates the previous one immediately.
  • Suspending is reversible, deleting is not. Use vps_ssh_access_set_status when you may want the same access back.
  • vps_fs_mkdir is effectively idempotent for a path that is already a directory, and refused when a file occupies that path.
  • vps_fs_write_batch is not atomic. Partial success is normal and is reported per path.
  • destroy_app is asynchronous. The job is queued while app_cost.terminated_ts is stamped synchronously.

Limits And Defaults

Setting Value
SSH verification connect timeout 10 seconds (external_vps.ssh_timeout)
Live metrics sampler connect timeout 6 seconds
Metrics sampling window two /proc readings 1 second apart
Usage samples stored per server 2000, oldest dropped
Inline file read 5 MB, larger files answer too_large
Batch upload 128 files per call, 5 MB per file, 64 MB decoded per batch
Search results 300, with capped and timed_out flags
Content search skips binaries, files over 8 MB, node_modules and .git, and it stays on one filesystem
Disk usage lines 600 du lines
Log tail 64 KB first page, 256 KB per incremental page
Command exec timeout 25 seconds
Captured command output 512 KB
Service actions allowed 6 fixed actions plus systemctl with 5 verbs on a regex-validated unit
Default SSH port and user 22 and root
Default web upstream port 80
Session history rows default 100, maximum 500
Command history rows default 300
SSH key event rows default 200, cap 1000

Webhooks

External VPS publishes no webhooks of its own. There is no outbound callback on connect, verify, consent change, diagnose result or delete, so build against polling: get_app_info for connection and consent state, get_vps_diagnose_report for the daily health result, and vps_ssh_session_events for tunnel activity.

The recurring work that does exist runs inside the platform, not as a webhook you can subscribe to:

  • A daily Auto Diagnose sweep connects read-only to each enabled server, runs a frozen command bundle, grades each check, and notifies the owner in the dashboard, with an email when a check is in the error state. The run itself is internal and is not registered as a callable method; only get_vps_diagnose_report is public.
  • A periodic user health sweep includes external_vps in its app-type list.
  • An hourly SSH key expiry sweep calls revoke_ssh_keys for keys that have passed their expires_at.

Known Gaps That Affect Integrations

Each of these is a real limitation today, not a caveat about a future release. Read them before you design around this API.

  • The file methods assume root on port 22. The connect wizard accepts any ssh_user and any port, and verify_external_vps_ssh honors both, but the SFTP and exec helpers behind every vps_fs_* method connect as root on port 22. A server connected as ubuntu, or on port 2222, verifies successfully and then fails on file operations.
  • The SSH over WebSocket tunnel is also pinned to port 22, so developer SSH access does not work for an External VPS on a custom port.
  • Auto Diagnose shares the same limitation. Its command runner uses the same root-on-22 path, so a server on custom SSH settings will not diagnose cleanly.
  • Firewall control does not work for an External VPS. All three agent_firewall_* methods require a DigitalOcean droplet id. Manage the firewall on the machine itself.
  • A connected custom domain does not point at the external server's IP. For an external_vps, agent_domain_connect falls through to a proxied CNAME to the app's access URL or <app_id>.xuda.app rather than writing an A record.
  • The public web URL is never auto-provisioned. Call vps_enable_web_url explicitly. Nothing sets it up when a server is verified.
  • Assigning a server to a project is not callable on production. The method behind that grouping exists in the codebase but is not registered in the production method catalog.
  • Backups are gated but not reachable from an External VPS project screen, because there is no Backups tab in the External VPS tab set, even though the backup consent scope is kept alive for this app type.
  • logs_manager is inert. The flag is still accepted and stored by create_external_vps, but the Logs tab always shows regardless of it.

A Note On What Is Not Here

Two surfaces sit next to this API without being part of it. Team sharing on an External VPS runs through Xuda's generic share methods rather than any External VPS specific method, and the daily diagnose runner is an internal method that is deliberately not registered in the callable catalog. Neither is documented here, because neither is an External VPS method.