import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { data, error } = await mailchannels.webhooks.batches();
if (error) {
console.error("List webhook batches failed:", error);
process.exit(1);
}
console.log(data);import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY before running")
# List webhook batches from the last 3 days.
response = mailchannels.Webhooks.batches()
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$client = new Client(apiKey: $api_key);
// List webhook batches from the last 3 days.
$response = $client->webhooks->batches();
print_r($response->toArray());curl --request GET \
--url https://api.mailchannels.net/tx/v1/webhook-batch \
--header 'X-Api-Key: <x-api-key>'{
"webhook_batches": [
{
"batch_id": 1,
"created_at": "2023-11-07T05:31:56Z",
"customer_handle": "<string>",
"event_count": 1,
"status": "1xx_response",
"webhook": "<string>",
"duration": {
"unit": "milliseconds",
"value": 1
},
"status_code": 349
}
]
}{
"errors": [
"<string>"
]
}Retrieve Webhook Batches
Retrieves paged webhook batches associated with the customer. The time range specified by created_after and created_before filters must not exceed 31 days. If neither is specified, the default time range is the last 3 days. Optional filters include status categories, webhook, limit and offset.
import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { data, error } = await mailchannels.webhooks.batches();
if (error) {
console.error("List webhook batches failed:", error);
process.exit(1);
}
console.log(data);import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY before running")
# List webhook batches from the last 3 days.
response = mailchannels.Webhooks.batches()
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$client = new Client(apiKey: $api_key);
// List webhook batches from the last 3 days.
$response = $client->webhooks->batches();
print_r($response->toArray());curl --request GET \
--url https://api.mailchannels.net/tx/v1/webhook-batch \
--header 'X-Api-Key: <x-api-key>'{
"webhook_batches": [
{
"batch_id": 1,
"created_at": "2023-11-07T05:31:56Z",
"customer_handle": "<string>",
"event_count": 1,
"status": "1xx_response",
"webhook": "<string>",
"duration": {
"unit": "milliseconds",
"value": 1
},
"status_code": 349
}
]
}{
"errors": [
"<string>"
]
}Headers
Query Parameters
Inclusive lower bound(UTC) for filtering webhook batches by creation time. Formats: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ
Exclusive upper bound(UTC) for filtering webhook batches by creation time. Formats: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ
Filters webhook batches by webhook response status category. Values must be unique and encoded as a comma-separated list in the query string. If not provided, batches with all categories are returned.
61xx, 2xx, 3xx, 4xx, 5xx, no_response Filters webhook batches by the webhook endpoint to which events in the batch were posted.
The maximum number of webhook batches to return
1 <= x <= 500The number of webhook batches to skip before starting to collect the result set
x >= 0Response
Successfully returned Webhook batches
List of webhook batches matching the filter. Empty if no webhook batches match the filter.
Show child attributes
Show child attributes
Was this page helpful?

