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

# Batches

The Reporting API provides two batch endpoints: one to retrieve a list of batches by date range, and one to fetch the transactions within a specific batch.

<Note>
  Both batch endpoints support pagination via `page` and `pageSize` parameters. The maximum `pageSize` is `1000`. Use the `totalCount` field in the response to determine how many pages to request. Date filtering is based on UTC time.
</Note>

## Authentication

All Reporting API requests require a **Reporting API key** passed in the request header.

```http theme={null} theme={null}
X-Api-Key: {{reporting_api_key}}
```

***

## List Batches

Fetch a list of batch IDs for a given date range.

```http theme={null} theme={null}
POST https://reporting.ecrypt.com/api/Batch
```

### Request

```http theme={null} theme={null}
POST /api/Batch HTTP/1.1
Host: reporting.ecrypt.com
X-Api-Key: {{reporting_api_key}}
Content-Type: application/json
```

```json theme={null} theme={null}
{
  "page": 1,
  "pageSize": 100,
  "sortOrder": "desc",
  "startDate": "2024-09-01T00:00:00",
  "endDate": "2024-09-30T23:59:59"
}
```

### Body Parameters

| Parameter   | Type    | Description                               |
| ----------- | ------- | ----------------------------------------- |
| `page`      | integer | Page number for pagination                |
| `pageSize`  | integer | Records per page. Maximum: `1000`         |
| `sortOrder` | string  | Sort direction: `asc` or `desc`           |
| `startDate` | string  | Start of date range. Format: `MM-DD-YYYY` |
| `endDate`   | string  | End of date range. Format: `MM-DD-YYYY`   |

<Warning>
  Date filtering is based on **UTC time**.
</Warning>

### Response

```json theme={null} theme={null}
{
  "batches": {
    "items": [
      {
        "id": 82382801,
        "closed": "2024-09-30T02:00:00",
        "status": "COMPLETED"
      }
    ],
    "page": 1,
    "pageSize": 1000,
    "totalCount": 1
  }
}
```

### Response Fields

| Field        | Description                                |
| ------------ | ------------------------------------------ |
| `id`         | Batch identifier                           |
| `closed`     | Timestamp the batch was closed (UTC)       |
| `status`     | Batch status (e.g., `COMPLETED`)           |
| `totalCount` | Total number of batches matching the query |

***

## Get Batch Detail

Fetch the transactions within a specific batch.

```http theme={null} theme={null}
POST https://reporting.ecrypt.com/api/BatchDetail
```

### Request

```http theme={null} theme={null}
POST /api/BatchDetail HTTP/1.1
Host: reporting.ecrypt.com
X-Api-Key: {{reporting_api_key}}
Content-Type: application/json
```

```json theme={null} theme={null}
{
  "id": 82382801,
  "page": 1,
  "pageSize": 1000,
  "sortOrder": "desc",
  "sortColumn": "Id"
}
```

### Body Parameters

| Parameter    | Type    | Description                       |
| ------------ | ------- | --------------------------------- |
| `id`         | integer | Batch ID to retrieve              |
| `page`       | integer | Page number for pagination        |
| `pageSize`   | integer | Records per page. Maximum: `1000` |
| `sortOrder`  | string  | Sort direction: `asc` or `desc`   |
| `sortColumn` | string  | Column to sort by (e.g., `Id`)    |

### Response

```json theme={null} theme={null}
{
  "id": 82382801,
  "transactions": {
    "items": [
      {
        "transactionId": 229764501,
        "type": "SALE",
        "tender": "CREDITCARD",
        "paymentName": "JJ TEST",
        "paymentNetwork": "VI",
        "paymentAccount": "4***********1111",
        "paymentAccountExpiry": "1025",
        "amount": 125.00,
        "authorizationAmount": 125.00,
        "capturedAmount": 125.00,
        "gratuityAmount": 0.00,
        "surchargeAmount": 0.00,
        "settlementAmount": 125.00,
        "approvalCode": "123456",
        "avsCode": "N",
        "cvvCode": "M",
        "status": "SETTLED",
        "created": "2024-09-29T17:16:24"
      },
      {
        "transactionId": 229743301,
        "type": "SALE",
        "tender": "CREDITCARD",
        "paymentName": "John Doe",
        "paymentNetwork": "VI",
        "paymentAccount": "4***********1111",
        "paymentAccountExpiry": "1025",
        "amount": 6.00,
        "authorizationAmount": 6.00,
        "capturedAmount": 6.00,
        "gratuityAmount": 0.00,
        "surchargeAmount": 0.00,
        "settlementAmount": 6.00,
        "approvalCode": "123456",
        "cvvCode": "M",
        "status": "SETTLED",
        "created": "2024-09-29T14:14:23"
      }
    ],
    "page": 1,
    "pageSize": 1000,
    "totalCount": 2
  }
}
```

### Response Fields

| Field                     | Description                               |
| ------------------------- | ----------------------------------------- |
| `id`                      | Batch ID                                  |
| `transactions.items`      | Array of transactions in the batch        |
| `transactions.totalCount` | Total number of transactions in the batch |
| `transactions.page`       | Current page                              |
| `transactions.pageSize`   | Page size used for this response          |

Each transaction item contains the same fields as the [Get a Transaction](/reporting/transactions) response.
