---
title: Batcher
slug: data-platform/connect-platform/app-sdk-api-reference-classes-batcher
docTags: 
createdAt: 2026-08-05T20:06:34.632Z
---

[OCP App SDK](docId\:gxEU_0AA37IEZJK-uoVcT)

***

[OCP App SDK](docId\:gxEU_0AA37IEZJK-uoVcT) / Batcher

# Class: Batcher`<T>`

Defined in: [src/app/lib/Batcher.ts:13](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/lib/Batcher.ts#L13)

A class to aid in batching operations, such as sending requests to ODP APIs.

## Usage

```javascript
const eventBatcher = new Batcher(z.event);
...
await eventBatcher.append({type: 'pageview', {page: 'https://foo'});
...
await eventBatcher.flush();
```

## Type Parameters

### T

`T`

## Constructors

### Constructor

:::BlockQuote
**new Batcher**`<T>`(`operation`, `limit`): `Batcher<T>`
:::

Defined in: [src/app/lib/Batcher.ts:15](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/lib/Batcher.ts#L15)

### Parameters

### operation

[`` `BatchOperation` ``](docId:1VeG5qpTh2CjHUF71buqx)`<T>`

### limit

`number` = `100`

### Returns

`Batcher<T>`

## Methods

### append()

:::BlockQuote
**append**(`data`): `Promise<void>`
:::

Defined in: [src/app/lib/Batcher.ts:22](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/lib/Batcher.ts#L22)

Append data to the batch, and if the batch size reaches the limit, perform and await the desired operation

### Parameters

### data

`T`

the data needed by the operation. Of type T in new Batcher`<T>`((data: T) => Promise`<void>`)

### Returns

`Promise``<void>`

***

### flush()

:::BlockQuote
**flush**(): `Promise``<void>`
:::

Defined in: [src/app/lib/Batcher.ts:33](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/lib/Batcher.ts#L33)

Flush any remaining items in the batcher. Do this before giving up control of your task, e.g.,
before exiting a job's perform method to make sure nothing is lost if the job needs to be paused and resumed.

### Returns

`Promise``<void>`
