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 })
)

Constructors

Constructor

new BatchBuilder(apiToken: string, baseUrl?: string): BatchBuilder;

Parameters

ParameterType
apiTokenstring
baseUrl?string

Returns

BatchBuilder

Methods

execute()

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

Executes an array of batch request descriptors in a single API call.

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

Throws

If the batch request fails