> ## Documentation Index
> Fetch the complete documentation index at: https://silmaril.security/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Classify an event

> Return a Firewall decision for one complete event.

Send one complete event in `text`. For multiple independent events, use [batch classification](https://silmaril.security/docs/api-reference/v2/batch.md).

The request body is the same as in [version 1](https://silmaril.security/docs/api-reference/classify.md). The request URL is your provisioned `SILMARIL_API_URL` with the final `/classify` replaced by `/v2/classify`. Each example derives it. Read the decision from the single item in `results` and enforce on its `action`.

Choose cURL, TypeScript, JavaScript, Python, Go, or Java in the request examples. They use standard HTTP libraries. The Java example requires Java 17 or later.

```bash cURL theme={"theme":"github-light-default"}
curl --request POST "${SILMARIL_API_URL%/classify}/v2/classify" \
  --header "x-api-key: $SILMARIL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "text": "Summarize this release note.",
    "hook": "user_input",
    "metadata": {"conversationId": "conv-123"}
  }'
```

```python Python theme={"theme":"github-light-default"}
import json
import os
from urllib.request import Request, urlopen

request = Request(
    os.environ["SILMARIL_API_URL"].removesuffix("/classify") + "/v2/classify",
    data=json.dumps({
        "text": "Summarize this release note.",
        "hook": "user_input",
        "metadata": {"conversationId": "conv-123"},
    }).encode("utf-8"),
    headers={
        "x-api-key": os.environ["SILMARIL_API_KEY"],
        "Content-Type": "application/json",
    },
    method="POST",
)

with urlopen(request, timeout=10) as response:
    result = json.load(response)

print(result)
```

```typescript TypeScript theme={"theme":"github-light-default"}
const url = process.env.SILMARIL_API_URL!.replace(/\/classify$/, "") + "/v2/classify";

const response = await fetch(url, {
  method: "POST",
  headers: {
    "x-api-key": process.env.SILMARIL_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    text: "Summarize this release note.",
    hook: "user_input",
    metadata: { conversationId: "conv-123" },
  }),
  signal: AbortSignal.timeout(10_000),
});

if (!response.ok) {
  throw new Error(`Silmaril API error: ${response.status}`);
}

const result = await response.json();
console.log(result);
```

```javascript JavaScript theme={"theme":"github-light-default"}
const url = process.env.SILMARIL_API_URL.replace(/\/classify$/, "") + "/v2/classify";

const response = await fetch(url, {
  method: "POST",
  headers: {
    "x-api-key": process.env.SILMARIL_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    text: "Summarize this release note.",
    hook: "user_input",
    metadata: { conversationId: "conv-123" },
  }),
  signal: AbortSignal.timeout(10_000),
});

if (!response.ok) {
  throw new Error(`Silmaril API error: ${response.status}`);
}

const result = await response.json();
console.log(result);
```

```go Go theme={"theme":"github-light-default"}
package main

import (
    "fmt"
    "io"
    "net/http"
    "os"
    "strings"
    "time"
)

func main() {
    if err := classify(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}

func classify() error {
    body := `{
  "text": "Summarize this release note.",
  "hook": "user_input",
  "metadata": {
    "conversationId": "conv-123"
  }
}`
    url := strings.TrimSuffix(os.Getenv("SILMARIL_API_URL"), "/classify") + "/v2/classify"
    request, err := http.NewRequest(http.MethodPost, url, strings.NewReader(body))
    if err != nil {
        return err
    }
    request.Header.Set("x-api-key", os.Getenv("SILMARIL_API_KEY"))
    request.Header.Set("Content-Type", "application/json")

    client := &http.Client{
        Timeout: 10 * time.Second,
        CheckRedirect: func(*http.Request, []*http.Request) error {
            return http.ErrUseLastResponse
        },
    }
    response, err := client.Do(request)
    if err != nil {
        return err
    }
    defer response.Body.Close()
    if response.StatusCode < 200 || response.StatusCode >= 300 {
        return fmt.Errorf("Silmaril API error: %d", response.StatusCode)
    }
    _, err = io.Copy(os.Stdout, response.Body)
    return err
}
```

```java Java theme={"theme":"github-light-default"}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class ClassifyRequest {
    public static void main(String[] args) throws Exception {
        var client = HttpClient.newBuilder()
            .connectTimeout(Duration.ofSeconds(10))
            .followRedirects(HttpClient.Redirect.NEVER)
            .build();
        var body = """
            {
              "text": "Summarize this release note.",
              "hook": "user_input",
              "metadata": {
                "conversationId": "conv-123"
              }
            }
            """;
        var url = System.getenv("SILMARIL_API_URL").replaceFirst("/classify$", "") + "/v2/classify";
        var request = HttpRequest.newBuilder(URI.create(url))
            .timeout(Duration.ofSeconds(10))
            .header("x-api-key", System.getenv("SILMARIL_API_KEY"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(body))
            .build();
        var response = client.send(request, HttpResponse.BodyHandlers.ofString());
        if (response.statusCode() < 200 || response.statusCode() >= 300) {
            throw new IllegalStateException("Silmaril API error: " + response.statusCode());
        }
        System.out.println(response.body());
    }
}
```

```json theme={"theme":"github-light-default"}
{
  "results": [
    {
      "action": "allow",
      "source": null,
      "confidence": null,
      "severity": null,
      "outcome": null,
      "governance": null,
      "model_id": "silmaril-cascade-1-6"
    }
  ]
}
```

`results` is always an array, and a single event returns one decision in it. Every key of a decision is always present and is `null` when empty. Ignore fields you do not recognize.

`model_id` identifies the model release that classified the item. Record it for provenance. Do not enforce on it.

## Handle the decision

HTTP `200` returns a decision. `action` is the only field to enforce on: treat any value other than `allow` as a block. In Block mode, stop a blocked event. In Warn or Shadow mode, record the would-block decision and continue.

Handle request failures with your application's [error policy](https://silmaril.security/docs/operate/troubleshooting.md). Error status codes and bodies are the same as in version 1. See [modes and enforcement](https://silmaril.security/docs/guides/enforcement.md) for the full decision model.

## Read a block

`source` names who decided a block: `model` or `governance`. It is `model` when both block. `outcome` is the predicted harm on a model block that has one.

```json Model block theme={"theme":"github-light-default"}
{
  "results": [
    {
      "action": "block",
      "source": "model",
      "confidence": "high",
      "severity": "moderate",
      "outcome": "control_abuse",
      "governance": null,
      "model_id": "silmaril-cascade-1-6"
    }
  ]
}
```

```json Governance block theme={"theme":"github-light-default"}
{
  "results": [
    {
      "action": "block",
      "source": "governance",
      "confidence": null,
      "severity": null,
      "outcome": null,
      "governance": {
        "action": "block",
        "rule_id": "block-shell",
        "policy_version": "policy-9",
        "resource": {
          "kind": "mcp_tool",
          "id": "search",
          "parent_id": "arxiv-mcp-server"
        },
        "identity_revision": "rev-1"
      },
      "model_id": "silmaril-cascade-1-6"
    }
  ]
}
```

`confidence` and `severity` describe the Firewall's assessment of the item, and are set only when that assessment is the reason for the block. They are `null` on an allow, on a block that came from a governance policy, and on a block the Firewall reached without that assessment.

## Optional review depth

The optional top-level `review` field accepts `standard` or `deep`. See [review depth](https://silmaril.security/docs/guides/review-depth.md) for requirements and selection behavior.

When the request sets `review`, the response carries the same value in a top-level `review` field beside `results`. The field is absent otherwise.

```json theme={"theme":"github-light-default"}
{
  "results": [
    {
      "action": "allow",
      "source": null,
      "confidence": null,
      "severity": null,
      "outcome": null,
      "governance": null,
      "model_id": "silmaril-cascade-1-6"
    }
  ],
  "review": "deep"
}
```


## OpenAPI

````yaml api-reference/generated/v2/classify.json POST /v2/classify
openapi: 3.1.0
info:
  title: Silmaril Firewall API — Classify an event
  version: 2.0.0
  description: >-
    Version 2 of the public classification contract. POST /v2/classify accepts
    the same request body as version 1 and returns one decision per item. Its
    URL is the classify URL provisioned for your deployment with the final
    /classify replaced by /v2/classify. Version 1 remains available at POST
    /classify.
servers:
  - url: https://your-deployment.example.com
    description: >-
      Replace with your deployment origin and any path prefix before
      /v2/classify.
security:
  - apiKey: []
paths:
  /v2/classify:
    post:
      summary: Classify an event
      description: Return a Firewall decision for one complete event.
      operationId: classifyEvent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SingleRequest'
            examples:
              single:
                summary: Single event
                value:
                  text: Summarize this release note.
                  hook: user_input
                  metadata:
                    conversationId: conv-123
              singleDeep:
                summary: Single event with deep review
                value:
                  text: Summarize this release note.
                  hook: user_input
                  review: deep
                  metadata:
                    conversationId: conv-123
      responses:
        '200':
          description: >-
            A results array holding the decision for the event. A block decision
            still returns HTTP 200.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyResponse'
              examples:
                allow:
                  summary: Allowed event
                  value:
                    results:
                      - action: allow
                        source: null
                        confidence: null
                        severity: null
                        outcome: null
                        governance: null
                        model_id: silmaril-cascade-1-6
                modelBlock:
                  summary: Model block with confidence and severity
                  value:
                    results:
                      - action: block
                        source: model
                        confidence: high
                        severity: moderate
                        outcome: control_abuse
                        governance: null
                        model_id: silmaril-cascade-1-6
                  description: >-
                    The Firewall's assessment of the item is the reason for the
                    block, so confidence and severity are set.
                governanceBlock:
                  summary: Governance block
                  value:
                    results:
                      - action: block
                        source: governance
                        confidence: null
                        severity: null
                        outcome: null
                        governance:
                          action: block
                          rule_id: block-shell
                          policy_version: policy-9
                          resource:
                            kind: mcp_tool
                            id: search
                            parent_id: arxiv-mcp-server
                          identity_revision: rev-1
                        model_id: silmaril-cascade-1-6
                  description: >-
                    Governance blocked the event. confidence, severity, and
                    outcome are null.
                reviewEcho:
                  summary: Allowed event with deep review acknowledged
                  value:
                    results:
                      - action: allow
                        source: null
                        confidence: null
                        severity: null
                        outcome: null
                        governance: null
                        model_id: silmaril-cascade-1-6
                    review: deep
        '400':
          description: >-
            Invalid request body, metadata, or mismatched per-item arrays.
            review must be the exact string standard or deep; null, other types,
            whitespace or case variants, and other strings are invalid. deep
            also returns HTTP 400 before classification when deep review is
            unavailable for the selected deployment. An explicit deep selection
            overrides a standard-review default. standard is available on all
            deployments. No verdict.
        '401':
          description: >-
            The direct Rust runtime reports a missing API key. Hosted gateways
            can return 403 instead. No verdict.
        '403':
          description: >-
            The direct Rust runtime reports an invalid API key, unauthorized
            traffic class, or conflicting forced surface. Hosted gateways can
            report either a missing or invalid key as 403. No verdict.
        '408':
          description: >-
            The direct Firewall runtime returns this response when the deadline
            for receiving the request body expires. Classification does not run
            and no verdict is produced. The connection is closed. Do not treat
            this response as a verdict. Python and Go SDKs intentionally retry
            HTTP 408 by default; Python supports max_retries=0 to disable
            retries, and Go callers can bound attempts with context cancellation
            or deadlines. The TypeScript SDK retries HTTP 429 only and surfaces
            HTTP 408 as an API error. This pre-classification timeout does not
            establish replay safety for model or tool operations.
          headers:
            Connection:
              description: >-
                The direct Firewall runtime closes the connection after this
                response.
              schema:
                type: string
                const: close
              example: close
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                  - code
                additionalProperties: false
                properties:
                  detail:
                    type: string
                    const: request body deadline exceeded
                  code:
                    type: string
                    const: request_body_timeout
              example:
                detail: request body deadline exceeded
                code: request_body_timeout
        '413':
          description: Request exceeds the deployment's body-size limit. No verdict.
        '429':
          description: Gateway rate limit or quota reached. Retry with backoff. No verdict.
        '500':
          description: Internal classification error. No verdict.
        '503':
          description: >-
            Classification service or authorization policy is unavailable or not
            ready. No verdict.
components:
  schemas:
    SingleRequest:
      title: Single event
      type: object
      required:
        - text
      not:
        required:
          - texts
      properties:
        text:
          type: string
          minLength: 1
          description: >-
            One complete event to classify. Input-size limits depend on your
            deployment.
          example: Summarize this release note.
        hook:
          $ref: '#/components/schemas/Hook'
        tool_name:
          type: string
          description: Tool name when checking a tool call or tool response.
          example: read_file
        metadata:
          $ref: '#/components/schemas/Metadata'
        resource:
          $ref: '#/components/schemas/Resource'
        identity_revision:
          type: string
          minLength: 1
          description: >-
            Resource-catalog revision for deployments supporting concrete
            governance identities.
        review:
          $ref: '#/components/schemas/ReviewLevel'
    ClassifyResponse:
      title: Decisions
      type: object
      required:
        - results
      additionalProperties: true
      properties:
        results:
          type: array
          items:
            $ref: '#/components/schemas/Decision'
          description: >-
            One decision per item, in input order. Always an array, for text and
            texts alike.
        review:
          $ref: '#/components/schemas/ReviewLevel'
          description: >-
            Present only when the request set review. It acknowledges the
            selection for the entire request; decisions carry no review field.
            An event may complete without additional review.
    Hook:
      type: string
      description: Boundary being checked. Use the SDK hook labels shown here.
      enum:
        - user_input
        - system_prompt
        - tool_call
        - tool_response
        - llm_output
        - unknown
      example: user_input
    Metadata:
      type: object
      additionalProperties: true
      description: >-
        JSON metadata for this event. SDKs add request identity under silmaril.
        A conversationId connects ordered single-event calls when conversation
        history is supported. Batch metadata does not connect events into a
        sequence.
      properties:
        conversationId:
          type: string
          description: >-
            Caller-owned conversation identity. Reuse for ordered single-event
            checks.
          example: conv-123
        silmaril:
          type: object
          additionalProperties: true
          description: Request identity and optional SDK-compatible governance context.
          properties:
            request_id:
              type: string
              minLength: 1
              description: Event identifier. SDKs generate this value per request.
            governance:
              type: object
              properties:
                agent:
                  type: string
                  description: >-
                    Caller attribution only; setting this field does not
                    activate or select agent-scoped rules. The authenticated
                    principal binding configured by the server selects the agent
                    identity used for policy evaluation.
                resource:
                  $ref: '#/components/schemas/GovernanceContextResource'
    Resource:
      type: object
      required:
        - kind
        - id
      additionalProperties: false
      description: >-
        Concrete governance resource, where supported. id must not be blank.
        mcp_tool requires parent_id; other resource kinds must omit parent_id.
      if:
        properties:
          kind:
            const: mcp_tool
        required:
          - kind
      then:
        required:
          - parent_id
      else:
        not:
          required:
            - parent_id
      properties:
        kind:
          type: string
          enum:
            - agent
            - tool
            - mcp_server
            - mcp_tool
            - plugin
            - skill
            - extension
        id:
          type: string
          minLength: 1
          pattern: .*\S.*
        parent_id:
          type: string
          minLength: 1
          pattern: .*\S.*
          description: Required for mcp_tool and omitted for other kinds.
    ReviewLevel:
      type: string
      enum:
        - standard
        - deep
      description: >-
        Optional request-wide review selection. standard selects standard
        review. deep requests an additional review of eligible potentially
        harmful events when available on your deployment. An event may complete
        without additional review. Omit review to inherit the deployment
        default. Review depth is independent of enforcement mode.
      example: deep
    Decision:
      title: Decision
      type: object
      required:
        - action
        - source
        - confidence
        - severity
        - outcome
        - governance
        - model_id
      additionalProperties: true
      description: >-
        The decision for one item. Every key is always present and is null when
        empty. Ignore unknown fields.
      properties:
        action:
          type: string
          enum:
            - allow
            - block
          description: >-
            The enforcement decision and the only field a client enforces on.
            Block on any value other than allow.
        source:
          type:
            - string
            - 'null'
          examples:
            - model
            - governance
          description: >-
            Who decided a block: model or governance. null on an allow. model
            when both the model and governance block. An open string, not a
            closed enum.
        confidence:
          type:
            - string
            - 'null'
          enum:
            - very_low
            - low
            - medium
            - high
            - very_high
            - null
          description: >-
            Confidence from the Firewall's assessment of the item, set only when
            that assessment is the reason for the block. A closed scale, ordered
            from very_low to very_high. null on an allow, on a block that came
            from a governance policy, and on a block the Firewall reached
            without that assessment. When set, action is block and source is
            model.
        severity:
          type:
            - string
            - 'null'
          enum:
            - minimal
            - low
            - moderate
            - high
            - critical
            - null
          description: >-
            Severity from the Firewall's assessment of the item, set only when
            that assessment is the reason for the block. A closed scale, ordered
            from minimal to critical. null on an allow, on a block that came
            from a governance policy, and on a block the Firewall reached
            without that assessment. When set, action is block and source is
            model.
        outcome:
          type:
            - string
            - 'null'
          pattern: >-
            [^\u0009-\u000D\u001C-\u0020\u0085\u00A0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000]
          examples:
            - secret_exposure
            - control_abuse
          description: >-
            The predicted harm, on a model block that has one. null otherwise.
            An open string, not a closed enum.
        governance:
          oneOf:
            - $ref: '#/components/schemas/GovernanceDecision'
            - type: 'null'
          description: >-
            The version 1 governance decision, unchanged. null when the item has
            none.
        model_id:
          type:
            - string
            - 'null'
          examples:
            - silmaril-cascade-1-6
          description: >-
            The identifier of the model release that classified the item.
            Provenance for your records, not a field to enforce on. An open
            string.
    GovernanceContextResource:
      type: object
      required:
        - kind
      description: >-
        SDK-compatible resource context. Support depends on the deployment's
        governance policy.
      properties:
        kind:
          type: string
          enum:
            - agent
            - tool
            - mcp_server
            - mcp_tool
            - plugin
            - skill
            - extension
        id:
          type: string
          description: Resource identifier.
        parent_id:
          type: string
          description: MCP server identifier for an MCP tool.
    GovernanceDecision:
      title: Governance decision
      type: object
      required:
        - action
        - policy_version
      properties:
        action:
          type: string
          enum:
            - allow
            - block
          description: Applicable governance-policy verdict.
        rule_id:
          type:
            - string
            - 'null'
          description: Matching governance rule, when present.
        policy_version:
          type: string
          description: Policy version used for the decision.
          minLength: 1
        resource:
          oneOf:
            - $ref: '#/components/schemas/GovernanceDecisionResource'
            - type: 'null'
          description: >-
            Canonical resource evidence for schema-6 decisions. Older
            deployments and unresolved identities may omit this field.
        identity_revision:
          type:
            - string
            - 'null'
          pattern: >-
            [^\u0009-\u000D\u001C-\u0020\u0085\u00A0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000]
          description: >-
            Open-ended identity-catalog revision used for the decision, when
            available.
        reason:
          type:
            - string
            - 'null'
          pattern: >-
            [^\u0009-\u000D\u001C-\u0020\u0085\u00A0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000]
          description: >-
            Open-ended decision reason supplied by the runtime, such as
            identity_unresolved.
      description: The version 1 governance decision, unchanged.
    GovernanceDecisionResource:
      type: object
      required:
        - kind
        - id
      description: >-
        Canonical resource evidence returned with a schema-6 governance
        decision. Older deployments and unresolved identities can omit the
        entire resource field.
      if:
        properties:
          kind:
            const: mcp_tool
        required:
          - kind
      then:
        required:
          - parent_id
        properties:
          parent_id:
            type: string
            minLength: 1
            pattern: .*\S.*
      else:
        properties:
          parent_id:
            type: 'null'
      properties:
        kind:
          type: string
          enum:
            - agent
            - tool
            - mcp_server
            - mcp_tool
            - plugin
            - skill
            - extension
        id:
          type: string
          minLength: 1
          pattern: .*\S.*
          description: Canonical resource identifier.
        parent_id:
          description: >-
            Canonical parent resource identifier. Required for MCP tools. Other
            resource kinds omit this field or return null.
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: API key provisioned for your deployment.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.