Rules
Span rules: conditions on a span and the actions to take when it matches. They are what SpanSlice runs in your SDKs.
List rules
Section titled “List rules”GET/v1/orgs/{org}/projects/{project}/rules
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
| Name | In | Type | Description |
|---|---|---|---|
orgrequired | path | string | The organization's slug, as in its URL in the app. Example: "snugghome". |
projectrequired | path | string | The project's slug, as in its URL in the app. Example: "snugghome-app". |
limit | query | integer | How many items to return, 1 to 200. Default 100. |
cursor | query | string | A previous page's next_cursor, to fetch the page after it. Omit for the first page. |
Example request
curl https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app/rules \ -H "Authorization: Bearer $SPANSLICE_TOKEN"Response 200
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
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The request is invalid; errors says where. |
| 401 | unauthorized | The access token is missing, unknown, expired or revoked. |
| 404 | not_found | It doesn't exist, or this token can't reach it. |
Create a rule
Section titled “Create a rule”POST/v1/orgs/{org}/projects/{project}/rules
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
| Name | In | Type | Description |
|---|---|---|---|
orgrequired | path | string | The organization's slug, as in its URL in the app. Example: "snugghome". |
projectrequired | path | string | The project's slug, as in its URL in the app. Example: "snugghome-app". |
Request body
CreateRuleRequest, required.
Example request
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
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
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The rule is invalid: detail names the field, as the editor would. |
| 401 | unauthorized | The access token is missing, unknown, expired or revoked. |
| 403 | forbidden | The token's role is too low for this operation. |
| 404 | not_found | It doesn't exist, or this token can't reach it. |
Get a rule
Section titled “Get a rule”GET/v1/orgs/{org}/projects/{project}/rules/{rule}
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
| Name | In | Type | Description |
|---|---|---|---|
orgrequired | path | string | The organization's slug, as in its URL in the app. Example: "snugghome". |
projectrequired | path | string | The project's slug, as in its URL in the app. Example: "snugghome-app". |
rulerequired | path | string | The 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
curl https://api.spanslice.com/v1/orgs/snugghome/projects/snugghome-app/rules/rule_RVeVNOTP \ -H "Authorization: Bearer $SPANSLICE_TOKEN"Response 200
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
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The request is invalid; errors says where. |
| 401 | unauthorized | The access token is missing, unknown, expired or revoked. |
| 404 | not_found | It doesn't exist, or this token can't reach it. |
Update a rule
Section titled “Update a rule”PATCH/v1/orgs/{org}/projects/{project}/rules/{rule}
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
| Name | In | Type | Description |
|---|---|---|---|
orgrequired | path | string | The organization's slug, as in its URL in the app. Example: "snugghome". |
projectrequired | path | string | The project's slug, as in its URL in the app. Example: "snugghome-app". |
rulerequired | path | string | The 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-Match | header | string | The rule's version you read. If it has changed since, nothing is written and you get a 412. |
Request body
UpdateRuleRequest, required.
Example request
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
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
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The rule as edited is invalid: detail names the field. |
| 401 | unauthorized | The access token is missing, unknown, expired or revoked. |
| 403 | forbidden | The token's role is too low for this operation. |
| 404 | not_found | It doesn't exist, or this token can't reach it. |
| 412 | precondition_failed | The rule changed since the version in If-Match; read it again. |
Delete a rule
Section titled “Delete a rule”DELETE/v1/orgs/{org}/projects/{project}/rules/{rule}
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
| Name | In | Type | Description |
|---|---|---|---|
orgrequired | path | string | The organization's slug, as in its URL in the app. Example: "snugghome". |
projectrequired | path | string | The project's slug, as in its URL in the app. Example: "snugghome-app". |
rulerequired | path | string | The 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
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
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The request is invalid; errors says where. |
| 401 | unauthorized | The access token is missing, unknown, expired or revoked. |
| 403 | forbidden | The token's role is too low for this operation. |
| 404 | not_found | It doesn't exist, or this token can't reach it. |
Switch a rule on or off
Section titled “Switch a rule on or off”PATCH/v1/orgs/{org}/projects/{project}/rules/{rule}/enabled
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
| Name | In | Type | Description |
|---|---|---|---|
orgrequired | path | string | The organization's slug, as in its URL in the app. Example: "snugghome". |
projectrequired | path | string | The project's slug, as in its URL in the app. Example: "snugghome-app". |
rulerequired | path | string | The 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
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
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
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The request is invalid; errors says where. |
| 401 | unauthorized | The access token is missing, unknown, expired or revoked. |
| 403 | forbidden | The token's role is too low for this operation. |
| 404 | not_found | It doesn't exist, or this token can't reach it. |
Reorder a list of rules
Section titled “Reorder a list of rules”PUT/v1/orgs/{org}/projects/{project}/rules/order
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
| Name | In | Type | Description |
|---|---|---|---|
orgrequired | path | string | The organization's slug, as in its URL in the app. Example: "snugghome". |
projectrequired | path | string | The project's slug, as in its URL in the app. Example: "snugghome-app". |
Request body
ReorderRulesRequest, required.
Example request
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
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
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The request is invalid; errors says where. |
| 401 | unauthorized | The access token is missing, unknown, expired or revoked. |
| 403 | forbidden | The token's role is too low for this operation. |
| 404 | not_found | It doesn't exist, or this token can't reach it. |
Describe the rule language
Section titled “Describe the rule language”GET/v1/rule-language
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
curl https://api.spanslice.com/v1/rule-language \ -H "Authorization: Bearer $SPANSLICE_TOKEN"Response 200
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
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | The access token is missing, unknown, expired or revoked. |
| 404 | not_found | It doesn't exist, or this token can't reach it. |