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.

engine
object

Must be active in the registry. May be omitted only when the namespace has a default_engine.

horizon
string
default:0s

How far before observed_at an outcome's prediction was made, such as 30d for "churned 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. Part of the definition, so changing it creates a version.

thresholds
object

Each threshold is true when p is at least the value.

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[]

Composite judgments only: aggregates over related documents that the combiner takes as numeric inputs beside the parts. Each names an aggregate the recipe's related declares. Features are scaled automatically beside the parts; a missing value counts as typical. Features add no questions, so they are never billed.

Required array length: 1 - 8 elements

An aggregate the recipe declares, as <relation>.count or <relation>.<sum|min|max|latest>(<path>), such as tickets.count or invoices.sum(state.amount).

Pattern: ^[A-Za-z0-9_-]+\.(count|(sum|min|max|latest)\((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
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. 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.