Skip to content

API reference

The Agent Functual API lets your scripts and tools do what the Agents pages at my.functual.com do. You can list your agents, read their system info, open remote access sessions, and manage install tokens. The functual command line is built on this API.

Base URL: https://api.functual.com/api/v1. Requests and responses are JSON; send Accept: application/json. Times are ISO 8601 in UTC. IDs are UUIDs.

Endpoint Access
GET /key any key
GET /agents, GET /agents/{id}, GET /agents/{id}/inventory, GET /agents/{id}/commands read
GET /sessions, GET /sessions/{id} read
POST /sessions, POST /sessions/{id}/close connect
PATCH /agents/{id}, DELETE /agents/{id} manage
GET /install-tokens, POST /install-tokens, DELETE /install-tokens/{id} manage

Create an API key in Agents → Settings → API keys. Each key belongs to your organization, not to a person, and keeps working when team members come and go. Send it as a bearer token:

Authorization: Bearer fnk_…
Terminal window
curl -s https://api.functual.com/api/v1/agents -H "Authorization: Bearer $FUNCTUAL_API_KEY" -H "Accept: application/json"

Treat a key like a password: keep it in a secret store or an environment variable, never in code or a URL. Revoking a key takes effect at once and closes the remote access sessions it opened. Everything a key does appears in the Activity log as “API key: <name>”.

The command line can also sign in as a person (functual login). Its requests act as that person, with their access, and appear under their name. For your own scripts and integrations, use an API key.

Each key has one access level. A level includes the ones before it.

Level Allows
read Read agents, system info, command history and sessions
connect Read, plus open and close remote access sessions
manage Connect, plus rename and remove agents, and manage install tokens

Give each script the lowest level it needs. A request above the key’s level gets 403 with reason_code: insufficient_scope.

Plan Requests per minute, per key API keys per organization
Free 60 2
Pro, Business 600 10

Above the limit you get 429 with reason_code: rate_limited and a Retry-After header in seconds. Wait that long before trying again. When you poll a session, every 2 seconds is enough.

List endpoints take page (from 1) and per_page (1 to 100, default 25) and answer:

{ "data": [ … ], "meta": { "total": 42, "page": 1, "per_page": 25 } }

Single objects come as {"data": { … }}.

Errors are JSON with a message written for people. Most also carry a reason_code for programs:

{ "message": "This agent hasn't checked in recently. Is it running? Check with \"functual status\" on the machine.", "reason_code": "server_offline" }

Validation errors (422) list each field:

{ "message": "The ports field is required.", "errors": { "ports": ["The ports field is required."] } }
Status Meaning
401 Missing, revoked or expired API key
403 insufficient_scope, or the plan doesn’t include it (not_licensed, port_not_licensed)
404 No such agent, session or token in your organization (server_not_found for sessions)
409 The current state doesn’t allow it: server_offline, server_revoked, concurrent_limit, concurrent_org_limit, not_open
422 Invalid fields (errors), or invalid_public_key
429 rate_limited; see Retry-After
503 Agent Functual is briefly unavailable; try again in a minute

Match on reason_code and the status, not on the message text, which may change.

Describes the key you’re calling with. It never returns the key itself.

{ "data": {
"type": "api_key", "id": "36fabe99-…", "name": "Deploy scripts", "scope": "connect", "expires_at": null,
"organization": { "id": "d361ab43-…", "name": "Acme" },
"limits": { "plan": "free", "keys": 2, "per_minute": 60 }
} }

scope is read, connect or manage. expires_at is null for a key that doesn’t expire. For a person’s command line sign-in, type is user, with user (name, email) and computer in place of name.

Your organization’s agents (one per enrolled machine), as a list.

Parameter Description
status online, offline, active (all but removed) or revoked (removed). Default: all
search Matches the label, hostname or ID
sortField, sortDir server (label), hostname, version or last_seen_at; asc or desc
page, per_page See Lists
{ "data": [ {
"id": "ccf033bc-…", "label": "Web 1", "instance": "default", "hostname": "web1",
"os": "ubuntu 24.04", "arch": "amd64", "version": "0.1.14",
"online": true, "last_seen_at": "2026-11-22T19:40:20Z",
"last_ip": "203.0.113.7", "last_location": { "city": "Stockholm", "country": "SE", "label": "Stockholm, Stockholm, SE", … },
"clone_suspected": false, "revoked": false, "enrolled_at": "2026-11-01T16:31:50Z",
"system": { "os_name": "Ubuntu 24.04.3 LTS", "boot_time": "2026-11-19T21:51:09Z", "chassis": "server",
"virtualization": "kvm", "cores": 8, "threads": 8, "memory": 66833772544, "reported_at": "2026-11-22T16:31:51Z" },
"features": { "remote_access": "free" }
} ], "meta": { "total": 1, "page": 1, "per_page": 25 } }
  • label is the name you gave the agent, or null; the console shows the hostname instead.
  • online is true when the agent checked in within the last few minutes.
  • revoked is true for a removed agent.
  • clone_suspected is true when the agent’s identity reported in from a different machine, for example after a disk image was copied. Remove the agent and install each machine with its own token.
  • system is a summary of the machine, present once it has reported. memory is in bytes.
  • features.remote_access is the agent’s remote access plan.

One agent: the same fields as a list row, without system.

The machine’s system info, as sections. The same data appears on the agent’s System panel.

{ "data": [
{ "agent_id": "ccf033bc-…", "module": "system-info", "schema": "system-info.v1", "section": "cpu",
"status": "ok", "detail": null, "missing": null, "reported_at": "2026-11-22T16:31:51Z",
"data": { "vendor": "GenuineIntel", "model": "Intel(R) Core(TM) Ultra 7 365", "sockets": 1, "cores": 8, "threads": 8, "max_mhz": 4900 } },
…
] }

The sections are os, hardware, cpu, memory, storage, network, power, peripherals and security.

  • status is ok, unsupported (not available on this platform), needs_permission, tool_missing or error. When a section can’t be collected, detail says why.
  • missing lists fields left out of an otherwise ok section, and why.
  • Within a schema version, fields are only ever added. Ignore fields you don’t know.

The commands Functual sent to the agent, newest first: remote access tunnels opening and closing, for example. It is the same history as the agent’s Commands tab.

{ "data": [ {
"id": "79ca81e1-…", "agent_id": "ccf033bc-…", "producer": "connectlio", "type": "tunnel.open",
"status": "succeeded", "result": { "ports": [22], "session": "s-kphra9akdz" }, "reason_code": null, "reason": null,
"created_at": "2026-11-22T18:26:02Z", "delivered_at": "2026-11-22T18:26:09Z", "started_at": "2026-11-22T18:26:10Z",
"finished_at": "2026-11-22T18:26:10Z", "expires_at": "2026-11-22T18:28:02Z"
} ], "meta": { … } }

status is queued, delivered, running, succeeded, failed, expired or canceled. A failed command carries the agent’s reason_code and reason.

Renames an agent. Body: label, a string up to 100 characters, or null to show the hostname again. The field is required. Response: 200 with the agent.

Removes an agent. It stops working at its next check-in and closes its sessions. The record stays, with revoked: true, so its history is kept. To use the machine again, install it again with a new install token. Response: 200 with the agent.

A session opens a short-lived tunnel to chosen ports on an agent’s machine (SSH on 22, Remote Desktop on 3389, VNC on 5900, or any other port your plan includes). It goes through Functual’s proxy, so the machine needs no open inbound ports. Sessions end after their idle time with no traffic, at their maximum length, or when closed.

{ "data": {
"id": "9ae1ab16-…", "agent_id": "ccf033bc-…", "slug": "s-whs6j7jqde", "status": "open",
"ports": [ { "port": 22, "group": "ssh" } ],
"idle_minutes": 5, "max_ends_at": "2026-11-22T21:41:48Z",
"opened_at": "2026-11-22T19:41:51Z", "last_activity_at": "2026-11-22T19:41:51Z",
"closed_at": null, "close_reason": null, "reason_code": null, "reason": null,
"user_id": null, "api_key_id": "36fabe99-…", "created_at": "2026-11-22T19:41:48Z",
"connection": {
"host": "connect.functual.com", "port": 22, "username": "s-whs6j7jqde",
"proxy_host_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA…",
"services": [ { "port": 22, "group": "ssh", "tls": true,
"command": "ssh -J s-whs6j7jqde@connect.functual.com -o HostKeyAlias=functual-ccf033bc <user>@localhost" } ]
}
} }
  • status goes requested → delivered → opening → open → closing → closed. A session that never opens ends as failed, with reason_code and reason.
  • close_reason says why it ended:
    • user: closed by a person or a key;
    • idle, max_length: its time ran out;
    • agent_offline, agent_disconnected, proxy_lost: a connection dropped;
    • server_revoked, user_removed, api_key_revoked: what opened it was removed;
    • failed: it never opened.
  • connection is present only while the session is open:
    • host, port and username are where to log in to the proxy;
    • proxy_host_key is the proxy’s host key, so you can check it instead of trusting it on first use;
    • services holds a ready-made command per port. tls: false marks ports whose traffic usually isn’t encrypted.
  • Opened by: user_id is set for a person’s session, api_key_id for one started with an API key.

Sessions in your organization, newest first, as a list. Each row adds user_name, api_key_name and server_name.

Parameter Description
agent_id Only this agent’s sessions
status open (not ended yet) or past
page, per_page See Lists

One session, with connection while it is open. Poll it after starting a session.

Starts a session. Needs connect access.

Field Type Required Description
agent_id UUID yes The agent to connect to; it must be online
ports array of integers yes 1 to 10 ports on the machine, e.g. [22]
public_key string yes, with an API key The session key: an SSH public key (ssh-ed25519 AAAA…) that may log in to this session only
idle_minutes integer no End after this many idle minutes; capped by your settings and plan

Response: 201 with the session in requested. The agent picks the session up when it next checks in, so it opens within 30 seconds. Poll GET /sessions/{id} every 2 seconds until status is open (then use connection) or failed.

Refusals: server_not_found (404), server_offline, server_revoked (409), not_licensed, port_not_licensed (403, with port), concurrent_limit, concurrent_org_limit (409, with limit: the plan’s open sessions per agent or per organization), invalid_public_key (422).

Every session needs its own session key: make a new key pair for each session and throw the private key away after. Each session counts as one connection toward your plan.

Closes a session. Needs connect access. Response: 200 with the session in closing. A session that is already closing or closed gets 409 with reason_code: not_open.

The simplest way is the functual command line. It does all of this for you.

To use OpenSSH instead, log in to the proxy as connection.username with the session key, and pin the proxy’s host key. The session key only opens the proxy hop. You then log in to the machine itself with your usual account and key, so its own host key is checked end to end.

Terminal window
# 1. A throwaway session key
ssh-keygen -q -t ed25519 -N "" -C session -f session_key
# 2. Start the session and wait for "open" (see the Python example below), then:
echo "connect.functual.com $PROXY_HOST_KEY" > proxy_known_hosts # connection.proxy_host_key
# 3. An SSH config entry for the proxy hop: its user is the session's slug, its key the session key
cat > session_ssh_config <<EOF
Host functual-proxy
HostName connect.functual.com
User $SLUG
IdentityFile $PWD/session_key
IdentitiesOnly yes
UserKnownHostsFile $PWD/proxy_known_hosts
StrictHostKeyChecking yes
EOF
# 4. Jump through it to the machine's own sshd
ssh -F session_ssh_config -J functual-proxy -o HostKeyAlias=functual-${AGENT_ID:0:8} admin@localhost

-i on the command line applies only to the final machine, not to the -J hop. That’s why the session key goes in the config entry. For other ports, forward them through the proxy: ssh -F session_ssh_config -N -L 13389:localhost:3389 functual-proxy, then connect to localhost:13389.

An install token enrolls new machines: it goes into the install command. Tokens are for installing only; an enrolled agent never needs one again.

Your tokens, as a list:

{ "data": [ {
"id": "5c1d…", "label": "Web servers", "defaults": { "features": ["remote_access"] },
"expires_at": "2026-11-29T18:00:00Z", "max_uses": 10, "uses": 3, "usable": true,
"revoked_at": null, "created_at": "2026-11-22T18:00:00Z"
} ], "meta": { … } }

max_uses: null means unlimited, and expires_at: null means the token never expires. usable is false once the token is revoked, expired or used up.

Field Type Required Description
label string, ≤ 100 no The name every agent enrolled with this token starts with. A machine that enrolls with its own name (--label) keeps that instead
expires_in_days integer, 1 to 365, or null no Default 7; null for a token that never expires (device images)
max_uses integer, 1 to 10,000, or null no Default 1; null for unlimited
features array no Features new agents start with, e.g. ["remote_access"]

Response: 201 with the token, plus the plain token and ready-made install commands. The plain token is only shown in this response.

{ "data": { "id": "5c1d…", …, "token": "cle_…",
"install_commands": {
"linux": "curl -fsSL https://get.functual.com | sudo sh -s -- cle_…",
"windows": "irm https://get.functual.com/windows | iex; Install-Functual cle_…",
"msi": "msiexec /i https://get.functual.com/windows.msi /qn ENROLL_TOKEN=cle_…"
},
"install_command": "curl -fsSL https://get.functual.com | sudo sh -s -- cle_…"
} }

The linux command also installs on macOS. Use msi with fleet tools such as Intune or Group Policy.

Revokes a token. Machines already enrolled with it keep working. Response: 200 with the token.

This uses requests. It lists the online agents, then opens and closes an SSH session on the first one.

import os, subprocess, tempfile, time
import requests
API = "https://api.functual.com/api/v1"
s = requests.Session()
s.headers.update({"Authorization": f"Bearer {os.environ['FUNCTUAL_API_KEY']}", "Accept": "application/json"})
def call(method, path, **kw):
while True:
r = s.request(method, API + path, timeout=30, **kw)
if r.status_code == 429: # over the rate limit: wait as told
time.sleep(int(r.headers.get("Retry-After", "5")))
continue
if not r.ok:
raise RuntimeError(f"{r.status_code}: {r.json().get('message')}")
return r.json()["data"]
agents = call("GET", "/agents", params={"status": "online", "per_page": 100})
for a in agents:
print(a["label"] or a["hostname"], a["os"], a["version"])
# A throwaway session key, then a session on port 22
key_dir = tempfile.mkdtemp()
subprocess.run(["ssh-keygen", "-q", "-t", "ed25519", "-N", "", "-f", f"{key_dir}/session_key"], check=True)
public_key = open(f"{key_dir}/session_key.pub").read().strip()
session = call("POST", "/sessions", json={"agent_id": agents[0]["id"], "ports": [22], "public_key": public_key})
for _ in range(45): # opens within 30 s
session = call("GET", f"/sessions/{session['id']}")
if session["status"] in ("open", "failed", "closed"):
break
time.sleep(2)
print(session["status"], session.get("connection", {}).get("username"))
# … connect as shown in "Connecting to an open session", then:
call("POST", f"/sessions/{session['id']}/close")

For scripts that only need to run a command on a machine, calling the command line is simpler: functual ssh admin@web1 -- uptime. See Command line.