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

# Create a webhook for an email domain

> Creates a webhook endpoint subscribed to a specific allowlist of event types. Both `email.*` events (published by email-api) and `email_domain.*` events (published by this service) flow through the same webhooks.




## OpenAPI

````yaml /openapi/generated/email/domains.yml post /email_domains/{domain_id}/webhooks
openapi: 3.1.0
info:
  contact:
    email: support@telnyx.com
  description: API for managing email domains, DNS records, verification, and webhooks.
  title: Telnyx Email Domains API
  version: 2.0.0
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /email_domains/{domain_id}/webhooks:
    post:
      tags:
        - Email Webhooks
      summary: Create a webhook for an email domain
      description: >
        Creates a webhook endpoint subscribed to a specific allowlist of event
        types. Both `email.*` events (published by email-api) and
        `email_domain.*` events (published by this service) flow through the
        same webhooks.
      operationId: createEmailDomainWebhook
      parameters:
        - $ref: '#/components/parameters/EmailDomainDomainId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEmailWebhookRequest'
            example:
              url: https://example.com/webhooks/email
              events:
                - email.sent
                - email.delivered
                - email.bounced
      responses:
        '201':
          description: Email webhook created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailWebhookResponse'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationFailed'
        '500':
          $ref: '#/components/responses/InternalServerError'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Telnyx from 'telnyx';


            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });


            const EmailWebhook = await
            client.emailDomains.webhooks.create('domain_id', {
              events: [],
              url: 'url',
            });


            console.log(EmailWebhook.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            email_webhook = client.email_domains.webhooks.create(
                domain_id="domain_id",
                events=[],
                url="url",
            )
            print(email_webhook.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\twebhook, err := client.EmailDomains.Webhooks.New(\n\t\tcontext.TODO(),\n\t\t\"domain_id\",\n\t\ttelnyx.EmailDomainWebhookNewParams{\n\t\t\tEvents: \"events\",\n\t\t\tURL:    \"url\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", webhook.Data)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.emailDomains.webhooks.WebhookCreateParams;

            import java.util.List;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    WebhookCreateParams params = WebhookCreateParams.builder()
                        .events(List.of())
                        .url("url")
                        .build();
                    var response = client.emailDomains().webhooks().create("domain_id", params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


            telnyx = Telnyx::Client.new(api_key: "My API Key")


            email_webhook = telnyx.email_domains.webhooks.create("domain_id",
            events: [], url: "url")


            puts(email_webhook)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $email_webhook = $client->emailDomains->webhooks->create(
                'domain_id',
                events: [],
                url: 'url',
              );

              var_dump($email_webhook);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx email-domains:webhooks create \
              --api-key 'My API Key' \
              --domain-id domain_id \
              --url url \
              --events email.scheduled
components:
  parameters:
    EmailDomainDomainId:
      name: domain_id
      in: path
      required: true
      description: Email domain UUID
      schema:
        type: string
        format: uuid
  schemas:
    CreateEmailWebhookRequest:
      type: object
      required:
        - url
        - events
      properties:
        url:
          type: string
          format: uri
          description: HTTPS endpoint to deliver subscribed events to.
        events:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/EmailWebhookEvent'
          description: At least one event type is required.
    EmailWebhookResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/EmailWebhook'
    EmailWebhookEvent:
      type: string
      description: >
        Event types a webhook may subscribe to. The union of email.* events
        (published by email-api) and email_domain.* lifecycle events (published
        by this service). An event not listed here can never be subscribed to
        and is silently dropped.
      enum:
        - email.scheduled
        - email.sandbox
        - email.queued
        - email.sending
        - email.sent
        - email.delivered
        - email.deferred
        - email.bounced
        - email.failed
        - email.complained
        - email.opened
        - email.clicked
        - email.unsubscribed
        - email.received
        - email_domain.created
        - email_domain.verified
        - email_domain.degraded
        - email_domain.suspended
        - email_domain.deleted
    EmailWebhook:
      type: object
      required:
        - id
        - record_type
        - url
        - events
        - domain_id
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
        record_type:
          type: string
          enum:
            - email_webhook
        url:
          type: string
          format: uri
          description: HTTPS endpoint to deliver subscribed events to.
        events:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/EmailWebhookEvent'
          description: >
            Allowlist of event types delivered to this webhook. At least one
            event is required — there is no default-to-all.
        domain_id:
          type: string
          format: uuid
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      example:
        id: 123e4567-e89b-12d3-a456-426614174003
        record_type: email_webhook
        url: https://example.com/webhooks/email
        events:
          - email.sent
          - email.delivered
          - email.bounced
        domain_id: 123e4567-e89b-12d3-a456-426614174000
        created_at: '2026-06-18T12:00:00Z'
        updated_at: '2026-06-18T12:00:00Z'
    DomainsErrorResponse:
      type: object
      required:
        - errors
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/email_Error'
    email_Error:
      type: object
      required:
        - code
        - title
        - detail
      properties:
        code:
          type: string
          enum:
            - '10001'
            - '10015'
            - '500'
            - '10007'
            - '10008'
            - '10020'
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              type: string
  responses:
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DomainsErrorResponse'
          example:
            errors:
              - code: '10001'
                title: Not Found
                detail: The requested email domain was not found
    ValidationFailed:
      description: Validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DomainsErrorResponse'
          example:
            errors:
              - code: '10015'
                title: Validation Failed
                detail: domain is invalid
                source:
                  pointer: /data/attributes/domain
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DomainsErrorResponse'
          example:
            errors:
              - code: '500'
                title: Internal Server Error
                detail: An unexpected error occurred
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````