Control API
Introduction
The Control API manages Capacity budgets, the sources on them, access keys,
webhook destinations, and source Metrics from your tools. It lives on your
swarmvia host (for example https://swarmvia.com), not on
api.swarmvia.cloud.
The API token is not an access key. It never admits traffic on the proxy.
It is also not how AI assistants connect. Those use the MCP server at
https://swarmvia.com/mcp. See Agents for how to add that URL
in Claude or Cursor. There is no token to paste. Use an API token for CI,
scripts, and infrastructure code, where a value in an environment variable is
the right shape.
Authentication
- Open Organization settings → API tokens.
- Create a token. Under What it's for, name the integration or job that
will hold it (
Nightly invoice sync): its sessions and activity show this name. Choose when it expires: 1 month, 6 months, or 1 year. - Choose What this token can do:
- Only the sources and calls I choose. The keys it mints work on those sources only and make only the calls you list. Use this for an integration.
- Everything I can do. Every source you can use, with every call you can make. Use this for your own admin scripts.
- Copy the plain token once. Send it as
Authorization: Bearer ….
A token looks like 12|sv_api_…: its id, a |, and the secret. Send the whole
value. Tokens created before the sv_api_ prefix have no prefix after the |,
and they keep working.
A token's activity
Select Activity under a token in Organization settings → API tokens to see what its integration did over the last 24 hours, 7 days or 30 days (as far as your plan keeps logs):
- Sources: each source a key from the token worked on, with its calls, refused calls, errors and writes.
- Timeline: every call made with a key the token minted, across those sources, newest first.
- Sessions: the token's agent sessions, and how many are open. N open sessions under the token links to them.
- Keys: how many of its keys work now, how many it minted in the period, and the most recent ones.
Owners and admins can see any token's activity; a member sees their own. Sources you can't see are counted, not shown.
Only owners and admins can create or revoke tokens. A token authenticates as
the person who created it in that organization. It can call the Control API
for every budget and source on the org. A token limited to chosen sources mints keys
only on those (403 elsewhere), and cannot change a source policy. Verb abilities still apply
(budgets:read, sources:read, sources:write, keys:write, metrics:read,
sessions:read, sessions:write).
Webhook create and attach use sources:write. Listing destinations uses
sources:read.
curl -sS "https://swarmvia.com/api/v1/me" \
-H "Authorization: Bearer $NTHBOUNCER_CONTROL_TOKEN" \
-H "Accept: application/json"Endpoints
Source path segments use the source subdomain (the *.swarmvia.cloud label).
| Method | Path | Ability | Purpose |
|---|---|---|---|
GET |
/api/v1/me |
(any valid token) | Current user, team, abilities |
GET |
/api/v1/budgets |
budgets:read |
List granted budgets |
GET |
/api/v1/budgets/{id} |
budgets:read |
Budget detail |
GET |
/api/v1/budgets/{id}/sources |
sources:read |
Sources under that budget |
GET |
/api/v1/sources |
sources:read |
List granted sources |
POST |
/api/v1/sources |
sources:write |
Admit an https origin (same as MCP create_source) |
POST |
/api/v1/sources/database |
sources:write |
Admit a public Postgres host |
POST |
/api/v1/sources/{subdomain}/auth-handoff |
sources:write |
Flip to managed auth and mint a one-shot intake |
PUT |
/api/v1/sources/{subdomain}/credential |
sources:write |
Attach a stored credential (secret allowed on this plane) |
GET |
/api/v1/sources/{subdomain} |
sources:read |
Source detail |
POST |
/api/v1/sources/{subdomain}/keys |
keys:write |
Mint an access key (sv_at_…, expires in 1h, 24h, or 7d) |
DELETE |
/api/v1/sources/{subdomain}/keys/{id} |
keys:write |
Revoke an access key |
GET |
/api/v1/sources/{subdomain}/policy |
sources:read |
An API source's policy, and can_call: what a key minted with this token can call |
PUT |
/api/v1/sources/{subdomain}/policy |
sources:write |
Replace the default source policy. rules is a list of text rules ("GET HEAD OPTIONS /**"). A policy is always enforced |
PUT |
/api/v1/sources/{subdomain}/policy/grants/{principal} |
sources:write |
Replace the extra calls a group (group:<id>) gets |
DELETE |
/api/v1/sources/{subdomain}/policy/grants/{principal} |
sources:write |
Remove a group's extra calls |
GET |
/api/v1/sources/{subdomain}/metrics |
metrics:read |
Admit / queue / reject series |
GET |
/api/v1/sessions |
sessions:read |
This token's agent sessions, newest first |
POST |
/api/v1/sessions |
sessions:write |
Start a session with a purpose |
GET |
/api/v1/sessions/{id} |
sessions:read |
One of this token's sessions |
POST |
/api/v1/sessions/{id}/end |
sessions:write |
End it: no new keys; keys it holds work until they expire |
DELETE |
/api/v1/sessions/{id} |
sessions:write |
Revoke it and every live key minted in it |
GET |
/api/v1/sessions/{id}/activity |
sessions:read |
What the script reported doing outside swarmvia in it, newest first |
POST |
/api/v1/sessions/{id}/activity |
sessions:write |
Report one thing it did outside swarmvia |
GET |
/api/v1/webhooks |
sources:read |
List webhook destinations |
POST |
/api/v1/webhooks |
sources:write |
Create a destination (signing secret once). Optional source_ids attaches and enables async |
PUT |
/api/v1/sources/{subdomain}/webhooks |
sources:write |
Replace destinations on a source. Enables async when the list is not empty |
POST /api/v1/sources takes origin (required) and name (optional). It
reuses a live API source that already fronts that host, or creates a
pass-through source with dashboard defaults. It does not attach a Capacity
budget or an origin credential. 201 on create, 200 on reuse.
Attach budgets and managed credentials in the dashboard.
POST /api/v1/webhooks takes name, url, optional description, and
optional source_ids. The URL must be https and cannot be loopback, private,
or swarmvia itself. 201 returns signing_secret once (whsec_…).
PUT /api/v1/sources/{subdomain}/webhooks takes webhook_endpoint_ids (may
be empty). Owners and admins only, same as the dashboard.
Source policies
GET /api/v1/sources/{subdomain}/policy returns an API source's
policy. Every rule is text: methods, then a path.
curl -sS "https://swarmvia.com/api/v1/sources/$SOURCE_SUBDOMAIN/policy" \
-H "Authorization: Bearer $NTHBOUNCER_CONTROL_TOKEN" \
-H "Accept: application/json"{
"data": {
"source_id": 12,
"subdomain": "netsuite-acme",
"has_policy": true,
"rules": ["GET HEAD OPTIONS /**"],
"can_call": ["GET HEAD OPTIONS /**"],
"grants": [
{
"principal": "group:4",
"name": "Finance",
"rules": ["POST PATCH /services/rest/record/v1/vendorBill/**"]
}
],
"limits": [],
"principals": {
"groups": [{ "id": 4, "name": "Finance" }]
}
}
}| Field | Meaning |
|---|---|
rules |
The default source policy: what every caller gets |
can_call |
What a key minted with this token can call on the source |
grants |
Extra calls for a group's members |
limits |
API tokens and agents held to fewer calls. Read-only here: set when the token is created or the agent approved |
principals |
The groups that can be given rules, with their ids |
grants, limits, and principals are returned only to an owner's or
admin's token with sources:write.
Replace the default source policy by sending the whole list. mode is
optional and keeps its current value when left out:
curl -sS -X PUT "https://swarmvia.com/api/v1/sources/$SOURCE_SUBDOMAIN/policy" \
-H "Authorization: Bearer $NTHBOUNCER_CONTROL_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"rules":["GET HEAD OPTIONS /**","POST /services/rest/query/v1/suiteql"]}'Give a group extra calls, and take them away:
curl -sS -X PUT "https://swarmvia.com/api/v1/sources/$SOURCE_SUBDOMAIN/policy/grants/group:4" \
-H "Authorization: Bearer $NTHBOUNCER_CONTROL_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"rules":["POST PATCH /services/rest/record/v1/vendorBill/**"]}'
curl -sS -X DELETE "https://swarmvia.com/api/v1/sources/$SOURCE_SUBDOMAIN/policy/grants/group:4" \
-H "Authorization: Bearer $NTHBOUNCER_CONTROL_TOKEN" \
-H "Accept: application/json"Each change returns the policy as it now stands and applies to keys already
issued, within about a minute. The principal is group:<id>. One person gets more calls
through a group.
422names the rule that is not valid by its position (rules.1), or says the group is not in the organization.403when the token's owner is no longer an owner or admin, or the token is limited to chosen sources.404on a database or MCP source, which has no policy.
Mint an access key
curl -sS -X POST "https://swarmvia.com/api/v1/sources/$SOURCE_SUBDOMAIN/keys" \
-H "Authorization: Bearer $NTHBOUNCER_CONTROL_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"label":"orders-sync","expires_preset":"24h"}'The body is optional:
| Field | Values | Default |
|---|---|---|
label |
Up to 60 characters. Names the key on the Access tab, in Logs, and in Metrics. | none |
access |
read or write (see Key access) |
write |
expires_preset |
1h, 24h, or 7d |
24h |
for_me |
true signs the key for the user who owns the Control API token, so it acts for them |
false |
session_id |
An open session of this token (ses_…). The key belongs to it, and an unlabeled key takes its purpose as the label. |
none |
Every key expires; 7 days is the longest. expires_preset: "none" is
refused with 422. Without for_me, a minted key is a machine key: it acts
for no one. A source whose credential is
per member needs for_me: true.
201 returns the key once, in data.key, with its expires_at:
{
"data": {
"id": 4821,
"label": "orders-sync",
"last_four": "Q2xk",
"access": "write",
"allowed_methods": null,
"allow": null,
"can_call": ["GET HEAD OPTIONS /**", "POST PATCH /v1/orders/**"],
"expires_at": "2026-10-19T14:05:00+00:00",
"revoked_at": null,
"created_at": "2026-10-18T14:05:00+00:00",
"key": "sv_at_eyJhbGciOiJFZERTQSIs…"
}
}Cache the key and mint a new one once about 80% of its lifetime has passed. Refresh access tokens before they expire shows the pattern, including tools that can only send a fixed header.
Revoke an access key
DELETE /api/v1/sources/{subdomain}/keys/{id} revokes the key with that id
at once and returns it with revoked_at set. Revoke a key only if it leaked;
otherwise let it expire.
Sessions
A session groups the keys a script mints for one task, so the task's calls on every source show up together under Sessions, and one call revokes all of its keys. See Sessions.
curl -sS -X POST "https://swarmvia.com/api/v1/sessions" \
-H "Authorization: Bearer $NTHBOUNCER_CONTROL_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"purpose":"Nightly invoice reconcile","issue":"OPS-7"}'purpose is required, up to 500 characters. issue is optional: a
Work issue of the organization, by its id. 201 returns the
session:
{
"data": {
"id": "ses_p4vslYUYf5VQlXmoPlJDd4Cb",
"purpose": "Nightly invoice reconcile",
"implicit": false,
"status": "open",
"end_reason": null,
"issue": "OPS-7",
"started_at": "2026-11-17T02:00:00+00:00",
"last_activity_at": "2026-11-17T02:00:00+00:00",
"ended_at": null
}
}Pass id as session_id when you mint a key. End the
session when the task is done. A token sees only its own sessions; another
token's session is a 404.
status is open, ended or revoked. end_reason is ended, idle
(24 hours without a call), capped (7 days after it started) or revoked.
Minting into a session that cannot take keys returns 409 with the reason in
error:
error |
Meaning |
|---|---|
session_not_found |
No session with that id belongs to this token |
session_ended |
It was ended, went idle, or reached 7 days. Start a new one. |
session_revoked |
It was revoked. |
Work outside swarmvia
A script's task often touches systems that are not sources: it uploads to S3, posts to Slack, opens a pull request. Report each one in one line, so the session's timeline shows the whole task:
curl -sS -X POST "https://swarmvia.com/api/v1/sessions/$SESSION_ID/activity" \
-H "Authorization: Bearer $NTHBOUNCER_CONTROL_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"system":"S3","action":"Uploaded the November export","outcome":"done"}'| Field | Value |
|---|---|
system |
Where it happened, up to 60 characters. Required. |
action |
What was done, in one line, up to 300 characters. Required. Never output, a payload or a secret. |
outcome |
done (default), failed or skipped |
url |
An http(s) link to what was done |
occurred_at |
When it happened (ISO 8601). Defaults to now; kept within the session. |
201 returns the line. The dashboard shows it marked Reported, since
swarmvia did not see the work happen. A session takes at most 5,000; past that,
or on a session that ended, the answer is 409 with activity_limit,
session_ended or session_revoked in error.
Key access
A key minted here can make what the token's owner can call on the source: the
default source policy, plus the rules of the owner's
groups. If the token was limited to chosen calls on that source, the
key is held to those. POST /api/v1/sources/{subdomain}/keys accepts access
to narrow it further:
| Value | The key can make |
|---|---|
write (default) |
Every call described above |
read |
GET, HEAD, and OPTIONS. The writes are left out. |
Any other call is refused with 403, before the request reaches your origin
and before it takes a concurrency slot. The policy decides what write
means: on a source where the owner can only read, a write key cannot write
either.
The response says what the key holds:
can_calllists every call the key can make on its source right now, one rule per entry. It isnullon a source that is not an API source.allowlists the calls the key is narrowed to, one rule per entry ("GET HEAD OPTIONS /**"). It isnullwhen the key has whatever the policy allows, which includes areadkey on a source that only allows reads.accessandallowed_methodsare kept for existing callers.allowed_methodsisnullon awritekey.
Omitting access mints a write key.
On a database source, access: read and access: write
both connect as the read role. Method scope is not applied: every query is
POST. Writes are refused by Postgres, not by the key.
MCP
AI assistants use https://swarmvia.com/mcp, not this token. Connection
steps are on Agents. Tools and session keys are on
MCP server.