---
title: "Test a request against the edge rules"
method: POST
path: "/projects/{project_id}/edge-rules/evaluate"
tags: ["Edge Rules"]
---

# Test a request against the edge rules

`POST /projects/{project_id}/edge-rules/evaluate`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/projects/{project_id}/edge-rules/evaluate`
- Auth: HTTP bearer

A dry run: what the proxy would do with the described request, against
the saved rules or the `rules` supplied. Nothing is stored or counted.

## Path parameters

- `project_id` integer, required

## Request body

- EvaluateEdgeRulesRequest: Body for the dry run.
  - `request` EdgeRuleSampleRequest, required: A request described in JSON, for `POST /edge-rules/evaluate`, the CLI's `test` command and the conformance fixtures.
    - `asn` integer, nullable
    - `bot_class` string, nullable
    - `challenge_cleared` boolean: Pretend the visitor already holds challenge clearance.
    - `continent` string, nullable
    - `country` string, nullable
    - `environment_id` integer, nullable
    - `headers` EdgeRuleSampleHeader[]
      - `name` string, required
      - `value` string, required
    - `ip` string, nullable: Client IP as the proxy would resolve it.
    - `is_hosting_provider` boolean, nullable
    - `ja4` string, nullable
    - `method` string
    - `url` string, required: Absolute URL (`https://app.example.com/path?q`) or origin-form path.
    - `user_agent` string, nullable: Shorthand for a `User-Agent` header; ignored if `headers` has one.
  - `rules` EvaluateEdgeRuleInput[], nullable: Rules to evaluate in order instead of the saved ones, e.g. an edited rule set before saving it.
    - `action` union, required: What a matching rule does.
      - object: Return an error response. Status 400–499.
        - `body` string: Plain-text body, up to 1024 bytes. Empty for a short default.
        - `status` integer, required
        - `type` 'block', required
      - object: Skip the remaining edge rules. Rate limits, attack mode and password protection still apply.
        - `type` 'allow', required
      - object: Serve the proof-of-work challenge unless the visitor holds clearance.
        - `type` 'challenge', required
      - object: Redirect to a path or an absolute URL with a fixed host. `{path}` and `{query}` insert the visitor's normalized path and raw query string.
        - `status` integer, required
        - `target` string, required
        - `type` 'redirect', required
      - object: Record the match and keep evaluating.
        - `type` 'log', required
    - `enabled` boolean
    - `environment_id` integer, nullable
    - `expression` EdgeRuleGroup, required: A group of conditions and nested groups.
      - `children` EdgeRuleExpression[]
        - union: A node of a rule's match expression.
          - object: A single test against one request attribute.
            - `case_insensitive` boolean: Compare without case. Hosts, methods, countries and enumerated fields always compare without case.
            - `field` 'ip' | 'country' | 'continent' | 'asn' | 'is_hosting_provider' | 'host' | 'path' | 'raw_path' | 'method' | 'query' | 'header' | 'cookie' | 'user_agent' | 'ja4' | 'bot_class', required: A request attribute a condition tests.
            - `id` string: Node identifier, unique within the rule. Assigned by the server when empty; used to attach validation messages to the right condition.
            - `key` string, nullable: Header, query parameter or cookie name. Required for those fields.
            - `op` 'eq' | 'in' | 'in_cidr' | 'starts_with' | 'ends_with' | 'contains' | 'glob' | 'regex' | 'exists' | 'not_exists', required: How a condition compares the request value with its `values`.
            - `values` string[]: One value for single-value operators, a list for `in`/`in_cidr`, none for `exists`/`not_exists`.
            - `kind` 'condition', required
          - object: A group of conditions and nested groups.
            - `children` EdgeRuleExpression[]
            - `combinator` 'all' | 'any' | 'none', required: How a group combines its children. `none` is `not(any(...))`.
            - `id` string
            - `kind` 'group', required
      - `combinator` 'all' | 'any' | 'none', required: How a group combines its children. `none` is `not(any(...))`.
      - `id` string
    - `id` integer, nullable: Saved rule id, or omit for an unsaved draft.
    - `mode` 'enforce' | 'log_only': `log_only` evaluates the rule and records matches but never acts.
    - `name` string, nullable

## Response `200`

The decision and a per-rule trace

- EvaluateEdgeRulesResponse: What the proxy would do with the request.
  - `decision` union, required: The final decision for a request.
    - object: No rule decided: the request continues down the pipeline.
      - `kind` 'forward', required
    - object
      - `body` string, required
      - `kind` 'block', required
      - `rule_id` integer, required
      - `status` integer, required
    - object
      - `kind` 'allow', required
      - `rule_id` integer, required
    - object
      - `kind` 'challenge', required
      - `rule_id` integer, required
    - object
      - `kind` 'redirect', required
      - `location` string, required
      - `rule_id` integer, required
      - `status` integer, required
  - `matched_mode` 'enforce' | 'log_only', nullable: `log_only` evaluates the rule and records matches but never acts.
  - `matched_rule_id` integer, nullable: The rule the proxy log would record: the deciding rule, or the first rule that matched in log-only mode.
  - `summary` string, required: The decision in one sentence.
  - `trace` EvaluateEdgeRuleTraceEntry[], required
    - `name` string, required
    - `outcome` 'disabled' | 'other_environment' | 'not_reached' | 'no_match' | 'ambiguous_path' | 'logged' | 'challenge_passed' | 'decided', required: How each rule fared, for the dry-run trace.
    - `rule_id` integer, required: Saved rule id, or a negative placeholder for an unsaved draft (`-1` for the first draft, `-2` for the second, ...).

## Other responses

- `400`: A supplied rule is invalid
- `401`: Unauthorized
- `403`: Insufficient permissions
- `404`: Project not found
- `500`: Internal server error

## Changes

- **2026-11-09** `12896146b193`: 5 breaking
  - removed the required property `extensions` from the response with the `400` status
  - removed the required property `extensions` from the response with the `401` status
  - removed the required property `extensions` from the response with the `403` status
  - removed the required property `extensions` from the response with the `404` status
  - …1 more
- **2026-10-31** `c2d57aea4875`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/projects/:project_id/edge-rules/evaluate/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
