Skip to content
Esc
↑↓navigate↵open⌘Jpreview

List a space's traffic rules

Returns the space’s traffic rules in the order the edge reads them, each with where it was declared and what the edge last said about it. collapsed names the declared rules the edge never got because an earlier rule already covers them. The edge is read only for the quota count, so an edge that does not answer still gets you the rules, with quota.stale set and quota.limit null.

GET/v1/spaces/{spaceId}/rules
Authorization
AuthorizationBearer token · headerrequired

Space key (sfc_…) for an unclaimed anonymous Space. Also the fragment of its claim URL and the token of its /__/<key> door. A publish without a credential returns it in claim with the claim link. With the key, getSpace extends the Space's expiry window, getSpaceVersion follows its publish, createSpaceOpenLink returns its reusable open link, and restoreSpace undoes a deleteSpace while the claim window remains open.

or
AuthorizationBearer token · headerrequired

Better Auth session, OAuth access token, OAuth client-credentials token, or sfm_ Space machine credential.

or
AuthorizationOAuth2 access token · headerrequired

OAuth 2.0 with explicit Spacefast capability scopes. Use the authorization-code flow for people and client credentials for machines.

Scopes:spaces:read
Path parameters
spaceIdstringrequired
Responses
200

Response for status 200

$schemastring<uri>

Canonical JSON Schema URL for this response body. The server also sends it in the Link: rel="describedby" response header.

dataTrafficRulesrequired

A space's traffic rules and what the edge is doing with them.

Show properties
rulesTrafficRuleState[]required

The space's rules, in the order the edge reads them.

Show properties
Array of TrafficRuleState
idstringrequired

Spacefast's id for this rule.

namestringrequired

The rule's name at the edge, derived from what it does.

handlestring | nullrequired

The name the author gave the rule, or null when they gave it none.

kindstringrequired

What the rule does.

Allowed:firewallcacheBypassredirectrewriteheader
originstringrequired

Where the rule was declared: file in the space's own source, config in the live version's config, overlay in the space settings, platform by Spacefast.

Allowed:fileconfigoverlayplatform
sourceRefstring | nullrequired

The config the rule was read from, for a rule a version declared.

placementstringrequired

Where the rule runs. edge answers before the request reaches the space.

Allowed:edgeorigin
placementReasonstring | nullrequired

Why the rule runs at the space instead of the edge, or null for a rule that runs at the edge. placement_off: this space does not run its rules at the edge, so nothing about the rule was judged. Every other code is an edge_ineligible_* one, and says what about the rule the edge could not carry. edge_ineligible_capture: the rule captures part of the path, or its destination uses a capture. edge_ineligible_condition: it matches on a request fact the edge would read differently from the space, such as a country, a cookie, a query string, or the user agent. edge_ineligible_destination: it sends the visitor to another origin. edge_ineligible_status: its redirect status is not 301, 302, 307, or 308. edge_ineligible_shadowed: a published file already answers that path and the rule is not forced. edge_ineligible_order: an earlier rule that stayed at the space could answer the same request first. edge_ineligible_reentry: it is a rewrite, and the space has to match its own rules against the rewritten path. edge_ineligible_proxy: it proxies to another origin. edge_ineligible_not_found: it answers 404. edge_ineligible_path_preservation: it is a whole-host redirect, and the edge cannot carry the path across. edge_ineligible_platform_header: it sets or removes a header the platform owns. edge_ineligible_header_folds: more than one rule sets the same header, and the space folds them where the edge would replace. edge_ineligible_quota: the space has more placeable rules than the edge holds.

desiredStatestringrequired

What the rule is meant to do. suspended is a paused space's parked rule.

Allowed:enableddisabledsuspended
edgeStatestringrequired

What the edge last said about the rule. pending means the edge accepted it and is still applying it; over_quota means the space has more rules than the edge allows and this one was left off.

Allowed:pendingliveinvalidover_quotafailedunknown
definitionTrafficRuleDefinition | nullrequired

The rule as its author wrote it. Null for a rule the edge still holds but the space no longer declares: the next reconcile removes it, and there is no authored rule left to show.

Show properties
Any of:
object | TrafficRuleRoutingDefinition
Any of:
object
namestring

Name for this rule: lowercase letters, digits, - and _, up to 61 characters. Names the rule in the CLI and the API.

matches ^[a-z0-9][a-z0-9_-]{0,60}$
descriptionstring

What this rule is for.

max length 255
actionstringrequired

block answers without reaching the space; challenge asks for proof of a human.

Allowed:blockchallenge
statusinteger

Status a blocked request gets. Defaults to 403. Blocks only.

min 400 · max 499
matchTrafficRuleMatchrequired

Request attributes the rule looks at. At least one.

Show properties
pathTrafficRuleValue

What the field has to match. A string with a * in it matches as a wildcard, any other string matches exactly, and a list matches any of its values. An ip value with a / in it matches a CIDR range. Everything else is an explicit clause: { "op": "exists" }, { "op": "contains", "value": "bot" }, { "op": "in", "values": ["RU"], "not": true }.

Show properties
Any of:
string
string
string[]
Array of string
string
TrafficRuleClause
opstringrequired

How the request attribute is compared to the value.

Allowed:eqneqininCidrcontainsstartsWithendsWithwildcardexists
valuestring

Single value to compare against.

min length 1 · max length 4096
valuesstring[]

Values to compare against, for in and inCidr.

min items 1 · max items 1000
notboolean

Match when the comparison does not hold.

hostTrafficRuleValue

What the field has to match. A string with a * in it matches as a wildcard, any other string matches exactly, and a list matches any of its values. An ip value with a / in it matches a CIDR range. Everything else is an explicit clause: { "op": "exists" }, { "op": "contains", "value": "bot" }, { "op": "in", "values": ["RU"], "not": true }.

methodTrafficRuleValue

What the field has to match. A string with a * in it matches as a wildcard, any other string matches exactly, and a list matches any of its values. An ip value with a / in it matches a CIDR range. Everything else is an explicit clause: { "op": "exists" }, { "op": "contains", "value": "bot" }, { "op": "in", "values": ["RU"], "not": true }.

ipTrafficRuleValue

What the field has to match. A string with a * in it matches as a wildcard, any other string matches exactly, and a list matches any of its values. An ip value with a / in it matches a CIDR range. Everything else is an explicit clause: { "op": "exists" }, { "op": "contains", "value": "bot" }, { "op": "in", "values": ["RU"], "not": true }.

countryTrafficRuleValue

Two-letter country codes.

asnTrafficRuleValue

What the field has to match. A string with a * in it matches as a wildcard, any other string matches exactly, and a list matches any of its values. An ip value with a / in it matches a CIDR range. Everything else is an explicit clause: { "op": "exists" }, { "op": "contains", "value": "bot" }, { "op": "in", "values": ["RU"], "not": true }.

userAgentTrafficRuleValue

What the field has to match. A string with a * in it matches as a wildcard, any other string matches exactly, and a list matches any of its values. An ip value with a / in it matches a CIDR range. Everything else is an explicit clause: { "op": "exists" }, { "op": "contains", "value": "bot" }, { "op": "in", "values": ["RU"], "not": true }.

refererTrafficRuleValue

What the field has to match. A string with a * in it matches as a wildcard, any other string matches exactly, and a list matches any of its values. An ip value with a / in it matches a CIDR range. Everything else is an explicit clause: { "op": "exists" }, { "op": "contains", "value": "bot" }, { "op": "in", "values": ["RU"], "not": true }.

headerobject

Per-name conditions: { "x-api-client": { "op": "exists" } }.

cookieobject

Per-name conditions: { "x-api-client": { "op": "exists" } }.

queryobject

Per-name conditions: { "x-api-client": { "op": "exists" } }.

extensionTrafficRuleValue

Path extension, without the dot.

ja3TrafficRuleValue

What the field has to match. A string with a * in it matches as a wildcard, any other string matches exactly, and a list matches any of its values. An ip value with a / in it matches a CIDR range. Everything else is an explicit clause: { "op": "exists" }, { "op": "contains", "value": "bot" }, { "op": "in", "values": ["RU"], "not": true }.

ja4TrafficRuleValue

What the field has to match. A string with a * in it matches as a wildcard, any other string matches exactly, and a list matches any of its values. An ip value with a / in it matches a CIDR range. Everything else is an explicit clause: { "op": "exists" }, { "op": "contains", "value": "bot" }, { "op": "in", "values": ["RU"], "not": true }.

anyboolean

Fire when any match field holds. Defaults to false: all of them have to.

object
namestring

Name for this rule: lowercase letters, digits, - and _, up to 61 characters. Names the rule in the CLI and the API.

matches ^[a-z0-9][a-z0-9_-]{0,60}$
descriptionstring

What this rule is for.

max length 255
matchTrafficRuleMatchrequired

Request attributes the rule looks at. At least one.

anyboolean

Fire when any match field holds. Defaults to false: all of them have to.

TrafficRuleRoutingDefinition
sourcestringrequired

The path the rule matches.

destinationstring

Where a redirect sends the request.

statusinteger

The status a redirect answers with.

min -9007199254740991 · max 9007199254740991
headersstring[]

The response header names a header rule sets or removes.

forceboolean

True when a redirect answers even if a published file can serve its source. Absent on a header rule.

queryobject

The query parameters a redirect matches, each mapped to the capture name it fills. Absent when the rule matches on the path only.

conditionalboolean

True when the rule also matches on a country, a language, a cookie, or the user agent. Only a _redirects line can state those, so a rule with this flag cannot be written in the space settings.

null
null
lastErrorobject | nullrequired

Why the edge refused the rule, or null.

Show properties
Any of:
object
codestringrequired
messagestringrequired
null
null
quotaobject | nullrequired

How many rules this space has at the edge and how many it may have. Null means the space has no edge yet, so there is no allowance to spend. stale: false is the edge's own answer; stale: true is our record of it, because the edge did not answer.

Show properties
Any of:
object
usedintegerrequired

Rules this space currently has at the edge.

min -9007199254740991 · max 9007199254740991
limitinteger | nullrequired

Rules the edge allows this space. Null when the edge could not be read, because the allowance is the edge's to state and this platform does not know it.

Show properties
Any of:
integer
integer
null
null
stalebooleanrequired

True when the edge could not be reached, so these numbers are this platform's own record rather than the edge's answer.

null
null
pausedbooleanrequired

True while the space is paused. A paused space serves as if it declared none, and a rule it declares while paused is parked as it arrives.

hostnamesstring[]required

The hostnames these rules answer on.

collapsedCollapsedTrafficRule[]required

Rules the space declares that the edge never got, and why.

Show properties
Array of CollapsedTrafficRule
ruleNamestringrequired

The rule's name at the edge.

originstringrequired

Where the rule was declared: file in the space's own source, config in the live version's config, overlay in the space settings, platform by Spacefast.

Allowed:fileconfigoverlayplatform
reasonstringrequired

fingerprint: an earlier rule already does the same thing. name: an earlier rule already has this name.

Allowed:fingerprintname
default

Problem details (RFC 9457). Any 4xx/5xx response is one application/problem+json document.

$schemastring<uri>

Canonical JSON Schema URL for this response body. The server also sends it in the Link: rel="describedby" response header.

typestringrequired

Problem type URI resolving to the error docs page. The server derives it mechanically from code against the docs origin.

titlestringrequired

Short human-readable summary of the problem type. The server derives it mechanically from code.

statusintegerrequired

HTTP status code of this response, repeated in the body.

min -9007199254740991 · max 9007199254740991
detailstringrequired

Human-readable failure explanation for this occurrence.

codestringrequired

Stable snake_case error code naming the failed public contract.

pointerstring

RFC 6901 JSON Pointer into the failing request field, for example "/files/37/path", on validation failures.

detailsobject

Machine-readable context for the error code.

fixstring

One sentence on what to do about this error code, the same text as the type page. Read it before retrying.

suggestionsstring[]

Actionable recovery steps safe to show in dashboards, SDKs, and CLI output.

nextstring[]

Copy-pasteable commands or API requests an agent can run next.

requestIdstringrequired

The request id to quote when contacting support.

Try it
Server
Authorization
Parameters
Request
curl -X GET 'https://api.spacefast.com/v1/spaces/string/rules' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json'
Response
{
  "$schema": "http://example.com",
  "data": {
    "rules": [
      {
        "id": "string",
        "name": "string",
        "handle": "string",
        "kind": "firewall",
        "origin": "file",
        "sourceRef": "string",
        "placement": "edge",
        "placementReason": "string",
        "desiredState": "enabled",
        "edgeState": "pending",
        "definition": {
          "name": "string",
          "description": "string",
          "action": "block",
          "status": 400,
          "match": {
            "path": "string",
            "host": "string",
            "method": "string",
            "ip": "string",
            "country": "string",
            "asn": "string",
            "userAgent": "string",
            "referer": "string",
            "header": {
              "property1": "string",
              "property2": "string"
            },
            "cookie": {
              "property1": "string",
              "property2": "string"
            },
            "query": {
              "property1": "string",
              "property2": "string"
            },
            "extension": "string",
            "ja3": "string",
            "ja4": "string"
          },
          "any": true
        },
        "lastError": {
          "code": "string",
          "message": "string"
        }
      }
    ],
    "quota": {
      "used": -9007199254740991,
      "limit": -9007199254740991,
      "stale": true
    },
    "paused": true,
    "hostnames": [
      "string"
    ],
    "collapsed": [
      {
        "ruleName": "string",
        "origin": "file",
        "reason": "fingerprint"
      }
    ]
  }
}

Was this page helpful?