Available
Map invoice items
Map the line items read off a supplier invoice onto your item master, with GRN, PO, previous-mapping and unit-of-measure evidence.
Updated 2026-10-14
POST https://app.docparser.dev/api/v1/json with "typeId": 101
Item mapping takes the lines read off a supplier invoice and answers, for each one, which item in your master it is. It weighs the evidence you send, strongest first: lines received on a GRN, how a person mapped this supplier’s lines before, the purchase order, the supplier’s own items, then the whole master. Each answer is one itemId from your candidates or none, with a confidence, the evidence behind it and up to three alternatives. When the invoice bills in a different unit from the PO or GRN (15 MT against 15,000 KG), the answer carries the conversion factor too.
Endpoints
Item mapping is typeId 101 on the JSON requests endpoint: one URL and one envelope for every request whose input is JSON. The envelope’s rules, errors and delivery are described there; this page documents the payload and the result.
| Method | Path | Answers |
|---|---|---|
POST | /api/v1/json | 202 with the job id; the result is POSTed to your webhook. |
POST | /api/v1/json/sync | 200 with the result in the body, no webhook. 502 with the error body if the engine fails. |
GET | /api/v1/json/101/:consumerRefId | The latest job for that reference, in the webhook’s shape. |
The dedicated routes /api/v1/item-mapping, /api/v1/item-mapping/sync and GET /api/v1/item-mapping/:consumerRefId take the same fields without the envelope (flat, at the top level) and return the same results.
A sync call is one model call, typically 10–40 seconds for tens of lines against a few hundred master items. Requests are cut at 100 seconds, so use the async endpoint for large payloads and batch jobs. Sending the same consumerRefId again replaces that job.
Request
The envelope carries the fields every request shares. Everything specific to item mapping goes inside payload.
| Field | Type | Required | Description |
|---|---|---|---|
consumerRefId | non-empty string | Yes | Your correlation reference, scoped to your organization. |
webhookUrl | string | No; defaults to "" | Relative path joined to the API key’s registered base URL. Not used by /sync. |
tags | object | No | Up to 20 attribution labels, echoed on the result. See Tag requests. |
typeId | integer | Yes | 101 for item mapping. |
payload | object | Yes | The item-mapping fields below. |
| Field | Type | Required | Description |
|---|---|---|---|
supplier | object | Yes | { identifier, name, gstin? }. |
invoice | object | No | { identifier?, number?, date?, currency?, poNumbers?, grnNumbers? }. |
detectedItems | object[] | Yes; 1–200 | The invoice lines: identifier (unique), name, description, hsn, unit, quantity, rate, amount. |
candidates.grnItems | object[] | No | GRN lines: identifier (unique), itemId, name, unit, quantity, rate, grnNumber, poItemIdentifier. |
candidates.poItems | object[] | No | PO lines: identifier (unique), itemId, name, unit, quantity, rate, poNumber. |
candidates.previousMappings | object[] | No | { invoiceItem: { identifier?, name, description, hsn, unit }, mappedTo: { itemId, name } } — how a person mapped this supplier’s lines before. |
candidates.supplierItems | object[] | No | Master items associated with this supplier: itemId, name, unit, hsn, supplierItemCode. |
candidates.masterItems | object[] | No; up to 2,000 | Your item master: itemId, name, description, unit, hsn, category. |
unitConversions | object[] | No | Per-item factors you already know: { itemId, fromUnit, toUnit, factor }, where quantity in toUnit = quantity in fromUnit × factor. |
options.minConfidence | number 0–1 | No; defaults to 0.6 | Below it a line is unmatched and the guess moves to alternatives. |
options.allowOneToMany | boolean | No; defaults to false | true lets several invoice lines claim one GRN or PO line. |
At least one candidate set must be non-empty. Every candidate row carries itemId, your master key, so every set is a slice of the same master. Identifiers may be strings or numbers and come back as strings. Numbers may be numeric strings such as "1,250.00". Extra keys on a candidate row, such as an item code or a SKU, are passed to the model as evidence.
hsn, unit, quantity and rate are optional but are the strongest evidence, so send them whenever you have them. Send each line’s unit exactly as printed on the invoice (MT, M.T., Kgs); it comes back unchanged.
{
"consumerRefId": "run-8812-1791895778488",
"webhookUrl": "/webhook/docparser/<token>/json",
"tags": { "business": "acme-foods" },
"typeId": 101,
"payload": {
"supplier": { "identifier": "SUP-0417", "name": "Shree Balaji Steels", "gstin": "29AAACS1234F1Z5" },
"invoice": { "number": "SBS/2026/889", "date": "2026-10-12", "currency": "INR", "poNumbers": ["PO-7781"], "grnNumbers": ["GRN-1"] },
"detectedItems": [
{ "identifier": "1", "name": "TMT BAR 12MM FE500D", "hsn": "7214", "unit": "MT", "quantity": 15, "rate": 52000, "amount": 780000 }
],
"candidates": {
"grnItems": [{ "identifier": "501", "itemId": "21", "name": "TMT Bar 12mm Fe500D", "unit": "KGS", "quantity": 15000, "rate": 52, "grnNumber": "GRN-1", "poItemIdentifier": "401" }],
"poItems": [{ "identifier": "401", "itemId": "21", "name": "TMT Bar 12mm Fe500D", "unit": "KGS", "quantity": 20000, "rate": 52, "poNumber": "PO-7781" }],
"masterItems": [{ "itemId": "21", "name": "TMT Bar 12mm Fe500D", "unit": "KGS", "hsn": "7214" }]
},
"unitConversions": [{ "itemId": "21", "fromUnit": "MTS", "toUnit": "KGS", "factor": 1000 }],
"options": { "minConfidence": 0.6, "allowOneToMany": false }
}
} Result
The webhook body, the sync response and the GET answer are the same.
{
"status": "processed",
"jobId": "2e68c6ae-d2d0-43d9-917c-12271653b3f6",
"consumerRefId": "run-8812-1791895778488",
"typeId": 101,
"supplierIdentifier": "SUP-0417",
"mappings": [
{
"detectedItemIdentifier": "1",
"status": "matched",
"itemId": "21",
"itemName": "TMT Bar 12mm Fe500D",
"confidence": 0.98,
"evidence": { "source": "grn", "lineIdentifier": "501", "reason": "Same HSN and grade as the GRN line; 15 MT is the 15,000 KG received." },
"alternatives": [],
"assumedUnitFactor": 1000,
"assumedFromUnit": "MT",
"assumedToUnit": "KGS",
"assumedFactorConfidence": 1,
"assumedFactorSource": "request"
}
],
"unconsumedGrnItems": [],
"lineMismatches": [],
"summary": { "total": 1, "matched": 1, "ambiguous": 0, "unmatched": 0, "nonItem": 0 },
"apiCost": { "input_tokens": 1890, "output_tokens": 410, "total_cost": 0.0048 },
"processingTimeMs": 12100,
"tags": { "business": "acme-foods" }
} status | itemId | Suggested handling |
|---|---|---|
matched | set | Map it. Optionally require your own confidence bar and evidence.source of grn or previous before posting without review. |
ambiguous | best guess | Pre-select it and show alternatives; a person confirms. |
unmatched | null | Show alternatives (may be empty) and a master search. |
non_item | null | A charge row (freight, packing, round-off) with no charge item in your master. Book it as a charge. |
evidence.source is the strongest set holding the chosen item, in the order grn, previous, po, supplier, master. evidence.lineIdentifier is the GRN or PO line the match consumed; each such line is consumed by at most one invoice line unless allowOneToMany is set. unconsumedGrnItems lists GRN lines no invoice line claimed. lineMismatches lists matched lines whose quantity or rate differs from the consumed GRN or PO line; quantities must agree exactly and rates within 0.5 %. When a person confirms or corrects a line, send it as a previousMappings row on that supplier’s next invoice.
An error result is { status: "error", jobId, consumerRefId, typeId, supplierIdentifier, error, errorCode }.
Units of measure
When an invoice line’s unit differs from the unit of the line or item it matched (the consumed GRN or PO line’s unit, otherwise the master item’s), the mapping carries a conversion factor: quantity in assumedToUnit = quantity in assumedFromUnit × assumedUnitFactor. assumedFromUnit is the invoice line’s unit and assumedToUnit the target’s, both exactly as you sent them. The four fields are absent when the units agree; two spellings of one unit (Kgs and KG, Nos and PCS) agree.
assumedFactorSource says where the factor came from, and the order is fixed:
| Source | When | Confidence |
|---|---|---|
request | A unitConversions row for that item matches the two units, in either direction. | 1 |
standard | Both units measure the same thing — mass (MT, quintal, KG, G, MG), length (KM, M, CM, MM), volume (KL, L, ML) or count (dozen, PCS) — so the factor is arithmetic. A different model answer is replaced. | 1 |
model | Units no arithmetic relates, such as BAG to KG or ROLL to MTR. | The model’s, capped at 0.6 unless the documents print the factor |
Unit names match regardless of case, dots and spacing, and common invoice spellings are recognised: MT, M.T., MTS, Tonne and Metric Tonne are one unit; so are KG, Kgs and Kilogram, and MTR, Meter and Metre.
With a factor, lineMismatches compares in the GRN or PO line’s unit: quantity × factor and rate ÷ factor. So 15 MT billed against a 15,000 KG line is not a mismatch, while 14 MT is reported as { "field": "quantity", "detected": 14000, "candidate": 15000, "unitFactor": 1000 }. Quantities in the result are never converted; keep the invoice’s own quantity and rate, and apply the factor where you post in PO units.
Errors
400 for a malformed body, with detail naming the first bad field at the path you sent it (payload.detectedItems: detectedItems cannot be empty). A typeId that isn’t a JSON type is a 400 listing the supported ones. 401 for missing or wrong credentials.