> This page is for Afterpay Partner API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.afterpay.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.afterpay.com/_mcp/server.

# Get Settlement Batch Files

GET https://agencyapi.afterpay.com/v1/settlement/batch

Returns signed S3 urls to the settlement file and aggregation file for specified batch IDs.

Reference: https://developers.afterpay.com/afterpay-partner-api/api-reference/reference-partner-api/settlements/get-settlement-batch-files

## Servers

- `https://agencyapi.afterpay.com` (Production, default)
- `https://agencyapi.sandbox.afterpay.com` (Sandbox)

## Request

### Query parameters

- `ids` (string, required) — Comma separated ids of batches to fetch.

### Headers

- `Accept` (string, required, default: application/json) — Specifies media types that are acceptable for the response.

## Response

### 200

Successful response with signed S3 URLs for the settlement and aggregation files.

- `batches` (list of V1SettlementBatchGetResponsesContentApplicationJsonSchemaBatchesItems, optional)
- `meta_data` (V1SettlementBatchGetResponsesContentApplicationJsonSchemaMetaData, optional)

## Errors

### 401 Unauthorized Error

Unauthorized, HMAC verification failed

- `timestamp` (string, optional) — Timestamp of the response.
- `status` (integer, optional) — The HTTP status code.
- `error` (string, optional) — Name of the error that occurred.
- `message` (string, optional) — A human-readable message which provides more details about the error.
- `path` (string, optional) — The attempted endpoint.

### 404 Not Found Error

Not Found - The specified resource was not found.

- `timestamp` (string, optional) — Timestamp of the response, indicating when the error occurred.
- `status` (integer, optional) — The HTTP status code, specifically indicating a 404 error in this case.
- `error` (string, optional) — A short description of the error, typically "Not Found" for a 404 response.
- `message` (string, optional) — A human-readable message providing more details about the error.
- `path` (string, optional) — The attempted endpoint path that resulted in the 404 error.

### 503 Service Unavailable Error

Service unavailable.

- `timestamp` (string, optional) — Timestamp of the response.
- `status` (integer, optional) — The HTTP status code.
- `error` (string, optional) — Name of the error that occurred.
- `message` (string, optional) — A human-readable message which provides more details about the error.
- `path` (string, optional) — The attempted endpoint.

## Types

### V1SettlementBatchGetResponsesContentApplicationJsonSchemaBatchesItems

- `id` (string, optional) — Settlement batch ID.
- `settlement_file` (string, optional) — Signed S3 URL to the settlement file.
- `aggregation_file` (string, optional) — Signed S3 URL to the aggregation file.

### V1SettlementBatchGetResponsesContentApplicationJsonSchemaMetaData

- `computed_at` (string, optional) — Timestamp of the query computation.
- `link_expiry` (string, optional) — Timestamp of the link expiration.

## Examples

**Response**

```json
{
  "batches": [
    {
      "id": "2020-07-10Z_sud294dgzb",
      "settlement_file": "https://s3.amazonaws.com/settlements/transaction.csv?token",
      "aggregation_file": "https://s3.amazonaws.com/settlements/aggregated.csv?token"
    }
  ],
  "meta_data": {
    "computed_at": "2024-02-21T19:25:44Z",
    "link_expiry": "2024-03-06T19:25:44Z"
  }
}
```

**SDK Code**

```python
import requests

url = "https://agencyapi.afterpay.com/v1/settlement/batch"

querystring = {"ids":"id1,id2,id3"}

headers = {
    "Accept": "application/json",
    "User-Agent": "User-Agent"
}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://agencyapi.afterpay.com/v1/settlement/batch?ids=id1%2Cid2%2Cid3';
const options = {
  method: 'GET',
  headers: {Accept: 'application/json', 'User-Agent': 'User-Agent'}
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://agencyapi.afterpay.com/v1/settlement/batch?ids=id1%2Cid2%2Cid3"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Accept", "application/json")
	req.Header.Add("User-Agent", "User-Agent")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://agencyapi.afterpay.com/v1/settlement/batch?ids=id1%2Cid2%2Cid3")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Accept"] = 'application/json'
request["User-Agent"] = 'User-Agent'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://agencyapi.afterpay.com/v1/settlement/batch?ids=id1%2Cid2%2Cid3")
  .header("Accept", "application/json")
  .header("User-Agent", "User-Agent")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://agencyapi.afterpay.com/v1/settlement/batch?ids=id1%2Cid2%2Cid3', [
  'headers' => [
    'Accept' => 'application/json',
    'User-Agent' => 'User-Agent',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://agencyapi.afterpay.com/v1/settlement/batch?ids=id1%2Cid2%2Cid3");
var request = new RestRequest(Method.GET);
request.AddHeader("Accept", "application/json");
request.AddHeader("User-Agent", "User-Agent");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Accept": "application/json",
  "User-Agent": "User-Agent"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://agencyapi.afterpay.com/v1/settlement/batch?ids=id1%2Cid2%2Cid3")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```