Skip to main content

BatchBuilder

Executes multiple API requests in a single HTTP call.

Example

const results = await api.batch(
api.workspaceUsers.getUserById(123, 456, { batch: true }),
api.workspaceUsers.getUserById(123, 789, { batch: true })
)

Extends

  • BaseClient

Constructors

Constructor

new BatchBuilder(config: ClientConfig): BatchBuilder;

Parameters

ParameterType
configClientConfig

Returns

BatchBuilder

Inherited from

BaseClient.constructor

Properties

PropertyModifierType
apiTokenreadonlystring
baseUrl?readonlystring
customFetch?readonlyCustomFetch
defaultVersionreadonlyApiVersion

Methods

execute()

execute<T>(requests: T): Promise<BatchResponseArray<T>>;

Executes multiple API requests with automatic chunking and parallel execution. Transparently handles the 10-request API limitation by splitting large batches into smaller chunks and executing them concurrently.

Type Parameters

Type Parameter
T extends readonly BatchRequestDescriptor<unknown>[]

Parameters

ParameterTypeDescription
requestsTArray of batch request descriptors

Returns

Promise<BatchResponseArray<T>>

Array of BatchResponse objects with processed data in original order

Throws

If any batch chunk fails completely


getBaseUri()

protected getBaseUri(version?: ApiVersion): string;

Gets the base URI for API requests with proper trailing slash handling. This method fixes the trailing slash bug that occurred when using custom baseUrl.

Parameters

ParameterTypeDescription
version?ApiVersionOptional API version override. Defaults to the configured version or 'v3'

Returns

string

Base URI with guaranteed trailing slash for proper URL resolution

Inherited from

BaseClient.getBaseUri