# ingestions.statement_matches

Suggest matches between a retained structured statement and current claims. Matches are review candidates, not proof of payment; no allocation or financial entry is created.

## What it does

Prepare read-only review candidates for complete retained structured statement JSON. Exact extraction text and statement_or_remittance classification are required. Source: {type:'statement',currency:ISO,decimals: integer 0–18,rows:[{id,date:YYYY-MM-DD,direction:'in'|'out',amountMinor:positive integer string,party:exact known name,reference?:exact economic sourceFactId}],totals:{in,out}:nonnegative integer strings}. Up to 500 rows / 64 KiB text, 2000 current-model claim components, 20 displayed candidates per row.

All rows and reconciled direction totals are returned; candidate counts/truncation are explicit. Matches are current priced-right commercial claims, with exact party/currency/scale/direction, no future origin date and original or outstanding amount. Reference narrows exact sourceFactId; a settled claim (zero outstanding) is a candidate only for a row whose reference names its sourceFactId, so an unreferenced duplicate payment reads unmatched. Unique candidates are matched suggestions, never confirmation of payment. Native amounts only; no fee/FX/net settlement or legacy claim interpretation.

Unsupported free text returns missing information. Requires whole source/context reads. Result is transient; no durable receipt, proposal/history or financial write, and no payment command.

## Before you send it

An authorized OAuth connection may call it, including a headless client. Effective membership, application grant and token permissions still apply. Describe `ingestions.statement_matches` through `GET /v1/catalog/commands/{name}` before acting.

This command does not accept `source_document_id` in its envelope. Any input evidence requirements remain as documented below.

## Inputs

Put these fields inside the envelope's `input` object. The outer envelope names the command, a stable `idempotency_key` and `effective_at`; [request and recovery rules](/docs/api/) explain those separately. Use exact minor-unit integer strings for monetary fields. Take existing IDs from prior reads or command results; choose a new identity only where the command asks for one.

Required means required within its containing object; an optional parent can be omitted.

| Field | Type | Required | Meaning and accepted values |
|---|---|---|---|
| `ingestionId` | string | Yes |   |
| `statementText` | string | Yes |   |

## After acceptance

When the command emits events, its documented effects and receipt are recorded in the command transaction. The response returns `commandId`, `replayed`, the command-specific `result` below and emitted `events` with their IDs and CIDs. A command is not automatically a cash movement or revenue recognition: use the behavior above to determine what this command records.

Inspect `result` and the affected records or reports before continuing. Save returned identifiers for later calls. Fetch `GET /v1/commands/{id}` with `commandId` to recover the accepted receipt; retry the same intent with the same idempotency key if the response was lost. Some commands can succeed with `events: []` and return a transient result and `commandId` without persisting a receipt. A lookup of that ID can return null; retain the returned result and verify the affected record. Retrying can re-evaluate the current state rather than replay a stored result. A domain `no_change` is a separate success outcome with no persisted receipt.

### Result fields

Required means required within its containing object; an optional parent can be omitted.

| Field | Type | Required | Meaning and accepted values |
|---|---|---|---|
| `disposition` | string | Yes |  Choose `"review"`, `"needs_information"`. |
| `missing` | array | Yes |  Items: string. |
| `source` | object | Yes |   |
| `source.documentId` | string | Yes |   |
| `source.cid` | string | Yes |   |
| `source.textCid` | string | Yes |   |
| `source.provenance` | string | Yes |  Choose `"registered_bytes"`, `"caller_supplied_unverified"`. |
| `currency` | string | No |   |
| `decimals` | integer | No |  Minimum: `0`. Maximum: `18`. |
| `totals` | object | No |   |
| `totals.in` | string | Yes |  Pattern: `"^(0\|[1-9][0-9]{0,18})$"`. |
| `totals.out` | string | Yes |  Pattern: `"^(0\|[1-9][0-9]{0,18})$"`. |
| `rows` | array | Yes |  Items: object. Maximum items: `500`. |
| `rows[].index` | integer | Yes |  Minimum: `0`. Maximum: `499`. |
| `rows[].sourcePointer` | string | Yes |   |
| `rows[].id` | string | Yes |   |
| `rows[].date` | string | Yes |  Format: date. |
| `rows[].direction` | string | Yes |  Choose `"in"`, `"out"`. |
| `rows[].amountMinor` | string | Yes |  Pattern: `"^(0\|[1-9][0-9]{0,18})$"`. |
| `rows[].party` | string | Yes |   |
| `rows[].reference` | string | No |   |
| `rows[].disposition` | string | Yes |  Choose `"matched"`, `"unmatched"`, `"ambiguous"`, `"needs_information"`. |
| `rows[].candidateCount` | integer or null | Yes |  Minimum: `0`. |
| `rows[].candidatesTruncated` | boolean | Yes |   |
| `rows[].candidates` | array | Yes |  Items: object. Maximum items: `20`. |
| `rows[].candidates[].claimId` | string | Yes |   |
| `rows[].candidates[].component` | object | Yes |   |
| `rows[].candidates[].component.originLedgerId` | string | Yes |   |
| `rows[].candidates[].component.accountCode` | integer | Yes |   |
| `rows[].candidates[].partyId` | string | Yes |   |
| `rows[].candidates[].original` | string | Yes |  Pattern: `"^(0\|[1-9][0-9]{0,18})$"`. |
| `rows[].candidates[].outstanding` | string | Yes |  Pattern: `"^(0\|[1-9][0-9]{0,18})$"`. |
| `rows[].candidates[].status` | string | Yes |  Choose `"open"`, `"settled"`, `"converted"`, `"cancelled"`. |
| `rows[].candidates[].sourceFactId` | string | Yes |   |


[All commands](/docs/command-reference/) · [Operation and errors](/docs/api-reference/operations/commands-execute/) · [Reusable schemas](/docs/api-reference/components/)

Keep credentials out of prompts; rehearse writes only in a disposable sandbox.

## Exact request schema


```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "const": "ingestions.statement_matches"
    },
    "input": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "ingestionId": {
          "type": "string"
        },
        "statementText": {
          "type": "string"
        }
      },
      "required": [
        "ingestionId",
        "statementText"
      ]
    },
    "idempotency_key": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "effective_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
    }
  },
  "required": [
    "name",
    "input",
    "idempotency_key",
    "effective_at"
  ],
  "additionalProperties": false
}
```

## Accepted command receipt


```json
{
  "type": "object",
  "required": [
    "commandId",
    "replayed",
    "result",
    "events"
  ],
  "properties": {
    "commandId": {
      "type": "string"
    },
    "replayed": {
      "type": "boolean"
    },
    "imported": {
      "const": true,
      "description": "The command's events are history from before the business joined Economico, recorded as an import: free of monthly events."
    },
    "result": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "disposition": {
          "enum": [
            "review",
            "needs_information"
          ]
        },
        "missing": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "source": {
          "type": "object",
          "properties": {
            "documentId": {
              "type": "string"
            },
            "cid": {
              "type": "string"
            },
            "textCid": {
              "type": "string"
            },
            "provenance": {
              "enum": [
                "registered_bytes",
                "caller_supplied_unverified"
              ]
            }
          },
          "required": [
            "documentId",
            "cid",
            "textCid",
            "provenance"
          ]
        },
        "currency": {
          "type": "string"
        },
        "decimals": {
          "type": "integer",
          "minimum": 0,
          "maximum": 18
        },
        "totals": {
          "type": "object",
          "properties": {
            "in": {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]{0,18})$"
            },
            "out": {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]{0,18})$"
            }
          },
          "required": [
            "in",
            "out"
          ]
        },
        "rows": {
          "type": "array",
          "maxItems": 500,
          "items": {
            "type": "object",
            "properties": {
              "index": {
                "type": "integer",
                "minimum": 0,
                "maximum": 499
              },
              "sourcePointer": {
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "date": {
                "type": "string",
                "format": "date"
              },
              "direction": {
                "enum": [
                  "in",
                  "out"
                ]
              },
              "amountMinor": {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]{0,18})$"
              },
              "party": {
                "type": "string"
              },
              "reference": {
                "type": "string"
              },
              "disposition": {
                "enum": [
                  "matched",
                  "unmatched",
                  "ambiguous",
                  "needs_information"
                ]
              },
              "candidateCount": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0
              },
              "candidatesTruncated": {
                "type": "boolean"
              },
              "candidates": {
                "type": "array",
                "maxItems": 20,
                "items": {
                  "type": "object",
                  "properties": {
                    "claimId": {
                      "type": "string"
                    },
                    "component": {
                      "type": "object",
                      "properties": {
                        "originLedgerId": {
                          "type": "string"
                        },
                        "accountCode": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "originLedgerId",
                        "accountCode"
                      ]
                    },
                    "partyId": {
                      "type": "string"
                    },
                    "original": {
                      "type": "string",
                      "pattern": "^(0|[1-9][0-9]{0,18})$"
                    },
                    "outstanding": {
                      "type": "string",
                      "pattern": "^(0|[1-9][0-9]{0,18})$"
                    },
                    "status": {
                      "enum": [
                        "open",
                        "settled",
                        "converted",
                        "cancelled"
                      ]
                    },
                    "sourceFactId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "claimId",
                    "component",
                    "partyId",
                    "original",
                    "outstanding",
                    "status",
                    "sourceFactId"
                  ]
                }
              }
            },
            "required": [
              "index",
              "sourcePointer",
              "id",
              "date",
              "direction",
              "amountMinor",
              "party",
              "disposition",
              "candidateCount",
              "candidatesTruncated",
              "candidates"
            ]
          }
        }
      },
      "required": [
        "disposition",
        "missing",
        "source",
        "rows"
      ]
    },
    "events": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "cid": {
            "type": "string"
          }
        }
      }
    }
  }
}
```


