Map free-text values onto a closed set of allowed values, or abstain
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
| Field | Type | Required | Description |
|---|---|---|---|
values | array<string; length 0..100>; max 200 items | yes | Strings to canonicalize. |
allowed | array<string; length 0..100>; max 500 items | yes | The closed set of canonical values. |
aliases | array<object>; max 500 items | no | Caller synonyms; each canonical must be in allowed. |
maxDistance | integer; 0..5 | no | Largest edit distance accepted (default 2). The effective limit is also capped at one third of the normalized input length. |
caseSensitive | boolean | no | Skip 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.
| Field | Type | Required | Description |
|---|---|---|---|
status | string; one of "pass", "fail", "unknown", "unsupported" | no | pass: 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. |
results | array<object> | no | |
allowedCollisions | array<object> | no | Allowed values that share a normal form; inputs landing there are ambiguous. |
counts | object | no | |
witnesses | array<object> | no | |
versions | object | no | Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile). |
limits | array<string> | no | |
deterministic | boolean | no | Always 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
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent