import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY, BATCH_ID } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
if (!BATCH_ID) throw new Error("Set BATCH_ID to the ID of the batch to resend");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { data, error } = await mailchannels.webhooks.resendBatch(Number(BATCH_ID));
if (error) {
console.error("Resend webhook batch 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")
batch_id_str = os.environ.get("BATCH_ID")
if not batch_id_str:
sys.exit("Set BATCH_ID before running")
# Resend a specific webhook batch.
response = mailchannels.Webhooks.resend_batch(int(batch_id_str))
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");
$batch_id = getenv('BATCH_ID') or exit("Error: BATCH_ID is not set\n");
$client = new Client(apiKey: $api_key);
$response = $client->webhooks->resendBatch((int) $batch_id);
print_r($response->toArray());curl --request POST \
--url https://api.mailchannels.net/tx/v1/webhook-batch/{batch_id}/resend \
--header 'X-Api-Key: <x-api-key>'{
"batch_id": 1,
"created_at": "2023-11-07T05:31:56Z",
"customer_handle": "<string>",
"event_count": 1,
"webhook": "<string>",
"duration_in_ms": 1,
"status_code": 123
}Resend Events
Synchronously resend the webhook batch with the provided batch_id for the customer. The result is returned in the response.
import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY, BATCH_ID } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
if (!BATCH_ID) throw new Error("Set BATCH_ID to the ID of the batch to resend");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { data, error } = await mailchannels.webhooks.resendBatch(Number(BATCH_ID));
if (error) {
console.error("Resend webhook batch 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")
batch_id_str = os.environ.get("BATCH_ID")
if not batch_id_str:
sys.exit("Set BATCH_ID before running")
# Resend a specific webhook batch.
response = mailchannels.Webhooks.resend_batch(int(batch_id_str))
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");
$batch_id = getenv('BATCH_ID') or exit("Error: BATCH_ID is not set\n");
$client = new Client(apiKey: $api_key);
$response = $client->webhooks->resendBatch((int) $batch_id);
print_r($response->toArray());curl --request POST \
--url https://api.mailchannels.net/tx/v1/webhook-batch/{batch_id}/resend \
--header 'X-Api-Key: <x-api-key>'{
"batch_id": 1,
"created_at": "2023-11-07T05:31:56Z",
"customer_handle": "<string>",
"event_count": 1,
"webhook": "<string>",
"duration_in_ms": 1,
"status_code": 123
}Headers
Path Parameters
the ID of the batch
Response
Resend attempt completed. The result of the resend attempt is included in the response body. A successful response here does not mean the webhook endpoint responded with a 2xx status code, only that we were able to make the resend attempt and receive a response.
Unique identifier for the webhook batch
x >= 0Timestamp of when the webhook batch was created
Customer handle associated with the webhook batch
255Number of events in the webhook batch
x >= 0Webhook URL to which events in the batch were posted
Duration of the webhook batch in milliseconds, measured from the time the request was sent to the webhook endpoint until the response was received. Null indicates that no response was returned from the webhook endpoint.
x >= 0HTTP status code returned by the webhook endpoint. Valid values are 100-599. Null indicates that no response was returned from the webhook endpoint.
x <= 599Was this page helpful?

