Skip to main content
POST
Create a judgment, or a new version of an existing name

Authorizations

Authorization
string
header
required

An organization API key. Keys carry a role (read_write or read_only) and may be restricted to a namespace prefix such as acme/*, or to one namespace such as acme/prod/tenant_1. A prefix matches on a / boundary: acme/prod/tenant_1* covers acme/prod/tenant_1 and everything under acme/prod/tenant_1/, never acme/prod/tenant_12.

Headers

Idempotency-Key
string

One key per logical request, reused only on its retries. A key belongs to one request: within your organization, the same method, path, query and body. For 24 hours after a successful response, a request with the key and the same body gets that response back verbatim, with Idempotent-Replayed: true, and runs nothing. Only a successful response is kept, so the retry of a request that failed runs again. While the first request runs or its response is kept, the key with a different request is idempotency_key_reused (422). A request sent while one with its key is still running is rate_limited with Retry-After: 1, without running: retry it to get the first one's response. In the rare case the key can't be checked, the request runs as if it had none.

Required string length: 1 - 255

Path Parameters

ns
string
required

A namespace name, or a template prefix ending in /*, with any / sent as %2F: acme%2Fprod%2Ftenant_123 or acme%2Fprod%2F*.

A namespace name, or a template prefix: a namespace path ending in /*, such as acme/prod/*, which every namespace under acme/prod/ inherits judgments from. Up to 256 bytes. Never exactly . or .., which a URL path can't carry.

Required string length: 1 - 256
Pattern: ^(?!\.\.?$)[A-Za-z0-9._:/-]+(/\*)?$

Body

application/json

A definition, or a starter filled with your paths.

name
string
required

A judgment, attribute or threshold name. Names are path segments in field references, so they never contain ..

Required string length: 1 - 128
Pattern: ^[A-Za-z0-9_-]+$
question
string
required
Minimum string length: 1
type
any
required
criteria
string
context
object

What the engine sees. A create without it is refused with a suggested recipe, unless use_context asks for the suggestion or the whole state; a version with no recipe sends the whole state, subject to the engine limit, and no images.

engine
object

Must be active in the registry. When omitted, Brussle fills it in: the namespace's default_engine, else the default model of your key for a provider Brussle serves when the namespace or your organization has one, else the included engine for the type. The created version records the result, and path says whether it runs on your key or on an included engine. Only an engine with limits.images reads the images the recipe selects.

horizon
string
default:0s

How long after an answer an outcome still labels it, such as 30d for "the invoice was paid within 30 days". Part of the definition, so changing it creates a version. Defaults to 0s, which joins labelled examples to current answers.

Pattern: ^(0|[1-9][0-9]*)[smhd]$
applies_to
object

The judgment judges, answers and bills only documents whose attributes match. A document that does not match has no answer for it: answers omits it. Without it, the judgment judges, answers and bills every document in the namespace, and the create response warns. Part of the definition, so changing it creates a version.

thresholds
object

Each threshold is true when p is at least the value, or, written {feature, gte} or {feature, lte}, when one of the judgment's features is at least or at most the number.

parts
object[]

Composite judgments only: 2 to 8 narrow yes/no questions with names unique within the judgment. They share the judgment's context recipe and engine, so they go in one engine request with its other questions, and each counts toward the 32 questions per request. question then documents what the combination means and is not sent to the engine. Parts are part of the version. They cannot reference other judgments. Each part is billed as a judgment. With features, one part is enough.

Required array length: 1 - 8 elements
features
string[]

Up to 12 numbers, on any bool judgment: aggregates over related documents the recipe's related declares, the judged document's own values, ages, and the engine's previous answer (see FeatureRef). Each is recorded as a raw number beside every answer under features, and on its evaluation, as of what that evaluation read, and never recomputed later. A threshold can name one, a query or subscription can filter on one, and the fit on your outcomes reads them beside the engine's answer. A composite judgment's combiner also takes them as numeric inputs beside the parts, scaled automatically, a missing value counting as typical. Features add no questions, so they are never billed: a change that moves only a feature records a new answer with no engine call. A judgment with relations created with features debounces for 10 minutes unless its freshness sets debounce_ms. Changing the list makes a new version.

Required array length: 1 - 12 elements

One number the judgment records beside every answer and its fit can read. It is one of:

  • An aggregate the recipe declares, as <relation>.count, <relation>.count_where, <relation>.labelled or <relation>.<sum|avg|min|max|latest>(<path>), such as tickets.count or invoices.sum(state.amount). A min or max over an answer's p or score gives the raw extreme, whatever band the context shows; a latest over an answer's threshold reads 1 or 0. A latest over an answer's value is not a number and is invalid_request. A sum or avg over an answer's number is a feature only. A latest over a bool outcome reads 1 or 0, over a score outcome its level; over a choice outcome it is invalid_request.
  • The judged document's own value, state.<path> or attributes.<name>: a number as itself, a boolean as 1 or 0, anything else missing. It needs no relation.
  • An age in fractional days, age(created_at), age(<state or attributes path>) or age(<relation>.<latest|min|max>(<path>)) over an aggregate the recipe declares. It is measured as of the judged document's own updated_at at the revision judged, so a write to a related document never moves it, and a new revision of the judged document does. The value must be an RFC 3339 string; a number or any other value reads missing, and a later time reads negative. age(updated_at) is invalid_request: as of the judged revision it is always 0.
  • previous.p: the engine's own p the last time it judged the document with the same engine version, in the same life of the document; on a choice, its 1 - escape_p. Missing on the first judgment, after the document is created again, after the engine version changes, and on a composite, which has none. On a score it is invalid_request.
  • On a choice among candidates (options.from) only, a number per candidate, <from>.each(<path>) over the options.from relation: each candidate's state.<path> or attributes.<name>, or age(created_at), age(updated_at) or age(<state or attributes path>) of the candidate, as of the judged document's revision. It is recorded for each candidate the engine read, under the answer's candidate_features. A candidate's answers are invalid_request: keep the number on the candidate's state.

A name the recipe declares as an aggregate always reads that aggregate. A feature that reads a path an outcome rule reads, one inside the other, is invalid_request.

Pattern: ^([A-Za-z0-9_-]+\.(count|count_where|labelled|(sum|avg|min|max|latest)\((state|attributes)(\.[^.()]+)+\)|(min|max|latest)\((created_at|updated_at)\)|(sum|avg|min|max)\(answers\.[A-Za-z0-9_-]+\.(p|score|dist\.[^()]+)\)|latest\(answers\.[A-Za-z0-9_-]+\.thresholds\.[A-Za-z0-9_-]+\)|latest\(outcomes\.[A-Za-z0-9_-]+\.value\))|(state|attributes)(\.[^.()]+)+|age\((created_at|(state|attributes)(\.[^.()]+)+|[A-Za-z0-9_-]+\.(latest|min|max)\((created_at|updated_at|(state|attributes)(\.[^.()]+)+)\))\)|previous\.p|[A-Za-z0-9_-]+\.each\(((state|attributes)(\.[^.()]+)+|age\((created_at|updated_at|(state|attributes)(\.[^.()]+)+)\))\))$
freshness
object

Settings, not part of the definition. Changing them creates no version.

activate
boolean

Activate this version on creation. In v1 this implies force. Refused for a composite judgment, which activation fits on your labels first.

confirm
boolean
default:false

Required to create a version with context.related on a judgment whose policy will be on_change. Without it, the response is the replay estimate of the monthly cost, and nothing is created; for a judgment that can fan out it also carries fanout, the rolling limit the confirm sets. Ignored for other judgments.

use_context
enum<string>

Instead of context: suggested creates with the recipe suggested from a sample of the namespace's documents, the one a create without context returns in details.suggested_context; whole_state sends the whole state, with a warning. Refused together with context.

Available options:
suggested,
whole_state
dry_run
boolean
default:false

Validate the body as a create would, and return the definition with its cost per answer and backfill estimate, creating nothing (CreateJudgmentDryRun).

Response

Nothing was created: a dry run (dry_run: true), or an entity judgment that needs confirm and was not confirmed, whose replay estimate this is.

What a create would make, and what it would cost. Nothing was created, written or billed.

dry_run
any
required
path
enum<string>
required

Whose account the version would run on, from the engine in definition.

Available options:
included,
customer_key
definition
object
required

The answer has p. With parts it is a composite judgment: the engine is asked each part instead of question, and p combines the parts' answers with weights fitted on the judgment's outcomes.

warnings
string[]
required
cost_per_answer
number | null
required

Mean judgments per answer over sampled_documents of the documents the definition applies to, each counted by its size class as a backfill estimate counts them: 1 when every answer is standard, 4 when every one is large, 2 for a standard composite of five parts with short questions (the first in full, each other a quarter). Null when there is nothing to sample, and on a template's prefix path.

Required range: x >= 0
sampled_documents
integer
required
Required range: x >= 0
estimate
object | null
required

What backfilling every document the definition applies to would cost once it exists. Creating never backfills by itself. Null on a template's prefix path.

replay
object | null
required

An entity judgment's monthly replay estimate, whatever its policy; null for others.

outcomes
object | null
required

For a starter with a suggested outcome setting, what the create would apply; null otherwise.