Map free-text values onto a closed set of allowed values, or abstain

$0.005 USDC per call · Developer and security · POST /api/v1/enum-canonicalize · Id enum-canonicalize

Maps each input string onto one member of a closed caller-supplied set using, in order: exact match, caller aliases, a deterministic normal form (Unicode NFKC, case and accent folding, punctuation and underscore collapse), then bounded edit distance (optimal string alignment, so a swapped pair of letters costs 1). Returns the canonical value, the method, the distance and the nearest candidates; it abstains (null) when nothing is within the threshold or when two allowed values tie, and it never guesses. For agents cleaning status, country, category or unit fields before writing them to a typed column. It does not translate, use synonyms beyond your aliases, or infer meaning.

What you get

A closed-set normalizer with an abstain path. 200 values against 500 allowed entries per $0.005 call.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/enum-canonicalize. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/enum-canonicalize \
  -H 'content-type: application/json' \
  -d '{"values":["Unted States","usa","U.S. of America","Atlantis"],"allowed":["United States","Canada","Mexico"],"aliases":[{"alias":"usa","canonical":"United States"},{"alias":"u s of america","canonical":"United States"}]}'

Input

FieldTypeRequiredDescription
valuesarray<string; length 0..100>; max 200 itemsyesStrings to canonicalize.
allowedarray<string; length 0..100>; max 500 itemsyesThe closed set of canonical values.
aliasesarray<object>; max 500 itemsnoCaller synonyms; each canonical must be in allowed.
maxDistanceinteger; 0..5noLargest edit distance accepted (default 2). The effective limit is also capped at one third of the normalized input length.
caseSensitivebooleannoSkip case, accent and punctuation folding (only NFKC and whitespace collapse). Default false.

Example request body

{
  "values": [
    "Unted States",
    "usa",
    "U.S. of America",
    "Atlantis"
  ],
  "allowed": [
    "United States",
    "Canada",
    "Mexico"
  ],
  "aliases": [
    {
      "alias": "usa",
      "canonical": "United States"
    },
    {
      "alias": "u s of america",
      "canonical": "United States"
    }
  ]
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
resultsarray<object>no
allowedCollisionsarray<object>noAllowed values that share a normal form; inputs landing there are ambiguous.
countsobjectno
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the data-contract-kit package.

Machine-readable