Skip to content

Using the API

The SpanSlice API lets scripts, CI jobs and agents do what the app does with your rules. It reads organizations, projects, environments and services. It creates, edits, reorders and switches rules. In environments that require commit, it reviews and commits pending changes. Agents can call the same operations as MCP tools. See For agents.

https://api.spanslice.com

Operations live under /v1, and they send and receive JSON. The reference lists every operation. It’s generated from the OpenAPI 3.1 spec at https://api.spanslice.com/v1/openapi.json, which needs no token.

Create a token in the app under Settings › Access tokens. Give it a name, a role, and an expiry: 30 days, 90 days, a year, or none. SpanSlice shows the token once, when you create it, and keeps only its hash. You revoke a token on the same page.

There are two kinds:

Personal (ss_pat_…) Organization (ss_org_…)
Made by anyone in the org, for themselves admins and owners
Acts as you, with the lower of your role and the token’s the organization, with the token’s role
Commits are made by you no one in particular (by is null)
Stops working when it expires, is revoked, or you leave the org when it expires or is revoked

A token belongs to one organization and can’t reach anything outside it. The SDK’s API keys (ss_…, set as SPANSLICE_API_KEY) are a different credential. The API refuses them with a 401.

Send the token as a bearer token. getMe describes the token, so it’s a good first call:

Terminal window
export SPANSLICE_TOKEN=ss_pat_…
curl https://api.spanslice.com/v1/me \
-H "Authorization: Bearer $SPANSLICE_TOKEN"
{
"token": {
"name": "Rules agent",
"kind": "personal",
"role": "member",
"organization": "snugghome",
"expires_at": "2027-01-06T14:03:12.000Z",
"created_at": "2026-10-08T14:03:12.000Z"
},
"user": { "name": "Ada", "email": "ada@snugghome.com" }
}

The token.organization value is the slug that other operations take. To list its projects:

Terminal window
curl https://api.spanslice.com/v1/orgs/snugghome/projects \
-H "Authorization: Bearer $SPANSLICE_TOKEN"
{
"data": [
{
"slug": "snugghome-app",
"name": "SnuggHome App",
"organization": "snugghome",
"created_at": "2026-09-18T12:00:00.000Z"
}
],
"next_cursor": null
}

Each operation needs a role, which the reference shows. Reads need viewer. Changing rules and committing need member. No operation needs more than that, so a token never needs admin to use the API.

A token whose role is too low gets a 403. If the token can’t reach something, including anything in another organization, the API returns a 404, as if it didn’t exist.

Organizations, projects, environments and services are addressed by the slugs in their app URLs. A slug that a project or organization had before a rename still finds it.

Rules have ids such as rule_RVeVNOTP. An id stays the same across environments and renames. Wherever an operation takes a rule, it also takes the keys that spans carry in their spanslice.rules attribute, one per environment. So from a span in your observability backend, getRule leads straight to the rule that changed it.

Lists return { data, next_cursor }. Pass limit (1 to 200, default 100) to set the page size. To get the next page, pass next_cursor back as cursor. It’s null on the last page.

Terminal window
curl "https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app/rules?limit=50&cursor=$NEXT_CURSOR" \
-H "Authorization: Bearer $SPANSLICE_TOKEN"

Each rule has a version, which goes up with every edit to what the rule does. When you update a rule, send the version you read as If-Match. If someone changed the rule since then, nothing is written and you get a 412. Read the rule again, and reapply your change.

Terminal window
curl -X PATCH https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app/rules/rule_RVeVNOTP \
-H "Authorization: Bearer $SPANSLICE_TOKEN" \
-H 'If-Match: "1"' \
-H 'Content-Type: application/json' \
-d '{ "name": "Drop health and readiness checks" }'

If-Match is optional, but without it you can overwrite someone else’s edit. Switching a rule on or off (setRuleEnabled) isn’t versioned.

Changing rules in environments that require commit

Section titled “Changing rules in environments that require commit”

A project’s rules are shared by all its environments. In an environment that applies changes as they’re made, the SDKs pick up a new rule with their next config. In an environment that requires commit, the SDKs keep running the latest commit. A change waits there as a pending change until someone commits it. To turn this on, use the environment’s Require commit switch in the app.

Here’s the whole flow with curl. Set the common parts once:

Terminal window
API=https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app
AUTH="Authorization: Bearer $SPANSLICE_TOKEN"

1. Check which environments require commit

Section titled “1. Check which environments require commit”
Terminal window
curl "$API/environments" -H "$AUTH"
{
"data": [
{ "slug": "staging", "name": "Staging", "description": null, "requires_commit": false, "position": 0 },
{ "slug": "production", "name": "Production", "description": null, "requires_commit": true, "position": 1 }
],
"next_cursor": null
}
Terminal window
curl -X POST "$API/rules" -H "$AUTH" -H 'Content-Type: application/json' -d '{
"name": "Drop health checks",
"stage": "created",
"target": "root",
"when": {
"type": "group",
"operator": "or",
"children": [
{ "type": "clause", "subject": "spanAttribute", "argument": "http.route", "operator": "is", "value": "/healthz" },
{ "type": "clause", "subject": "spanAttribute", "argument": "http.route", "operator": "is", "value": "/readyz" }
]
},
"then_actions": [{ "action": "dropTrace" }]
}'

The response is the rule as written, with its id, version, and per-environment keys. Staging runs the rule from now on. Production doesn’t run it yet.

getRuleLanguage (GET /v1/rule-language) lists everything that when and then_actions can express: each condition subject with its operators and value shapes, each action with its fields, and example rules. How rules run and Actions explain what they do.

Terminal window
curl "$API/environments/production/pending" -H "$AUTH"
{
"environment": "production",
"requires_commit": true,
"working_version": "5f0c2e9a41d3b7c8",
"committed": { "message": "Sample checkout at 1 in 10", "created_at": "2026-10-07T09:12:44.000Z", "by": "Ada" },
"changes": [
{
"id": "WyJydWxlIiwiYWRkZWQiLDE3LG51bGxd",
"kind": "rule",
"change": "added",
"rule": "rule_RVeVNOTP",
"services": ["Api", "Main"],
"after": { "key": "ZWMVUY0p", "name": "Drop health checks", "stage": "created", "target": "root" },
"revertible": true
}
]
}

changes lists every difference between what production runs now and what it would run after a commit. That includes changes other people made in the app, such as instrumentation, metrics, or destinations, not only yours.

Send back the working_version you reviewed:

Terminal window
curl -X POST "$API/environments/production/commits" -H "$AUTH" -H 'Content-Type: application/json' \
-d '{ "working_version": "5f0c2e9a41d3b7c8", "message": "Drop health checks" }'
{ "message": "Drop health checks", "created_at": "2026-10-08T14:20:01.000Z", "by": "Ada" }

Production’s SDKs now run every pending change. If anything changed after you read working_version, nothing is committed, and you get a 409. Review the pending changes again, then commit the new working_version.

To drop one change instead, revert it, sending the same working_version:

Terminal window
curl -X POST "$API/environments/production/pending/WyJydWxlIiwiYWRkZWQiLDE3LG51bGxd/revert" -H "$AUTH" \
-H 'Content-Type: application/json' -d '{ "working_version": "5f0c2e9a41d3b7c8" }'

Reverting puts the setting back the way the latest commit has it. Rules are shared, so other environments see the revert too, the same as when you revert in the app.

Errors are RFC 9457 problems (application/problem+json). Each has a stable code to branch on, and a detail that says what to change. Errors lists every code.

https://api.spanslice.com/v1/openapi.json describes every operation, parameter and object, with examples. It needs no token. Use it to generate a client, import the API into an HTTP tool, or give it to an agent. The reference on this site is built from the same spec.