Skip to content

Rules

Span rules: conditions on a span and the actions to take when it matches. They are what SpanSlice runs in your SDKs.

GET/v1/orgs/{org}/projects/{project}/rules

listRulesRole: viewer or higher

A project's span rules, in the order they run: rules with stage created before rules with stage completed, and within a stage each service's own rules before the project's.

Parameters

NameInTypeDescription
orgrequiredpathstringThe organization's slug, as in its URL in the app. Example: "snugghome".
projectrequiredpathstringThe project's slug, as in its URL in the app. Example: "snugghome-app".
limitqueryintegerHow many items to return, 1 to 200. Default 100.
cursorquerystringA previous page's next_cursor, to fetch the page after it. Omit for the first page.

Example request

Terminal window
curl https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app/rules \
-H "Authorization: Bearer $SPANSLICE_TOKEN"

Response 200

ListRulesResponse

Example response
{
"data": [
{
"id": "rule_RVeVNOTP",
"name": "Drop health checks",
"title": "Drop traces with http.route = /healthz",
"stage": "created",
"target": "root",
"service": null,
"when": {
"type": "group",
"operator": "and",
"children": [
{
"type": "clause",
"subject": "spanAttribute",
"argument": "http.route",
"operator": "is",
"value": "/healthz"
}
]
},
"then_actions": [
{
"action": "dropTrace"
}
],
"position": 0,
"version": 1,
"disabled": [
{
"service": "worker",
"environment": "staging"
}
],
"keys": {
"staging": "gZHXJsCM",
"production": "ZWMVUY0p"
},
"created_at": "2026-10-08T14:03:12.000Z",
"updated_at": "2026-10-08T14:03:12.000Z"
}
],
"next_cursor": null
}

Errors

StatusCodeWhen
400invalid_requestThe request is invalid; errors says where.
401unauthorizedThe access token is missing, unknown, expired or revoked.
404not_foundIt doesn't exist, or this token can't reach it.

POST/v1/orgs/{org}/projects/{project}/rules

createRuleRole: member or higher

Adds a rule at the end of its list (stage and service). It runs everywhere it applies at once, except in environments that require commit, where it waits as a pending change until someone commits.

Parameters

NameInTypeDescription
orgrequiredpathstringThe organization's slug, as in its URL in the app. Example: "snugghome".
projectrequiredpathstringThe project's slug, as in its URL in the app. Example: "snugghome-app".

Request body

CreateRuleRequest, required.

Example request

Terminal window
curl -X POST https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app/rules \
-H "Authorization: Bearer $SPANSLICE_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"name": "Drop health checks",
"stage": "created",
"target": "root",
"when": {
"type": "group",
"operator": "and",
"children": [
{
"type": "clause",
"subject": "spanAttribute",
"argument": "http.route",
"operator": "is",
"value": "/healthz"
}
]
},
"then_actions": [
{
"action": "dropTrace"
}
]
}'

Response 201

Rule

Example response
{
"id": "rule_RVeVNOTP",
"name": "Drop health checks",
"title": "Drop traces with http.route = /healthz",
"stage": "created",
"target": "root",
"service": null,
"when": {
"type": "group",
"operator": "and",
"children": [
{
"type": "clause",
"subject": "spanAttribute",
"argument": "http.route",
"operator": "is",
"value": "/healthz"
}
]
},
"then_actions": [
{
"action": "dropTrace"
}
],
"position": 0,
"version": 1,
"disabled": [
{
"service": "worker",
"environment": "staging"
}
],
"keys": {
"staging": "gZHXJsCM",
"production": "ZWMVUY0p"
},
"created_at": "2026-10-08T14:03:12.000Z",
"updated_at": "2026-10-08T14:03:12.000Z"
}

Errors

StatusCodeWhen
400invalid_requestThe rule is invalid: detail names the field, as the editor would.
401unauthorizedThe access token is missing, unknown, expired or revoked.
403forbiddenThe token's role is too low for this operation.
404not_foundIt doesn't exist, or this token can't reach it.

GET/v1/orgs/{org}/projects/{project}/rules/{rule}

getRuleRole: viewer or higher

One rule, by its id or by a key from a span's spanslice.rules attribute: to find what changed a span, look up each key it carries.

Parameters

NameInTypeDescription
orgrequiredpathstringThe organization's slug, as in its URL in the app. Example: "snugghome".
projectrequiredpathstringThe project's slug, as in its URL in the app. Example: "snugghome-app".
rulerequiredpathstringThe rule's id (rule_…), or a key a span carries in spanslice.rules. Each environment has its own key, so a span leads straight to its rule. Example: "rule_RVeVNOTP".

Example request

Terminal window
curl https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app/rules/rule_RVeVNOTP \
-H "Authorization: Bearer $SPANSLICE_TOKEN"

Response 200

Rule

Example response
{
"id": "rule_RVeVNOTP",
"name": "Drop health checks",
"title": "Drop traces with http.route = /healthz",
"stage": "created",
"target": "root",
"service": null,
"when": {
"type": "group",
"operator": "and",
"children": [
{
"type": "clause",
"subject": "spanAttribute",
"argument": "http.route",
"operator": "is",
"value": "/healthz"
}
]
},
"then_actions": [
{
"action": "dropTrace"
}
],
"position": 0,
"version": 1,
"disabled": [
{
"service": "worker",
"environment": "staging"
}
],
"keys": {
"staging": "gZHXJsCM",
"production": "ZWMVUY0p"
},
"created_at": "2026-10-08T14:03:12.000Z",
"updated_at": "2026-10-08T14:03:12.000Z"
}

Errors

StatusCodeWhen
400invalid_requestThe request is invalid; errors says where.
401unauthorizedThe access token is missing, unknown, expired or revoked.
404not_foundIt doesn't exist, or this token can't reach it.

PATCH/v1/orgs/{org}/projects/{project}/rules/{rule}

updateRuleRole: member or higher

Changes the fields sent and leaves the rest. Moving a rule to another stage or service puts it at the end of that list; moving it to one service keeps only that service's switches. Send If-Match with the version you read so you never overwrite someone else's edit.

Parameters

NameInTypeDescription
orgrequiredpathstringThe organization's slug, as in its URL in the app. Example: "snugghome".
projectrequiredpathstringThe project's slug, as in its URL in the app. Example: "snugghome-app".
rulerequiredpathstringThe rule's id (rule_…), or a key a span carries in spanslice.rules. Each environment has its own key, so a span leads straight to its rule. Example: "rule_RVeVNOTP".
If-MatchheaderstringThe rule's version you read. If it has changed since, nothing is written and you get a 412.

Request body

UpdateRuleRequest, required.

Example request

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"
}'

Response 200

Rule

Example response
{
"id": "rule_RVeVNOTP",
"name": "Drop health checks",
"title": "Drop traces with http.route = /healthz",
"stage": "created",
"target": "root",
"service": null,
"when": {
"type": "group",
"operator": "and",
"children": [
{
"type": "clause",
"subject": "spanAttribute",
"argument": "http.route",
"operator": "is",
"value": "/healthz"
}
]
},
"then_actions": [
{
"action": "dropTrace"
}
],
"position": 0,
"version": 2,
"disabled": [
{
"service": "worker",
"environment": "staging"
}
],
"keys": {
"staging": "gZHXJsCM",
"production": "ZWMVUY0p"
},
"created_at": "2026-10-08T14:03:12.000Z",
"updated_at": "2026-10-08T14:03:12.000Z"
}

Errors

StatusCodeWhen
400invalid_requestThe rule as edited is invalid: detail names the field.
401unauthorizedThe access token is missing, unknown, expired or revoked.
403forbiddenThe token's role is too low for this operation.
404not_foundIt doesn't exist, or this token can't reach it.
412precondition_failedThe rule changed since the version in If-Match; read it again.

DELETE/v1/orgs/{org}/projects/{project}/rules/{rule}

deleteRuleRole: member or higher

Deletes the rule and its history. In environments that require commit, SDKs keep running it until the deletion is committed. To stop it somewhere without deleting it, use setRuleEnabled.

Parameters

NameInTypeDescription
orgrequiredpathstringThe organization's slug, as in its URL in the app. Example: "snugghome".
projectrequiredpathstringThe project's slug, as in its URL in the app. Example: "snugghome-app".
rulerequiredpathstringThe rule's id (rule_…), or a key a span carries in spanslice.rules. Each environment has its own key, so a span leads straight to its rule. Example: "rule_RVeVNOTP".

Example request

Terminal window
curl -X DELETE https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app/rules/rule_RVeVNOTP \
-H "Authorization: Bearer $SPANSLICE_TOKEN"

Response 204

No content.

Errors

StatusCodeWhen
400invalid_requestThe request is invalid; errors says where.
401unauthorizedThe access token is missing, unknown, expired or revoked.
403forbiddenThe token's role is too low for this operation.
404not_foundIt doesn't exist, or this token can't reach it.

PATCH/v1/orgs/{org}/projects/{project}/rules/{rule}/enabled

setRuleEnabledRole: member or higher

Switches the rule on or off for the (service, environment) pairs named, leaving the others as they are. A pair must be a deployment the rule applies to. This is not a versioned edit.

Parameters

NameInTypeDescription
orgrequiredpathstringThe organization's slug, as in its URL in the app. Example: "snugghome".
projectrequiredpathstringThe project's slug, as in its URL in the app. Example: "snugghome-app".
rulerequiredpathstringThe rule's id (rule_…), or a key a span carries in spanslice.rules. Each environment has its own key, so a span leads straight to its rule. Example: "rule_RVeVNOTP".

Request body

SetRuleEnabledRequest, required.

Example request

Terminal window
curl -X PATCH https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app/rules/rule_RVeVNOTP/enabled \
-H "Authorization: Bearer $SPANSLICE_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"cells": [
{
"service": "worker",
"environment": "staging",
"enabled": false
}
]
}'

Response 200

Rule

Example response
{
"id": "rule_RVeVNOTP",
"name": "Drop health checks",
"title": "Drop traces with http.route = /healthz",
"stage": "created",
"target": "root",
"service": null,
"when": {
"type": "group",
"operator": "and",
"children": [
{
"type": "clause",
"subject": "spanAttribute",
"argument": "http.route",
"operator": "is",
"value": "/healthz"
}
]
},
"then_actions": [
{
"action": "dropTrace"
}
],
"position": 0,
"version": 1,
"disabled": [
{
"service": "worker",
"environment": "staging"
}
],
"keys": {
"staging": "gZHXJsCM",
"production": "ZWMVUY0p"
},
"created_at": "2026-10-08T14:03:12.000Z",
"updated_at": "2026-10-08T14:03:12.000Z"
}

Errors

StatusCodeWhen
400invalid_requestThe request is invalid; errors says where.
401unauthorizedThe access token is missing, unknown, expired or revoked.
403forbiddenThe token's role is too low for this operation.
404not_foundIt doesn't exist, or this token can't reach it.

PUT/v1/orgs/{org}/projects/{project}/rules/order

reorderRulesRole: member or higher

Sets the order of one list: the rules of one stage at project scope (service: null) or for one service. order must name every rule in that list exactly once.

Parameters

NameInTypeDescription
orgrequiredpathstringThe organization's slug, as in its URL in the app. Example: "snugghome".
projectrequiredpathstringThe project's slug, as in its URL in the app. Example: "snugghome-app".

Request body

ReorderRulesRequest, required.

Example request

Terminal window
curl -X PUT https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app/rules/order \
-H "Authorization: Bearer $SPANSLICE_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"stage": "created",
"service": null,
"order": [
"rule_q13u1f9T",
"rule_RVeVNOTP"
]
}'

Response 200

ReorderRulesResponse

Example response
{
"data": [
{
"id": "rule_q13u1f9T",
"name": "Name spans by route",
"title": "Drop traces with http.route = /healthz",
"stage": "created",
"target": "root",
"service": null,
"when": {
"type": "group",
"operator": "and",
"children": [
{
"type": "clause",
"subject": "spanAttribute",
"argument": "http.route",
"operator": "is",
"value": "/healthz"
}
]
},
"then_actions": [
{
"action": "dropTrace"
}
],
"position": 0,
"version": 1,
"disabled": [
{
"service": "worker",
"environment": "staging"
}
],
"keys": {
"staging": "gZHXJsCM",
"production": "ZWMVUY0p"
},
"created_at": "2026-10-08T14:03:12.000Z",
"updated_at": "2026-10-08T14:03:12.000Z"
},
{
"id": "rule_RVeVNOTP",
"name": "Drop health checks",
"title": "Drop traces with http.route = /healthz",
"stage": "created",
"target": "root",
"service": null,
"when": {
"type": "group",
"operator": "and",
"children": [
{
"type": "clause",
"subject": "spanAttribute",
"argument": "http.route",
"operator": "is",
"value": "/healthz"
}
]
},
"then_actions": [
{
"action": "dropTrace"
}
],
"position": 1,
"version": 1,
"disabled": [
{
"service": "worker",
"environment": "staging"
}
],
"keys": {
"staging": "gZHXJsCM",
"production": "ZWMVUY0p"
},
"created_at": "2026-10-08T14:03:12.000Z",
"updated_at": "2026-10-08T14:03:12.000Z"
}
]
}

Errors

StatusCodeWhen
400invalid_requestThe request is invalid; errors says where.
401unauthorizedThe access token is missing, unknown, expired or revoked.
403forbiddenThe token's role is too low for this operation.
404not_foundIt doesn't exist, or this token can't reach it.

GET/v1/rule-language

getRuleLanguageRole: viewer or higher

Everything a rule's when and then_actions can say: each condition subject with its operators and value shapes, each action with its fields, example rules, and the exact JSON Schemas. Read it before writing a rule.

Example request

Terminal window
curl https://api.spanslice.com/v1/rule-language \
-H "Authorization: Bearer $SPANSLICE_TOKEN"

Response 200

GetRuleLanguageResponse

Example response
{
"conditions": "`when` is a clause or a group: { \"type\": \"group\", \"operator\": \"and\" | \"or\", \"children\": [...] }.",
"subjects": [
{
"subject": "spanName",
"description": "The span's name.",
"argument": null,
"stage": null,
"root_only": false,
"choices": null,
"operators": [
{
"operator": "is",
"label": "is",
"value": "text"
}
]
}
],
"values": {
"text": "A non-empty string. For regex, an RE2 pattern: no lookaround or backreferences."
},
"actions": [
{
"action": "dropTrace",
"description": "Drops every span of the trace. It beats every sample rate.",
"scope": "trace",
"once": true,
"in_descendants": false,
"fields": {},
"required": []
}
],
"examples": [
{
"name": "Drop health checks",
"stage": "created",
"target": "root",
"when": {
"type": "clause",
"subject": "spanAttribute",
"argument": "http.route",
"operator": "in",
"value": [
"/healthz",
"/readyz"
]
},
"then_actions": [
{
"action": "dropTrace"
}
]
}
],
"json_schema": {
"condition": {},
"action": {}
}
}

Errors

StatusCodeWhen
401unauthorizedThe access token is missing, unknown, expired or revoked.
404not_foundIt doesn't exist, or this token can't reach it.