Skip to content
foxdeployDocsSign up

HTTP API

Everything the SDKs and the CLI do goes through this API. Keys, scopes, ids, errors, retries and rate limits.

View as Markdown

The base address is https://api.foxdeploy.ai/v1. Bodies and answers are JSON, times are RFC 3339 in UTC, and money fields carry a currency and an amount. The API reference lists every operation with its fields, read from the OpenAPI contract.

A first call

Shell
curl -s https://api.foxdeploy.ai/v1/computers \
  -H "Authorization: Bearer $FOXDEPLOY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: docs-first-call" \
  -d '{"size":"small","region":"sgp","image":"ubuntu-24.04"}'

The answer is 201 with the computer's id (cm_ and six letters or digits), its state and started_in_ms. Then run a command in it:

Shell
id=$(curl -s "https://api.foxdeploy.ai/v1/computers?state=running" \
  -H "Authorization: Bearer $FOXDEPLOY_API_KEY" | python3 -c 'import json,sys; print(json.load(sys.stdin)["items"][0]["id"])')
curl -s https://api.foxdeploy.ai/v1/computers/$id/exec \
  -H "Authorization: Bearer $FOXDEPLOY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cmd":"uname -a","timeout_s":60}'
curl -s -X POST https://api.foxdeploy.ai/v1/computers/$id/pause \
  -H "Authorization: Bearer $FOXDEPLOY_API_KEY"

With "stream": true, exec answers server sent events: stdout and stderr with {"d": "text"}, then exit with the exit code.

Keys and scopes

A key starts with fd_live_ and is shown once when it is made. We keep only a keyed hash of it. Send it as Authorization: Bearer fd_live_..., never in the address: a key found in a URL is refused with key_in_url, and you should revoke it.

ScopeWhat a key with it may do
Full accesseverything below, plus previews, resume, snapshots, stop, start and destroy
Create and exec onlycreate, read one computer, run commands and the terminal, files, ports and pause
Read onlylist and read computers, read files, ports, images and regions

A key may also carry a largest size, a spend limit of its own and an expiry date. A revoked key stops working within seconds, and anything it had open (a terminal, a stream, a running command) is ended. Revoked keys stay listed for 30 days with who revoked them.

Ids

PrefixWhat
cm_a computer
snap_a snapshot
key_an API key
org_an organisation

An id that is not in your organisation answers 404, exactly as an id that does not exist.

Creates are safe to repeat

Send an Idempotency-Key header with a create. A repeat with the same key and the same body answers the first create instead of starting a second computer. The same key with another body is refused with 409 idempotency_conflict. Keys are kept 24 hours.

Rate limits and sizes

WhatLimit
Requests per key or member600 a minute
Creates per key or member60 a minute
A JSON body1 MiB
One file written100 MiB
One upload1 GiB
A command's timeout_s1 to 3600 seconds, 600 by default

A request over a rate limit answers 429 with Retry-After. More on request.

Errors

Every error has the same body: code, a word your code can test; message, a sentence for a person; and fields, the field errors of a request that did not validate.

JSON
{ "code": "limit_concurrent", "message": "...", "fields": {} }
StatusCodesWhat to do
400bad_request, key_in_urlfix the request
401unauthenticatedcheck the key; it may be revoked
402starts_blockedcredit is empty: add credit
403forbidden, limit_concurrent, limit_size, limit_monthly, kill_switcha scope or a limit: the message says which
404not_foundno such id in your organisation
409invalid_state, idempotency_conflictnot now, for example a command while paused
413payload_too_largesend less
422validation_failedsee fields
429too_many_requestswait for Retry-After
502, 503, 504upstream_error, capacity, unavailable, timeouttry again later

The full list of codes is on the API reference.

When to retry

The SDKs and the CLI already follow these rules. If you call the API yourself:

  • Retry any call answered 429, after Retry-After.
  • Retry a call that is safe to repeat (a read, a whole file write, a delete, a create with an Idempotency-Key) after a 5xx or a network error.
  • Retry anything else (exec, pause, resume) only on a 503 with the code capacity or unavailable: those say nothing started. A bare 503 from a proxy may follow a command that ran.
  • Wait 0.25 seconds before the first retry and double it each time, up to 8 seconds, with up to a quarter more at random. Stop after 3 retries.

Account, keys and usage

Your account, keys, usage and the team are on the control plane at https://api.foxdeploy.ai/api/v1, used by the dashboard with your signed in session. Making keys from code is not offered yet: make them on the API keys page.