Skip to main content
POST/rampart/classify

Classify Content

Classifies the submitted content and returns its classification, a risk score and a confidence (both in basis points, 0 to 10000), any categories, and the classifier's calibration version.

The classification (clear, suspicious or malicious) is a risk signal for your own decision: malicious is not an instruction to block, and suspicious is not a reason to block automatically.

Weigh it with what you know about the request, for example route it for review or ask the user to confirm.

Body: input (an object, required) and an optional label (1 to 128 characters) naming the context.

The response also carries a signed classificationReceipt: a compact JWS with the protected-header typ k9o.rampart.classify.v1, signed with EdDSA.

It binds the SHA-256 of the input's canonical JSON (RFC 8785), the result, the project, the calibration version and windows, the number of windows scored.

Verify it against the key whose kid the receipt names, published at GET /rampart/jwks.

The receipt is advisory: a record of what the classifier answered, not an authorization.

Long input is never truncated: it is scored in overlapping windows of up to 512 tokens (128 tokens of overlap), and the result is the window with the highest risk.

Input that needs more than 16 windows (about 6,000 tokens) answers 413 K9O_RAMPART_INPUT_TOO_LONG with no classification.

If the classifier is unreachable or returns an unusable result for any window, the request fails closed with 503 K9O_RAMPART_CLASSIFIER_UNAVAILABLE; no classification is invented, and no partial result is returned.

Requires membership in the project; an organization-level role alone does not grant access.

Parameters
projectSlug *path

The project's slug: the path segment after @.

It is unique within the org.

Request body
input *object

The content to classify, as a JSON object.

Rampart scores it for prompt injection: text written to make a model ignore its instructions.

Send anything you want checked in one object: a prompt, a tool call's arguments, a retrieved document, an incoming email, or a prompt together with the content it pulled in.

To classify plain text, send {"text": "..."}.

Rules:

  • input must be an object. A string, array or null gets 400 K9O_INVALID_FIELD_VALUE with context.reason not_an_object.
  • Numbers must be integers up to 2^53-1. A fraction or a larger integer gets 400 naming the field's path, for example input.items[2].price, because the receipt hashes the exact input.
  • Up to about 6,000 tokens. Longer input gets 413 K9O_RAMPART_INPUT_TOO_LONG and no verdict.

How it is read: the object is flattened to one key: value line per value.

Keys are sorted at every level, and keys are read as well as values, because a key can carry an injection too.

Each array item is its own line under the array's key.

A nested object puts its key on its own line, then its members.

Numbers, booleans and null appear as their JSON literal.

Long input is scored in overlapping 512-token windows, and the highest-scoring window decides.

An empty object is clear, and its receipt records that no window was scored.

labelstring

A short label naming where the content came from, such as a tool name.

It is not scored.

Default rampart_classify.

Responses
HTTPK9O CodeDescription
200Success
400K9O_INVALID_FIELD_VALUEThe request body failed validation (input must be an object; optional label 1-128 chars).
401K9O_UNAUTHENTICATEDThe caller is not signed in; authenticate before requesting a classification.
403K9O_ACCESS_DENIEDThe caller is not a member of this project. Classification is a project data surface: an organization-level role alone does not grant access.
413K9O_RAMPART_INPUT_TOO_LONGThe input needs more than 16 windows of 512 tokens (about 6,000 tokens), or the classifier refused it as too long (reason rampart_input_too_long). No classification is made; send a shorter input.
503K9O_RAMPART_CLASSIFIER_UNAVAILABLEThe Rampart classifier could not be reached or returned an unusable result. The request fails closed and never returns an invented classification; retry later.
Response body (200)
data *object

The classifier's verdict on the content, with its signed receipt.

classification *"clear" | "suspicious" | "malicious"

The verdict on the riskiest window.

It is advisory: Rampart blocks nothing, and your code decides what to do with the content.

riskScore *integer

The likelihood that the content is a prompt injection, in basis points (0 to 10000, where 10000 is certain).

confidence *integer

How sure the classifier is of the verdict it gave, in basis points (0 to 10000).

categories *string[]

Labels for the kind of risk found.

The current classifier only distinguishes injection from safe, so this is empty.

calibrationVersion *string

The version of the score thresholds that produced the verdict.

It is signed into the receipt.

projectId *string

The project the receipt is bound to (proj_...).

Verifying the receipt compares this with its signed claim.

classificationReceipt *string

A signed record of this verdict: a compact EdDSA JWS with typ k9o.rampart.classify.v1.

It carries the SHA-256 of the canonical input, the verdict, the scores, the project, the calibration version and how many windows were scored.

Verify it against the keys at GET /rampart/jwks.

It is a record, not an authorization.

meta *any
TypeScript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.rampart.classify({})

Showing example in TypeScript

Request example
{
  "label": "string"
}
Response example (200)
{
  "data": {
    "classification": "clear",
    "riskScore": 0,
    "confidence": 0,
    "categories": [
      "string"
    ],
    "calibrationVersion": "string",
    "projectId": "string",
    "classificationReceipt": "string"
  }
}

More in AI Safety