# SettlementRunOutcomesDto

A model the API reference uses in a request or a response. The operation pages link every field typed as this model here.

Result payload for `GetRecentSettlementOutcomesAsync`: the
terminal (non-Pending) settlement batches for a merchant inside a recent window.

## Fields
- `merchantId` (string(uuid)): The merchant the outcomes belong to.
- `queriedAtUtc` (string(date-time)): The instant the lookback window was measured back from, taken once before the read.
- `windowStartUtc` (string(date-time)): The start of the window: `QueriedAtUtc` minus the applied lookback. Every item's  `CompletedAtUtc` is at or after this instant.
- `items` (array<[SettlementRunOutcomeDto](https://devportal.demo.winkpg.io/docs/api/models/SettlementRunOutcomeDto.md)>): Terminal outcomes that completed inside the window, newest `CompletedAtUtc` first. (nullable)
  Fields of each item:
  - `settlementBatchId` (string(uuid)): The settlement batch document id, for linking to batch detail.
  - `runId` (string(uuid)): The settlement run this batch belonged to.
  - `processorKey` (string): Lower-cased processor key the batch was produced for. Null for legacy rows and for synthetic  rows written before a processor could be resolved. (nullable)
  - `openBatchId` (string): The gateway batch id this run settled. Null when the run failed before one existed. (nullable)
  - `status` ([SettlementBatchStatus](https://devportal.demo.winkpg.io/docs/api/models/SettlementBatchStatus.md)): The batch's terminal status. Never `Pending`.
    Values:
    - `Pending`: Batch created, awaiting processor submission.
    - `Completed`: Batch successfully settled with the processor.
    - `Failed`: Batch settlement failed.
    - `PartiallyCompleted`: Some transactions settled, others rejected by the processor.
    - `NothingToSettle`: No transactions were eligible to settle for this (merchant, processor) group. A successful no-op outcome, distinct from Failed (a genuine fault) and from Completed (a real settle). Recorded so a settlement run leaves a history row for every targeted (merchant, processor) even when zero transactions are loaded. The short explanation is carried in SettlementBatch.ErrorMessage as the per-batch outcome detail.
    - `OperatorActionRequired`: The batch could not be settled automatically and is parked for operator action. Distinct from Failed: a Failed closed batch is re-attempted on the next run (transient fault), whereas an OperatorActionRequired batch is deliberately excluded from automatic retry because blindly re-submitting it would just re-fail. Two causes park a batch here: a non-transient duplicate-batch-number processor rejection (the same processor BatchNumber will keep colliding until an operator bumps it), and exhaustion of SettlementConsts.MaxSettlementRetries transient retries. The batch's transactions are moved to SettlementStatus.SettlementOnHold so they stop auto-retrying; the reason is carried in SettlementBatch.ErrorMessage. The operator UI (follow-up story) lists these and can retry with a bumped processor BatchNumber.
    - `TerminalContention`: The batch was not submitted because a concurrent settlement run already held the terminal lock for the same (Fiserv MerchID, TermID) pair (UMF Appendix M 42.1: only one batch at a time per terminal). Distinct from Failed: nothing went wrong, this run simply deferred to the run that already owned the terminal. The next scheduled run retries normally.
  - `errorMessage` (string): The persisted operator-facing reason (`SettlementBatch.ErrorMessage`). Already sanitized  at write time: raw exception text stays in the structured logs. (nullable)
  - `completedAtUtc` (string(date-time)): When the batch reached its terminal state, falling back to its creation time when the batch has  no recorded completion time. The lookback window and the newest-first order both use this value.
  - `triggerType` ([SettlementTriggerType](https://devportal.demo.winkpg.io/docs/api/models/SettlementTriggerType.md)): (nullable)
    Values:
    - `Auto`
    - `Manual`
  - `correlationId` (string(uuid)): (nullable)
  - `instanceId` (string): (nullable)

## See also

- [All documentation](https://devportal.demo.winkpg.io/llms.txt): the machine-readable index of every public page on this site.
