Back to website Open portal

Available

Compare line items

Match invoice line items against purchase order or goods receipt note line items asynchronously.

Updated 2026-09-07

POST https://app.docparser.dev/api/v1/comparison/compare

Persists a line-item comparison job, enqueues it, and returns 202 Accepted. The job matches each invoice row to a row of the counterpart document — a purchase order or a goods receipt note — and delivers the matched pairs, the unmatched rows on each side, and a summary. Matching is semantic: identifiers first (item and SKU codes, UPC, HSN/SAC), then descriptions and numeric fields, never on equal amounts alone.

Request

Field Type Required Description
consumerRefId non-empty string Yes Caller-supplied correlation reference, scoped to the organization during retrieval.
webhookUrl string No; defaults to "" Relative path joined to the API key’s registered base URL.
invoiceDocumentId string | integer Yes Your identifier for the invoice. Echoed as invoice_document_id.
comparisonDocumentId string | integer Yes Your identifier for the PO or GRN. Echoed as comparison_document_id.
typeId integer No; defaults to 1 1 compares against poLineItems (invoice_po); 2 compares against grnLineItems (invoice_grn).
invoiceLineItems object[] Yes; at least one Invoice rows, typically processed_data.lineItems from an invoice job.
poLineItems object[] When typeId is 1 Purchase order rows.
grnLineItems object[] When typeId is 2 Goods receipt note rows. Received quantities are compared, not expected ones.
tags object No Attribution labels, e.g. {"business": "acme-foods"}: up to 20 keys, values up to 256 characters. Echoed in the webhook as tags. See Tag requests.
json
{
"consumerRefId": "cmp-4471",
"webhookUrl": "/hooks/docparser",
"invoiceDocumentId": 4471,
"comparisonDocumentId": "PO-2201",
"typeId": 1,
"invoiceLineItems": [
  { "id": "inv-row-1", "description": "Thermal paper roll 80mm", "hsn_sac": "4811", "quantity": 120, "rate": 42.5, "amount": 5100 }
],
"poLineItems": [
  { "line_id": "po-row-7", "item_description": "Thermal paper 80 mm roll", "hsn_code": "4811", "quantity": 120, "unit_price": 42.5, "amount": 5100 }
]
}

Accepted response

json
{
"jobId": "5ca1ab1e-314d-4b2d-b9d6-8e68870b840f",
"consumerRefId": "cmp-4471",
"typeId": 1,
"status": "initiated"
}

Result shape

The delivered result depends on typeId. Each matched pair carries invoice_item and the counterpart item, a match_confidence from 0 to 100, a match_relationship (one-to-one, subset, or superset for a PO; one-to-one, partial-receipt, or over-receipt for a GRN), exact_matching_keys for same-name fields with equal values, and matching_fields for fields that match under different names. Copied rows keep only fields with a non-zero, non-empty value.

typeIdCounterpart request fieldPair keyUnmatched key
1poLineItemspo_itemunmatched_po_items
2grnLineItemsgrn_itemunmatched_grn_items

The full webhook payload is shown under Webhooks.

Retrieve

GET https://app.docparser.dev/api/v1/comparison/:consumerRefId

Returns the most recent persisted line_item_comparison_jobs row for the authenticated organization and consumer reference. result carries the comparison, extractionStats the token counts and model, and the webhook and error fields behave as they do for document jobs.

Errors

  • 400 — an empty invoiceLineItems array, a missing or empty counterpart array for the selected typeId, a row without an identifier, an absolute webhookUrl, or a typeId other than 1 or 2.
  • 401 and 403 — as for every public endpoint.
  • 404 with Line-item comparison job not found. — no organization-scoped job matched the reference.
  • 500 with Failed to create line-item comparison job. — the job could not be persisted.