Batches method 📢 Webhooks
Retrieves paged webhook batches associated with the customer. The time range specified by createdAfter and createdBefore must not exceed 31 days. If neither is specified, the default time range is the last 3 days.
Usage
ts
import { MailChannelsClient, Webhooks } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const webhooks = new Webhooks(mailchannels)
const { data, error } = await webhooks.batches()ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { data, error } = await mailchannels.webhooks.batches()Params
createdAfterstringoptional: Inclusive lower bound (UTC) for filtering webhook batches by creation time. Formats:YYYY-MM-DDorYYYY-MM-DDTHH:MM:SSZ.createdBeforestringoptional: Exclusive upper bound (UTC) for filtering webhook batches by creation time. Formats:YYYY-MM-DDorYYYY-MM-DDTHH:MM:SSZ.statusesWebhooksBatchStatus[]optional: Filters webhook batches by webhook response status category. If not provided, batches with all categories are returned. Possible values:1xx,2xx,3xx,4xx,5xx,no_response.webhookstringoptional: Filters webhook batches by the webhook endpoint to which events in the batch were posted.limitnumberoptional: The maximum number of webhook batches to return. Must be between1and500. Default is500.offsetnumberoptional: The number of webhook batches to skip before starting to collect the result set. Default is0.
Response
dataWebhooksBatch[] | nullnullablebatchIdnumberguaranteed: Unique identifier for the webhook batch.createdAtstringguaranteed: Timestamp of when the webhook batch was created.customerHandlestringguaranteed: The customer handle associated with the webhook batch.durationobjectoptional: Duration of the webhook batch, measured from the time the request was sent to the webhook endpoint until the response was received.unitstringguaranteed: The unit of time for the duration. Possible values:milliseconds.valuenumberguaranteed: The value of the duration in the specified unit.
eventCountnumberguaranteed: Number of events in the webhook batch.statusWebhooksBatchResponseStatusguaranteed: Status of the webhook batch. Possible values:1xx_response,2xx_response,3xx_response,4xx_response,5xx_response,no_response.statusCodenumber | nullnullable: HTTP status code returned by the webhook endpoint.webhookstringguaranteed: Webhook endpoint to which events in the batch were posted.
errorErrorResponse | nullnullable: Error information if the operation failed.messagestringguaranteed: A human-readable description of the error.statusCodenumber | nullnullable: The HTTP status code from the API, ornullif the error is not related to an HTTP request. This field is intended for diagnostic use only and should not be relied upon.typestringguaranteed: A string identifier for the type of error. This field is intended for diagnostic use only and should not be relied upon.
Type declarations
Signature
ts
async function batches (options?: WebhooksBatchesOptions): Promise<WebhooksBatchesResponse>Response type declarations
ts
interface ErrorResponse {
message: string;
statusCode: number | null;
type: ErrorType;
}ts
type DataResponse<T> = {
data: T;
error: null;
} | {
data: null;
error: ErrorResponse;
};Batches type declarations
ts
type WebhooksBatchStatus = "1xx" | "2xx" | "3xx" | "4xx" | "5xx" | "no_response";ts
interface WebhooksBatchesOptions {
createdAfter?: string;
createdBefore?: string;
statuses?: WebhooksBatchStatus[];
webhook?: string;
limit?: number;
offset?: number;
}ts
type WebhooksBatchResponseStatus = "1xx_response" | "2xx_response" | "3xx_response" | "4xx_response" | "5xx_response" | "no_response";ts
interface WebhooksBatch {
batchId: number;
createdAt: string;
customerHandle: string;
duration?: {
unit: "milliseconds";
value: number;
};
eventCount: number;
status: WebhooksBatchResponseStatus;
statusCode: number | null;
webhook: string;
}ts
type WebhooksBatchesResponse = DataResponse<WebhooksBatch[]>;Source
Source • Playground • Docs • Tests