> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailchannels.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.




## OpenAPI

````yaml /email-api/api-reference/openapi.yaml get /webhook-batch
openapi: 3.0.0
info:
  contact:
    email: support@mailchannels.com
    name: MailChannels Corporation
  description: >
    This is the API reference for Email API. Here, you'll find more detailed
    information on every endpoint, including parameters, response formats, and
    error codes.
  title: Email API
  version: 1.4.0
servers:
  - url: https://api.mailchannels.net/tx/v1
security: []
tags:
  - name: Send
  - name: DKIM
  - name: Metrics
  - name: Sub-accounts
  - name: Suppression
  - name: Webhooks
  - name: Usage
  - name: Custom Tracking
paths:
  /webhook-batch:
    get:
      tags:
        - Webhooks
      summary: Retrieve Webhook Batches
      description: |
        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.
      parameters:
        - description: >
            Inclusive lower bound(UTC) for filtering webhook batches by creation
            time.

            Formats: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ
          in: query
          name: created_after
          required: false
          schema:
            type: string
        - description: >
            Exclusive upper bound(UTC) for filtering webhook batches by creation
            time.

            Formats: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ
          in: query
          name: created_before
          required: false
          schema:
            type: string
        - description: >
            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.
          example: no_response,4xx,5xx
          explode: false
          in: query
          name: statuses
          required: false
          schema:
            items:
              enum:
                - 1xx
                - 2xx
                - 3xx
                - 4xx
                - 5xx
                - no_response
              type: string
            maxItems: 6
            type: array
          style: form
        - description: >
            Filters webhook batches by the webhook endpoint to which events in
            the batch were posted.
          in: query
          name: webhook
          required: false
          schema:
            type: string
        - description: |
            The maximum number of webhook batches to return
          in: query
          name: limit
          required: false
          schema:
            default: 500
            maximum: 500
            minimum: 1
            type: integer
        - description: >
            The number of webhook batches to skip before starting to collect the
            result set
          in: query
          name: offset
          required: false
          schema:
            default: 0
            minimum: 0
            type: integer
        - in: header
          name: X-Api-Key
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookBatchResult'
          description: |
            Successfully returned Webhook batches
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '500':
          description: Internal Server Error
      x-codeSamples:
        - label: Node.js
          lang: javascript
          source: >-
            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);
        - label: Python
          lang: python
          source: |-
            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)
        - label: PHP
          lang: php
          source: >-
            <?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());
components:
  schemas:
    WebhookBatchResult:
      properties:
        webhook_batches:
          description: |
            List of webhook batches matching the filter.
            Empty if no webhook batches match the filter.
          items:
            $ref: '#/components/schemas/WebhookBatch'
          type: array
      required:
        - webhook_batches
      type: object
    ErrorResponse:
      properties:
        errors:
          description: >
            This is an array error objects that provide machine and human
            readable descriptions of the errors.
          items:
            type: string
          type: array
      type: object
    WebhookBatch:
      properties:
        batch_id:
          description: |
            Unique identifier for the webhook batch
          format: int64
          minimum: 0
          type: integer
        created_at:
          description: |
            Timestamp of when the webhook batch was created
          format: date-time
          type: string
        customer_handle:
          description: |
            Customer handle associated with the webhook batch
          maxLength: 255
          type: string
        duration:
          $ref: '#/components/schemas/WebhookBatchDuration'
        event_count:
          description: |
            Number of events in the webhook batch
          minimum: 0
          type: integer
        status:
          description: |
            Status of the webhook batch.
            no_response: no response returned from the webhook endpoint.
          enum:
            - 1xx_response
            - 2xx_response
            - 3xx_response
            - 4xx_response
            - 5xx_response
            - no_response
          type: string
        status_code:
          description: |
            HTTP status code returned by the webhook endpoint
          maximum: 599
          minimum: 100
          nullable: true
          type: integer
        webhook:
          description: Webhook endpoint to which events in the batch were posted
          type: string
      required:
        - batch_id
        - customer_handle
        - webhook
        - status
        - created_at
        - event_count
      type: object
    WebhookBatchDuration:
      description: >
        Duration of the webhook batch.

        measured from the time the request was sent to the webhook endpoint
        until

        the response was received.
      properties:
        unit:
          enum:
            - milliseconds
          type: string
        value:
          minimum: 0
          type: integer
      required:
        - value
        - unit
      type: object

````