Decisions and receipts
A ranked list leaves the hardest question to you: is the first result the answer? Every geocode answer carries adecision that says what to do with it, and, when you ask, a receipt to keep beside the result you store.
The three actions
decision.action | Means | Do |
|---|---|---|
act | The top result stands clear of the runner-up, nothing tied it, and no missing field would change it. | Use the first result. |
ask | The top result is clear, but a field the caller did not send would raise confidence. ask_for names it. | Ask for that field and geocode again, or use the result and flag it. |
refuse | The top candidates are within scoring noise of each other, or several tied exactly. | Show the choices, or add context and ask again. Do not pick the first. |
It is computed over every candidate the search kept, before the list is cut to limit, so it does not change with limit. An empty answer is ask, with locality inask_for when there was no context.
How it is reached
- Ties. If
tied_at_topis more than 1, the action isrefuse, anddisambiguationlists up to eight of the tied options with a label, country and locality for each. - Margin. Otherwise the top two results are scored on a blend of calibrated confidence (70%), the reranker (20%) and prominence (10%). If the top leads by less than 0.12, the action is
refuse.marginis that lead, so you can see how close it was. - Missing fields. Otherwise, if the top result would be helped by more input, the action is
ask:postcodefor an address answered on city context alone,house_numberfor a street match with no number,localitywhen no context was sent and the top result names no locality,countrywhen the candidates span more than one. - Otherwise
act.
Refuse: two good answers
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1
{
"query": "Museo Soumaya",
"name": "Museo Soumaya",
"context": null,
"parse": {
"name": "Museo Soumaya",
"method": "passthrough"
},
"context_resolution": null,
"near": null,
"results": [
{
"doc": 348329,
"name": "Museo Soumaya",
"lat": 19.44062110346353,
"lon": -99.20465953606559,
"bbox": [
19.440487037931074,
19.440755168997644,
-99.20478863854248,
-99.20453043361198
],
"precision": "poi",
"precision_m": 6.756173533775122,
"hierarchy": {
"locality": "Miguel Hidalgo",
"region": "CMX",
"country": "MX",
"category": "museum",
"postcode": null,
"street": null
},
"normalized": {
"locality": "Miguel Hidalgo",
"region": "CMX",
"country": "MX",
"formatted": "Museo Soumaya, Miguel Hidalgo, CMX, MX"
},
"components": {
"name": "exact",
"house_number": "missing",
"street": "missing",
"locality": "missing",
"region": "missing",
"postcode": "missing",
"country": "missing"
},
"confidence": 0.5,
"why": {
"tokens": [
"museo",
"soumaya"
],
"matched": 2,
"extra": 0,
"mode": "all",
"tied": false,
"prominence": 5,
"rerank": 87
},
"provenance": {
"name": "overture-places",
"release": "2026-08-19.0",
"license": "CDLA-Permissive-2.0"
},
"attributes": {
"rating": null,
"reviews": 0,
"price": null,
"hours": [
[
0,
0
],
[
0,
0
],
[
0,
0
],
[
0,
0
],
[
0,
0
],
[
0,
0
],
[
0,
0
]
],
"photo": "https://commons.wikimedia.org/wiki/Special:FilePath/Museo_Soumaya%2C_Ciudad_de_M%C3%A9xico%2C_M%C3%A9xico%2C_2015-07-18%2C_DD_12.JPG",
"provenance": {
"name": "wikidata",
"release": "2026-11-23",
"license": "CC0; images under their Commons licences"
}
}
},
{
"doc": 318314,
"name": "Museo Soumaya",
"lat": 19.33886538628843,
"lon": -99.19254435060174,
"bbox": [
19.338731342470982,
19.33899943010779,
-99.19267344656319,
-99.19241525466357
],
"precision": "poi",
"precision_m": 6.756173533775122,
"hierarchy": {
"locality": "Álvaro Obregón",
"region": "CMX",
"country": "MX",
"category": "museum",
"postcode": null,
"street": null
},
"normalized": {
"locality": "Álvaro Obregón",
"region": "CMX",
"country": "MX",
"formatted": "Museo Soumaya, Álvaro Obregón, CMX, MX"
},
"components": {
"name": "exact",
"house_number": "missing",
"street": "missing",
"locality": "missing",
"region": "missing",
"postcode": "missing",
"country": "missing"
},
"confidence": 0.5,
"why": {
"tokens": [
"museo",
"soumaya"
],
"matched": 2,
"extra": 0,
"mode": "all",
"tied": false,
"prominence": 0,
"rerank": 85
},
"provenance": {
"name": "overture-places",
"release": "2026-08-19.0",
"license": "CDLA-Permissive-2.0"
},
"attributes": null
},
{
"doc": 385507,
"name": "Museo Soumaya - Auguste Rondin",
"lat": 19.53106621771892,
"lon": -99.23296424906052,
"bbox": [
19.530932130179863,
19.531200305259414,
-99.23309336673412,
-99.23283513141011
],
"precision": "poi",
"precision_m": 6.756173533775122,
"hierarchy": {
"locality": "Tlalnepantla de Baz",
"region": null,
"country": "MX",
"category": "museum",
"postcode": null,
"street": null
},
"normalized": {
"locality": "Tlalnepantla de Baz",
"country": "MX",
"formatted": "Museo Soumaya - Auguste Rondin, Tlalnepantla de Baz, MX"
},
"components": {
"name": "exact",
"house_number": "missing",
"street": "missing",
"locality": "missing",
"region": "missing",
"postcode": "missing",
"country": "missing"
},
"confidence": 0.5,
"why": {
"tokens": [
"museo",
"soumaya"
],
"matched": 2,
"extra": 2,
"mode": "all",
"tied": false,
"prominence": 0,
"rerank": 55
},
"provenance": {
"name": "overture-places",
"release": "2026-08-19.0",
"license": "CDLA-Permissive-2.0"
},
"attributes": null
}
],
"mode": "all",
"tied_at_top": 1,
"tie_probe": 32,
"interpolated": false,
"decision": {
"action": "refuse",
"margin": 0.03733337
},
"epoch": 30,
"release": "2026-08-19.0",
"examined": 420,
"postings": 424,
"segments": 2,
"store_requests": 0,
"store_bytes": 0,
"took_us": 12238
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Nothing tied, but there are two Museo Soumaya buildings and both match the name exactly. The margin is about 0.04, under 0.12, so the answer is refuse. A user who typed this wants to be asked which one.
Refuse: many equal answers
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1
{
"query": "OXXO",
"name": "OXXO",
"context": null,
"parse": {
"name": "OXXO",
"method": "passthrough"
},
"context_resolution": null,
"near": null,
"results": [
{
"doc": 19524,
"name": "OXXO",
"lat": 20.612046892212046,
"lon": -105.23387968256127,
"bbox": [
20.611911606339586,
20.612182178088325,
-105.23401122598554,
-105.2337481391495
],
"precision": "poi",
"precision_m": 6.756173533775122,
"hierarchy": {
"locality": "Puerto Vallarta",
"region": null,
"country": "MX",
"category": "convenience_store",
"postcode": null,
"street": null
},
"normalized": {
"locality": "Puerto Vallarta",
"country": "MX",
"formatted": "OXXO, Puerto Vallarta, MX"
},
"components": {
"name": "exact",
"house_number": "missing",
"street": "missing",
"locality": "missing",
"region": "missing",
"postcode": "missing",
"country": "missing"
},
"confidence": 0.99148935,
"why": {
"tokens": [
"oxxo"
],
"matched": 1,
"extra": 0,
"mode": "all",
"tied": true,
"prominence": 0,
"rerank": 75
},
"provenance": {
"name": "overture-places",
"release": "2026-08-19.0",
"license": "CDLA-Permissive-2.0"
},
"attributes": null
},
{
"doc": 20122,
"name": "OXXO",
"lat": 20.610405973859322,
"lon": -105.23397110804532,
"bbox": [
20.61027068832683,
20.610541259395642,
-105.23410265149454,
-105.23383956460859
],
"precision": "poi",
"precision_m": 6.756173533775122,
"hierarchy": {
"locality": "Puerto Vallarta",
"region": null,
"country": "MX",
"category": "convenience_store",
"postcode": null,
"street": null
},
"normalized": {
"locality": "Puerto Vallarta",
"country": "MX",
"formatted": "OXXO, Puerto Vallarta, MX"
},
"components": {
"name": "exact",
"house_number": "missing",
"street": "missing",
"locality": "missing",
"region": "missing",
"postcode": "missing",
"country": "missing"
},
"confidence": 0.99148935,
"why": {
"tokens": [
"oxxo"
],
"matched": 1,
"extra": 0,
"mode": "all",
"tied": true,
"prominence": 0,
"rerank": 75
},
"provenance": {
"name": "overture-places",
"release": "2026-08-19.0",
"license": "CDLA-Permissive-2.0"
},
"attributes": null
},
{
"doc": 20812,
"name": "OXXO",
"lat": 20.62072596660037,
"lon": -105.22510306857126,
"bbox": [
20.620590680172317,
20.620861253032217,
-105.2252346095983,
-105.22497152755672
],
"precision": "poi",
"precision_m": 6.756173533775122,
"hierarchy": {
"locality": "Puerto Vallarta",
"region": null,
"country": "MX",
"category": "convenience_store",
"postcode": null,
"street": null
},
"normalized": {
"locality": "Puerto Vallarta",
"country": "MX",
"formatted": "OXXO, Puerto Vallarta, MX"
},
"components": {
"name": "exact",
"house_number": "missing",
"street": "missing",
"locality": "missing",
"region": "missing",
"postcode": "missing",
"country": "missing"
},
"confidence": 0.99148935,
"why": {
"tokens": [
"oxxo"
],
"matched": 1,
"extra": 0,
"mode": "all",
"tied": true,
"prominence": 0,
"rerank": 75
},
"provenance": {
"name": "overture-places",
"release": "2026-08-19.0",
"license": "CDLA-Permissive-2.0"
},
"attributes": null
}
],
"mode": "all",
"tied_at_top": 16,
"tie_probe": 32,
"interpolated": false,
"decision": {
"action": "refuse",
"margin": 0,
"disambiguation": {
"tied": 16,
"options": [
{
"rank": 1,
"label": "OXXO, Puerto Vallarta, MX",
"country": "MX",
"locality": "Puerto Vallarta"
},
{
"rank": 2,
"label": "OXXO, Puerto Vallarta, MX",
"country": "MX",
"locality": "Puerto Vallarta"
},
{
"rank": 3,
"label": "OXXO, Puerto Vallarta, MX",
"country": "MX",
"locality": "Puerto Vallarta"
},
{
"rank": 4,
"label": "OXXO, Puerto Vallarta, JAL, MX",
"country": "MX",
"locality": "Puerto Vallarta"
},
{
"rank": 5,
"label": "OXXO, Puerto Vallarta, MX",
"country": "MX",
"locality": "Puerto Vallarta"
},
{
"rank": 6,
"label": "Oxxo, Boca de Tomatlán, JAL, MX",
"country": "MX",
"locality": "Boca de Tomatlán"
},
{
"rank": 7,
"label": "oxxo, Pérula, JAL, MX",
"country": "MX",
"locality": "Pérula"
},
{
"rank": 8,
"label": "OXXO, Tomatlán, MX",
"country": "MX",
"locality": "Tomatlán"
}
]
}
},
"epoch": 30,
"release": "2026-08-19.0",
"examined": 98,
"postings": 1736,
"segments": 2,
"store_requests": 0,
"store_bytes": 0,
"took_us": 805
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Sixteen OXXO shops share the top score. disambiguation.options is the list to show; adding a city or anear point is the way to narrow it.
Act
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1
{
"query": "Avenida Insurgentes Sur 1602, 03940",
"name": "Avenida Insurgentes Sur 1602",
"context": "03940",
"parse": {
"name": "Avenida Insurgentes Sur 1602",
"context": "03940",
"house_number": "1602",
"street": "Avenida Insurgentes Sur",
"postcode": "03940",
"method": "comma_parts"
},
"context_resolution": {
"terms": [
"03940"
],
"divisions": [],
"known": true,
"fallback": false
},
"near": null,
"results": [
{
"doc": 1645192,
"name": "AVENIDA INSURGENTES SUR 1602",
"lat": 19.364069672979937,
"lon": -99.18198831998704,
"bbox": [
19.3639356260916,
19.36420371987013,
-99.18211741026626,
-99.18185922973113
],
"precision": "rooftop",
"precision_m": 6.756173533775122,
"hierarchy": {
"locality": "Ciudad de México",
"region": null,
"country": "MX",
"category": null,
"postcode": "03940",
"street": "AVENIDA INSURGENTES SUR"
},
"normalized": {
"house_number": "1602",
"street": "AVENIDA INSURGENTES SUR",
"locality": "Ciudad de México",
"postcode": "03940",
"country": "MX",
"formatted": "AVENIDA INSURGENTES SUR 1602, Ciudad de México, 03940, MX"
},
"components": {
"name": "exact",
"house_number": "exact",
"street": "exact",
"locality": "exact",
"region": "missing",
"postcode": "exact",
"country": "missing"
},
"confidence": 0.72772276,
"why": {
"tokens": [
"1602",
"avenida",
"insurgentes",
"sur"
],
"matched": 4,
"extra": 0,
"mode": "all",
"tied": false,
"prominence": 0,
"rerank": 100
},
"provenance": {
"name": "overture-addresses",
"release": "2026-08-19.0",
"license": "permissive (per-source, see record)"
},
"attributes": null
}
],
"mode": "all",
"tied_at_top": 1,
"tie_probe": 16,
"interpolated": false,
"decision": {
"action": "act",
"margin": 0.18940592
},
"epoch": 30,
"release": "2026-08-19.0",
"examined": 1612,
"postings": 3471,
"segments": 2,
"store_requests": 0,
"store_bytes": 0,
"took_us": 15244
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
A house number and a postcode, one rooftop match, and a margin of 0.19: act.
Branching on it
from oslew import Client
client = Client(base_url="https://api.oslew.com")
answer = client.geocode("Museo Soumaya", limit=5)
decision = answer["decision"]
if decision["action"] == "act":
place = answer["results"][0]
elif decision["action"] == "ask":
missing = decision.get("ask_for", []) # e.g. ["postcode"]
... # ask for those, then geocode again
else: # refuse
options = (decision.get("disambiguation") or {}).get("options") or answer["results"]
... # show them; never pick the first silentlyimport { Client } from "@oslew/client";
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.geocode("Museo Soumaya", { limit: 5 });
const { action, ask_for, disambiguation } = answer.decision;
if (action === "act") {
const place = answer.results[0];
} else if (action === "ask") {
// ask_for, e.g. ["postcode"]: ask for those, then geocode again
} else {
// refuse: show disambiguation?.options ?? answer.results; never pick the first silently
}Receipts
Pass receipt=true and the answer carries a receipt: which store epoch and data release answered, and a SHA-256 of the facts you are most likely to store. Keep it beside the stored result. Later, it shows which release a row came from, and that the row still says what the service said.
curl -G "https://api.oslew.com/v1/geocode" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'q=Avenida Insurgentes Sur 1602, 03940' \
--data-urlencode 'limit=1' \
--data-urlencode 'receipt=true'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.geocode("Avenida Insurgentes Sur 1602, 03940", receipt=True, limit=1)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.geocode("Avenida Insurgentes Sur 1602, 03940", { receipt: true, limit: 1 });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1
{
"query": "Avenida Insurgentes Sur 1602, 03940",
"name": "Avenida Insurgentes Sur 1602",
"context": "03940",
"parse": {
"name": "Avenida Insurgentes Sur 1602",
"context": "03940",
"house_number": "1602",
"street": "Avenida Insurgentes Sur",
"postcode": "03940",
"method": "comma_parts"
},
"context_resolution": {
"terms": [
"03940"
],
"divisions": [],
"known": true,
"fallback": false
},
"near": null,
"results": [
{
"doc": 1645192,
"name": "AVENIDA INSURGENTES SUR 1602",
"lat": 19.364069672979937,
"lon": -99.18198831998704,
"bbox": [
19.3639356260916,
19.36420371987013,
-99.18211741026626,
-99.18185922973113
],
"precision": "rooftop",
"precision_m": 6.756173533775122,
"hierarchy": {
"locality": "Ciudad de México",
"region": null,
"country": "MX",
"category": null,
"postcode": "03940",
"street": "AVENIDA INSURGENTES SUR"
},
"normalized": {
"house_number": "1602",
"street": "AVENIDA INSURGENTES SUR",
"locality": "Ciudad de México",
"postcode": "03940",
"country": "MX",
"formatted": "AVENIDA INSURGENTES SUR 1602, Ciudad de México, 03940, MX"
},
"components": {
"name": "exact",
"house_number": "exact",
"street": "exact",
"locality": "exact",
"region": "missing",
"postcode": "exact",
"country": "missing"
},
"confidence": 0.72772276,
"why": {
"tokens": [
"1602",
"avenida",
"insurgentes",
"sur"
],
"matched": 4,
"extra": 0,
"mode": "all",
"tied": false,
"prominence": 0,
"rerank": 100
},
"provenance": {
"name": "overture-addresses",
"release": "2026-08-19.0",
"license": "permissive (per-source, see record)"
},
"attributes": null
}
],
"mode": "all",
"tied_at_top": 1,
"tie_probe": 16,
"interpolated": false,
"decision": {
"action": "act",
"margin": 0.18940592
},
"epoch": 30,
"release": "2026-08-19.0",
"receipt": {
"epoch": 30,
"release": "2026-08-19.0",
"payload_sha256": "63cad92f9f779ca88f60c1d8643f755a86c7ab7f2e06a99db919ea341195f084",
"alg": "sha256"
},
"examined": 1612,
"postings": 3471,
"segments": 2,
"store_requests": 0,
"store_bytes": 0,
"took_us": 14849
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
| Field | Is |
|---|---|
epoch, release | The store that answered. The same two fields are on every geocode and validate answer. |
payload_sha256 | SHA-256 of a canonical JSON object, below. |
alg | sha256, or sha256-keyed when the operator also signed it. |
signature | Present only when the operator sets a receipt secret: SHA-256 of the secret, a zero byte and the payload. Only the operator can check it. |
For a geocode, the payload is the query, the epoch and release, and the top result's position, confidence and licence, as compact JSON with the keys sorted. You can recompute it from the answer. The one subtlety isconfidence, which the service holds as a 32-bit float and widens before hashing, so widen it the same way:
import hashlib, json, struct
def geocode_payload_sha256(answer: dict) -> str:
top = answer["results"][0]
confidence = struct.unpack("f", struct.pack("f", top["confidence"]))[0] # as the service widened it
payload = {
"q": answer["query"],
"epoch": answer["epoch"],
"release": answer["release"],
"lat": top["lat"],
"lon": top["lon"],
"confidence": confidence,
"license": top["provenance"]["license"],
}
text = json.dumps(payload, sort_keys=True, separators=(",", ":"), ensure_ascii=False)
return hashlib.sha256(text.encode()).hexdigest()
assert geocode_payload_sha256(answer) == answer["receipt"]["payload_sha256"]Committing an address a user accepted
POST /v1/validate/commit is validation that always carries a receipt. Call it at the moment a user accepts an address in a form, and store its receipt with the address. Its payload is the verdict, the formatted address, the position, the epoch and the release, so the stored row and the receipt can be checked against each other in the same way.
curl -X POST "https://api.oslew.com/v1/validate/commit" \
-H "Authorization: Bearer $GEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Avenida Insurgentes Sur 1602, Crédito Constructor, 03940 Ciudad de México","selected_rank":1}'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.validate_commit(
{
"text": "Avenida Insurgentes Sur 1602, Crédito Constructor, 03940 Ciudad de México",
"selected_rank": 1,
},
)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.validate_commit({
text: "Avenida Insurgentes Sur 1602, Crédito Constructor, 03940 Ciudad de México",
selected_rank: 1,
});HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 293
ratelimit-reset: 1
{
"verdict": "partial",
"formatted": "1602 AVENIDA INSURGENTES SUR, Ciudad de México, 03940, MX",
"components": [
{
"name": "house_number",
"input": "1602",
"matched": "1602",
"quality": "exact"
},
{
"name": "street",
"input": "Avenida Insurgentes Sur",
"matched": "AVENIDA INSURGENTES SUR",
"quality": "exact"
},
{
"name": "locality",
"input": "Crédito Constructor",
"matched": "Ciudad de México",
"quality": "partial"
},
{
"name": "region",
"input": null,
"matched": null,
"quality": "missing"
},
{
"name": "postcode",
"input": "03940 Ciudad de México",
"matched": "03940",
"quality": "partial"
},
{
"name": "country",
"input": null,
"matched": "MX",
"quality": "missing"
}
],
"lat": 19.364069672979937,
"lon": -99.18198831998704,
"precision": "rooftop",
"confidence": 0.25609756,
"candidates": 25,
"why": "matched AVENIDA INSURGENTES SUR 1602 (an address point) among 25 candidates; locality \"Crédito Constructor\" contradicts the match (\"Ciudad de México\"); postcode \"03940 Ciudad de México\" contradicts the match (\"03940\"); country inferred as \"MX\"",
"epoch": 30,
"release": "2026-08-19.0",
"receipt": {
"epoch": 30,
"release": "2026-08-19.0",
"payload_sha256": "5ad2ed3344fa7133d5380a3fff17f9484b02087567b655d76982055291abda55",
"alg": "sha256"
},
"took_us": 2084
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Send selected_rank, the position in your list of suggestions that the user chose, and the choice is also recorded as feedback where the deployment keeps a query log. The fields are the same as validation's.
Pinning a release
release on a geocode makes the service refuse with 400 rather than answer from a different data release, for a pipeline that must not mix two. epoch asks for an earlier store epoch, which a deployment answers only if it keeps them. See conventions.
Endpoints
/v1/validate/commitaddressValidate an address, seal a receipt, and optionally record the accepted correction as feedback for traffic learning.