> ## Documentation Index
> Fetch the complete documentation index at: https://docs.finosu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Confirm ACH Settlements (Batch)

## Overview

This batch endpoint allows you to submit multiple ACH settlement confirmations from external loan management systems (LMS) in a single API request for improved efficiency.

Each confirmation in the batch is processed independently with detailed individual results, making it ideal for processing daily ACH settlement files from banks or bulk syncing from your LMS system.

## ID Mapping

The endpoint uses the same reference ID mapping as the [single ACH confirm endpoint](./create.mdx).

## Request Body Format

The batch endpoint accepts an array of ACH confirm records wrapped in a `confirms` field:

```json theme={null}
{
  "confirms": [
    {
      "customer_id": "CUST123",
      "loan_id": "LOAN456",
      "payment_id": "PMT789",
      "settlement_date": "2024-01-17T09:00:00Z"
    },
    {
      "customer_id": "CUST124",
      "loan_id": "LOAN457",
      "payment_id": "PMT790",
      "settlement_date": "2024-01-17T09:00:00Z"
    }
  ]
}
```

### Individual Confirm Schema

Each object in the `confirms` array follows the same schema as the [single ACH confirm endpoint](./create.mdx):

**Identifiers (Required):**

* `customer_id` - Customer reference ID from your LMS
* `loan_id` - Loan reference ID from your LMS
* `payment_id` - Payment reference ID from your LMS

**Settlement Fields:**

* `settlement_date` - Date the ACH payment settled

## Response Format

The batch endpoint returns detailed results for each ACH confirmation processed:

```json theme={null}
{
  "success": true,
  "total_processed": 2,
  "successful": 2,
  "failed": 0,
  "results": [
    {
      "success": true,
      "payment_id": "PMT789",
      "message": "ACH payment successfully confirmed as settled"
    },
    {
      "success": true,
      "payment_id": "PMT790",
      "message": "ACH payment successfully confirmed as settled"
    }
  ]
}
```

### Response Fields

* **success** - `true` if ALL confirmations were processed successfully, `false` if any failed
* **total\_processed** - Total number of confirmations in the batch
* **successful** - Number of successfully processed confirmations
* **failed** - Number of failed confirmations
* **results** - Array of individual results for each confirmation
  * **success** - Whether this specific confirmation was processed successfully
  * **payment\_id** - The payment ID from the request for easy matching
  * **message** - Success or error message for this specific confirmation

## Partial Success Handling

The batch endpoint uses **partial success** handling to ensure maximum processing:

* **Individual failures don't stop processing** - If one confirmation fails, the remaining confirmations are still processed
* **Detailed error messages** - Each failed confirmation includes its specific error message
* **Transaction isolation** - Each confirmation is processed in its own transaction to prevent one failure from affecting others
* **Overall success flag** - The top-level `success` field is `true` only if all confirmations succeeded

### Example: Partial Failure Response

```json theme={null}
{
  "success": false,
  "total_processed": 3,
  "successful": 2,
  "failed": 1,
  "results": [
    {
      "success": true,
      "payment_id": "PMT789",
      "message": "ACH payment successfully confirmed as settled"
    },
    {
      "success": false,
      "payment_id": "PMT790",
      "message": "404: Customer with reference_id 'CUST999' not found"
    },
    {
      "success": true,
      "payment_id": "PMT791",
      "message": "ACH payment successfully confirmed as settled"
    }
  ]
}
```

## What the Endpoint Does

For each ACH confirmation in the batch, Finosu:

1. **Locates the records** using the external reference IDs

2. **Updates AchPayment** with:
   * Status set to COMPLETED
   * Settlement date (if provided)

3. **Updates PaymentTransaction** with:
   * Status set to SUCCESSFUL

## When to Use Batch vs Single

**Use the batch endpoint when:**

* Processing daily ACH settlement files from your bank
* Syncing multiple confirmations from your LMS system
* You have more than 5-10 confirmations to submit
* You want to minimize API calls for efficiency

**Use the [single endpoint](./create.mdx) when:**

* Processing real-time individual confirmations
* You only have 1-2 confirmations to submit
* You need simpler error handling
* Testing or debugging individual confirmations

## Error Handling

The endpoint returns HTTP status 200 OK for all requests, with detailed success/failure information in the response body for each individual confirmation.

**Individual confirmation errors may include:**

* **400 BAD REQUEST** - ACH payment does not belong to specified loan
* **404 NOT FOUND** - Customer, loan, or payment not found with provided IDs
* **409 CONFLICT** - Multiple ACH payments found with the same processor transaction ID
* **500 INTERNAL SERVER ERROR** - Server error during processing

Check the `results` array in the response to see which confirmations succeeded and which failed.

## Authentication

Authentication via **X-API-Key header**:

* API key is company-scoped
* Must be obtained from Finosu
* Same authentication as single ACH confirm endpoint

## Example Usage

This endpoint is typically used for:

* **Daily bank reconciliation** - Process ACH settlement files from your bank
* **Bulk LMS sync** - Sync multiple settlement confirmations from your loan management system
* **Scheduled jobs** - Automated daily/weekly settlement confirmation workflows
