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

> ## Agent Instructions
> AhaSend stores all message data in the EU. See /facts.
> The API base URL is https://api.ahasend.com. Send the API key in the Authorization: Bearer header. See /api-reference/authentication.
> Use send.ahasend.com for SMTP. Ports 25, 587 and 2525 use STARTTLS. Port 465 is not supported. See /smtp.
> For send-only integrations, create an API Key v2 under Credentials → Add and scope it to messages:send:{your-domain}. See /send-api/credentials and /api-reference/scopes.

# Update a Webhook via the API

> Update an AhaSend webhook with the API: change its URL, event types, enabled status or domain scope. Omitted fields stay unchanged; the secret can't change.

The AhaSend API updates an existing webhook. Omitted or null fields are unchanged.
Omitted/null `domains` preserves associations, while `[]` clears the
associations of a resulting-scoped webhook. Moving from global to
scoped requires a non-empty `domains` array in the same request. Moving
to global clears associations and ignores supplied domains.

A domain-scoped key must be authorized for the existing webhook and
every newly supplied domain; changing to global requires
`webhooks:write:all`.

Turning on a contact event (the `on_contact_*` fields) for an account
without the marketing features returns HTTP 400. A webhook with any
contact event on needs an API key with `contacts:read`, and with
`lists:read` as well for `on_contact_added_to_list`,
`on_contact_removed_from_list`, `on_contact_subscribed`,
`on_contact_unsubscribed`, and `on_contact_complained`. This check runs
against the webhook as it will be after the update, so every update of
an enabled webhook that keeps a contact event on needs these scopes,
also an update of only `name`, `url`, `scope`, `domains`, or
`origins`, and returns HTTP 403 without them. A key without them can
only turn those events off or disable the webhook (`enabled: false`);
turning it on again needs the scopes. The marketing check runs first.

**Note:** The webhook secret is not updatable

## Related Guides

* [API authentication](https://ahasend.com/docs/api-reference/authentication.md), [Permission scopes](https://ahasend.com/docs/api-reference/scopes.md), [Webhook setup](https://ahasend.com/docs/integrations/webhooks.md).
* [Event reference](https://ahasend.com/docs/api-reference/webhooks.md), [Webhook CLI](https://ahasend.com/docs/cli/commands/webhooks.md), [Local webhook testing](https://ahasend.com/docs/cli/webhook-testing.md).
* [Signature verification](https://ahasend.com/docs/api-reference/webhooks/security.md), [Retry policy](https://ahasend.com/docs/api-reference/webhooks/retry-policy.md), [API errors](https://ahasend.com/docs/api-reference/errors.md).
* [API rate limits](https://ahasend.com/docs/api-reference/rate-limits.md).


## OpenAPI

````yaml openapi.yaml PUT /v2/accounts/{account_id}/webhooks/{webhook_id}
openapi: 3.1.0
info:
  title: AhaSend API v2
  description: >
    The AhaSend API v2 allows you to send transactional emails, manage domains,
    webhooks, routes, API keys, and view statistics.


    ## Authentication

    All API requests must be authenticated using a Bearer token in the
    Authorization header:

    ```

    Authorization: Bearer aha-sk-64-CHARACTER-RANDOM-STRING

    ```


    ## Scopes

    API keys have specific scopes that control access to different resources and
    actions:


    ### Message Scopes

    - `messages:send:all` - Send messages from any domain in the account

    - `messages:send:{domain}` - Send messages from a specific domain

    - `messages:cancel:all` - Cancel messages from any domain

    - `messages:cancel:{domain}` - Cancel messages from a specific domain

    - `messages:read:all` - Read messages from any domain

    - `messages:read:{domain}` - Read messages from a specific domain


    ### Domain Scopes

    - `domains:read` - Read all domains

    - `domains:write` - Create and update domains

    - `domains:delete:all` - Delete any domain

    - `domains:delete:{domain}` - Delete a specific domain


    ### Account Scopes

    - `accounts:read` - Read account information

    - `accounts:write` - Update account settings

    - `accounts:billing` - Access billing information

    - `accounts:members:read` - Read account members

    - `accounts:members:add` - Add account members

    - `accounts:members:update` - Update account members

    - `accounts:members:remove` - Remove account members


    ### Webhook Scopes

    - `webhooks:read:all` - Read all webhooks

    - `webhooks:read:{domain}` - Read webhooks for a specific domain

    - `webhooks:write:all` - Create and update webhooks

    - `webhooks:write:{domain}` - Create and update webhooks for a specific
    domain

    - `webhooks:delete:all` - Delete any webhook

    - `webhooks:delete:{domain}` - Delete webhooks for a specific domain


    ### Route Scopes

    - `routes:read:all` - Read all routes

    - `routes:read:{domain}` - Read routes for a specific domain

    - `routes:write:all` - Create and update routes

    - `routes:write:{domain}` - Create and update routes for a specific domain

    - `routes:delete:all` - Delete any route

    - `routes:delete:{domain}` - Delete routes for a specific domain


    ### Suppression Scopes

    - `suppressions:read` - Read suppressions

    - `suppressions:write` - Create suppressions

    - `suppressions:delete` - Delete suppressions

    - `suppressions:wipe` - Delete the account's suppressions except protected
    ones (dangerous)


    ### Template Scopes

    - `templates:read` - Read transactional templates, their drafts and their
    published versions, and campaign templates

    - `templates:write` - Create and update transactional templates, and
    publish, discard and restore their drafts; create and update campaign
    templates

    - `templates:delete` - Delete transactional templates and campaign templates


    ### Campaign Scopes

    - `campaigns:read` - Read campaigns, their stats and their recipients

    - `campaigns:write` - Create, update and duplicate campaigns

    - `campaigns:delete` - Delete draft campaigns

    - `campaigns:send` - Send, unschedule and test-send campaigns


    ### Contact Scopes

    - `contacts:read` - Read contacts

    - `contacts:write` - Create and update contacts

    - `contacts:delete` - Delete contacts


    ### Contact lifecycle and attributes

    Contacts are account-global. A contact created through this API joins no

    list on its own; campaigns target lists, so add it to one with the Lists

    endpoints before a campaign can reach it.

    Contact subscription state and suppression records are independent:

    creating, updating, unsubscribing, resubscribing, or deleting a contact

    never creates, changes, or removes complaint, permanent, or protected

    suppressions. Prefer unsubscribe over delete when the goal is only to stop

    marketing mail, because unsubscribe is reversible and preserves contact

    history.


    Writable attribute keys and types come from the account's contact-attribute

    definitions managed in the dashboard; this API does not expose property

    definition CRUD. Writes accept only canonical values for those definitions,

    while reads remain legacy-safe and can return any recursively nested JSON

    value previously stored.


    An email used as `{id_or_email}` is a raw SDK argument and must be

    percent-encoded exactly once as a URL path segment by an HTTP client. For

    example, do not pre-encode `user+tag@example.com` before passing it to an

    SDK that encodes path parameters.


    ### List Scopes

    - `lists:read` - Read lists and list membership

    - `lists:write` - Create and update lists, and add or remove their contacts

    - `lists:delete` - Delete lists


    ### Lists and membership

    A list is a static, private, single opt-in container of contacts, and it is

    what a campaign targets. A membership carries its own `subscription_status`

    (`unconfirmed`, `confirmed`, `unsubscribed`, or `complained`), which is

    per-list consent and is independent of the contact's account-wide

    `unsubscribed` flag. A membership created without a status named is

    `confirmed`, because that is what a campaign reaches. `complained` is the

    mailbox provider's verdict, never writable, and a membership holding it is

    frozen.


    Deleting a list keeps its memberships, so an unsubscribe survives it.

    Removing a contact from a list deletes the membership row and discards that

    record with it, which is why unsubscribing is the reversible way to stop

    marketing mail on one list. Expanding a list's members with

    `include_contacts=true` requires `contacts:read` in addition to

    `lists:read`.


    ### Segment Scopes

    - `segments:read` - Read segments, their members and a contact's segments,
    and preview a definition

    - `segments:write` - Create and update segments

    - `segments:delete` - Delete segments


    ### Segments

    A segment is a saved set of rules over the account's contacts: their

    fields, their list memberships, and the campaigns they received, opened

    or clicked. AhaSend keeps its members up to date as that data changes,

    usually within a minute; rules about campaigns follow within an hour of a

    send, and relative times such as `30 days ago` are read again on a

    schedule. Membership is the rule match only, whatever the contact's

    consent: a campaign to a segment reaches the members who are enabled, not

    unsubscribed, not found invalid, and either confirmed on at least one list

    or on no list at all. A contact who unsubscribed from or complained on

    every list they were on, or has not confirmed a double opt-in, is not

    reached. A contact who unsubscribes from a segment send, or reports it as

    spam, gets no more marketing email from the account.


    ### SMTP Credentials Scopes

    - `smtp-credentials:read:all` - Read all SMTP credentials

    - `smtp-credentials:read:{domain}` - Read SMTP credentials for a specific
    domain

    - `smtp-credentials:write:all` - Create SMTP credentials

    - `smtp-credentials:write:{domain}` - Create SMTP credentials for a specific
    domain

    - `smtp-credentials:delete:all` - Delete any SMTP credentials

    - `smtp-credentials:delete:{domain}` - Delete SMTP credentials for a
    specific domain


    ### Statistics Scopes

    - `statistics-transactional:read:all` - Read all transactional statistics

    - `statistics-transactional:read:{domain}` - Read transactional statistics
    for a specific domain


    ### API Key Scopes

    - `api-keys:read` - Read API keys

    - `api-keys:write` - Create and update API keys

    - `api-keys:delete` - Delete API keys


    ### Sub-Account Scopes

    - `sub-accounts:read` - List and read sub accounts under the parent

    - `sub-accounts:write` - Create and update sub accounts

    - `sub-accounts:delete` - Soft-delete sub accounts

    - `sub-accounts:suspend` - Pause and resume sub accounts, and unpause their
    domains

    - `sub-accounts:usage` - Read per-sub-account usage and allocated cost

    - `sub-account-api-keys:read` - List and read API keys owned by sub accounts

    - `sub-account-api-keys:write` - Create and update API keys owned by sub
    accounts

    - `sub-account-api-keys:delete` - Delete API keys owned by sub accounts


    ## Rate Limiting

    - General API endpoints: 100 requests per second, 200 burst

    - Statistics endpoints: 1 request per second, 1 burst


    A request over the limit gets HTTP 429 with a `Retry-After` header: the

    number of seconds to wait before retrying.


    ## Pagination

    List endpoints use cursor-based pagination with the following parameters:

    - `limit`: Maximum number of items to return (default: 100, max: 100)

    - `after`: Pass `pagination.next_cursor` to fetch the next page

    - `before`: Pass `pagination.previous_cursor` to fetch the previous page


    `after` and `before` are mutually exclusive. A legacy `cursor` query may be

    accepted by parts of the server for backwards compatibility, but it is not

    part of the v2 public contract.


    ## Time Formats

    All timestamps must be in RFC3339 format, e.g., `2023-12-25T10:30:00Z`


    ## Idempotency

    The operations that explicitly declare the optional `Idempotency-Key`

    header support idempotency. Other POST operations do not gain idempotency

    implicitly. When the header is provided:

    - A fresh execution does not return `Idempotent-Replayed`.

    - A completed stored response is replayed with its original status and body
      and `Idempotent-Replayed: true`.
    - An unexpired in-progress execution returns HTTP 409 with
      `Idempotent-Replayed: false` and a positive integer `Retry-After` header.
    - Reusing a key with a different HTTP method, resolved request path, or
      request body returns HTTP 422. That response has neither
      `Idempotent-Replayed` nor `Retry-After`.
    - For ordinary idempotent operations, deterministic 2xx and 4xx outcomes
      produced after the idempotency middleware are stored and replayed.
      Authentication and IP-allow-list failures happen before idempotency and
      are therefore not stored.
    - The two secret-bearing API-key create operations use manual encrypted
      completion. They store and replay a successful 201, including the same
      one-time `secret_key`; a controller-produced 4xx is not stored and leaves
      the key in progress until its execution lease expires.
    - Create Segment and Test Campaign store and replay a 2xx only. A 4xx is
      not stored: it releases the key, so a retry with the same key runs
      again.
    - Server errors (5xx), handler failures, and panics are not stored. The key
      is released so retrying the same request with the same key re-executes it.
      The v2 API does not use an HTTP 412 failed-key tombstone.
    - Idempotency keys for non-secret responses expire after 24 hours.

    - Encrypted API-key creation replay responses expire after 5 minutes.


    ## IP Allow Lists

    Each API key can carry an `ip_allow_list`: a set of source IPs that restrict
    where the key may authenticate from.

    - Entries are CIDR blocks (e.g. `203.0.113.0/24`) or bare IPv4/IPv6
    addresses (stored as a `/32` or `/128`). They are canonicalized and
    de-duplicated; the allow-all prefixes `0.0.0.0/0` and `::/0` are rejected,
    and at most 100 entries are allowed after de-duplication (a longer list is
    rejected with HTTP 400).

    - An empty list (the default) places no restriction.

    - When the list is non-empty, any authenticated request whose client IP is
    not covered by an entry is rejected with HTTP 403 on every v2 endpoint,
    regardless of the key's scopes.

    - Manage the list with the `ip_allow_list` field on the API-key create and
    update endpoints (including the sub-account API-key endpoints).

    - When a key updates its own `ip_allow_list` to a value that excludes the
    caller's current IP, the update is rejected with HTTP 409 to prevent
    self-lockout. Updating a sub-account key from a parent key has no such
    guard.
  version: 2.0.0
  contact:
    email: support@ahasend.com
  license:
    name: MIT
    identifier: MIT
servers:
  - url: https://api.ahasend.com
    description: Production server
security:
  - BearerAuth: []
tags:
  - name: Utility
    description: Utility endpoints for health checks and diagnostics
  - name: API Keys
    description: Manage API keys for authentication and access control
  - name: Domains
    description: Manage sending domains
  - name: Messages
    description: Send and manage transactional messages
  - name: Accounts
    description: Manage account settings and members
  - name: Contacts
    description: Read, create, update, batch upsert, and delete account-global contacts
  - name: Templates
    description: >-
      Create, change, publish and delete the account's transactional templates,
      and read them with their drafts, their published versions and the
      variables a send must supply
  - name: Campaign Templates
    description: >-
      Create, change, read and delete the account's campaign templates, the
      designs a campaign copies when it is made from one
  - name: Campaigns
    description: >-
      Create, change, read, duplicate, delete, test and send the account's
      marketing campaigns, and read their stats and recipients
  - name: Lists
    description: Manage contact lists and the contacts on them
  - name: Segments
    description: >-
      Manage segments, the saved rules that keep a set of contacts up to date,
      and read their members
  - name: Suppressions
    description: Manage email suppressions
  - name: Routes
    description: Manage inbound email routing
  - name: Webhooks
    description: Manage webhook notifications
  - name: SMTP Credentials
    description: Manage SMTP authentication credentials
  - name: Statistics
    description: Access transactional email statistics
  - name: Message Events
    description: Webhooks for outbound message delivery events
  - name: Suppression Events
    description: Webhooks for suppression list changes
  - name: Domain Events
    description: Webhooks for domain configuration issues
  - name: Route Events
    description: Webhooks for inbound email routing
paths:
  /v2/accounts/{account_id}/webhooks/{webhook_id}:
    put:
      tags:
        - Webhooks
      summary: Update Webhook
      description: |
        Updates an existing webhook. Omitted or null fields are unchanged.
        Omitted/null `domains` preserves associations, while `[]` clears the
        associations of a resulting-scoped webhook. Moving from global to
        scoped requires a non-empty `domains` array in the same request. Moving
        to global clears associations and ignores supplied domains.

        A domain-scoped key must be authorized for the existing webhook and
        every newly supplied domain; changing to global requires
        `webhooks:write:all`.

        Turning on a contact event (the `on_contact_*` fields) for an account
        without the marketing features returns HTTP 400. A webhook with any
        contact event on needs an API key with `contacts:read`, and with
        `lists:read` as well for `on_contact_added_to_list`,
        `on_contact_removed_from_list`, `on_contact_subscribed`,
        `on_contact_unsubscribed`, and `on_contact_complained`. This check runs
        against the webhook as it will be after the update, so every update of
        an enabled webhook that keeps a contact event on needs these scopes,
        also an update of only `name`, `url`, `scope`, `domains`, or
        `origins`, and
        returns HTTP 403 without them. A key without them can only turn those
        events off or disable the webhook (`enabled: false`); turning it on
        again needs the scopes. The marketing check runs first.

        **Note:** The webhook secret is not updatable
      operationId: updateWebhook
      parameters:
        - name: account_id
          in: path
          required: true
          description: Account ID
          schema:
            type: string
            format: uuid
        - name: webhook_id
          in: path
          required: true
          description: Webhook ID
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateWebhookRequest'
      responses:
        '200':
          description: Webhook updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Webhook'
        '400':
          description: |
            Bad request, or a contact event for an account without the
            marketing features
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: |
            Forbidden, or a contact event on with an API key that lacks the
            `contacts:read` or `lists:read` scope it needs
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Webhook not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth:
            - webhooks:write:all
        - BearerAuth:
            - webhooks:write:{domain}
      x-code-samples:
        - lang: go
          label: AhaSend Go SDK
          source: |
            package main

            import (
              "context"
              "fmt"
              "log"
              "os"

              "github.com/AhaSend/ahasend-go"
              "github.com/AhaSend/ahasend-go/api"
              "github.com/AhaSend/ahasend-go/models/requests"
              "github.com/google/uuid"
            )

            func main() {
              client := api.NewAPIClient(api.WithAPIKey(os.Getenv("AHASEND_API_KEY")))
              accountID := uuid.MustParse(os.Getenv("AHASEND_ACCOUNT_ID"))
              ctx := context.Background()

              webhookID := uuid.MustParse("c5a32c40-b351-439f-8230-779daed3e42c")

              response, _, err := client.WebhooksAPI.UpdateWebhook(ctx, accountID, webhookID, requests.UpdateWebhookRequest{
                Name:      ahasend.String("Failures"),
                URL:       ahasend.String("https://example.com/webhook"),
                Enabled:   ahasend.Bool(true),
                OnBounced: ahasend.Bool(true),
              })
              if err != nil {
                log.Fatalf("Error updating webhook: %v", err)
              }
              fmt.Printf("Updated webhook %s\n", response.ID)
            }
        - lang: javascript
          label: Node.js 22+ (AhaSend SDK)
          source: >
            import { AhaSendClient } from "@ahasend/sdk";


            const client = AhaSendClient.fromEnv();

            const webhookId = "00000000-0000-4000-8000-000000000007";

            const webhook = await client.webhooks.update(webhookId, {
              name: "Transactional delivery events",
            });

            console.log("Webhook updated.", { id: webhook.id, name: webhook.name
            });
components:
  schemas:
    UpdateWebhookRequest:
      type: object
      description: |
        Partial update. Omitted and null scalar fields leave their stored values
        unchanged. Domain transition rules depend on the webhook's existing
        scope and are described on `domains`.
      properties:
        name:
          type:
            - string
            - 'null'
          maxLength: 255
          description: Webhook name
        url:
          type:
            - string
            - 'null'
          format: uri
          description: Webhook URL
        enabled:
          type:
            - boolean
            - 'null'
          description: Whether the webhook is enabled
        on_reception:
          type:
            - boolean
            - 'null'
          description: Trigger on message reception
        on_delivered:
          type:
            - boolean
            - 'null'
          description: Trigger on message delivery
        on_transient_error:
          type:
            - boolean
            - 'null'
          description: Trigger on transient errors
        on_failed:
          type:
            - boolean
            - 'null'
          description: Trigger on permanent failures
        on_bounced:
          type:
            - boolean
            - 'null'
          description: Trigger on bounces
        on_suppressed:
          type:
            - boolean
            - 'null'
          description: Trigger on suppressions
        on_opened:
          type:
            - boolean
            - 'null'
          description: Trigger on opens
        on_clicked:
          type:
            - boolean
            - 'null'
          description: Trigger on clicks
        on_unsubscribed:
          type:
            - boolean
            - 'null'
          description: Trigger on unsubscribes
        on_complained:
          type:
            - boolean
            - 'null'
          description: Trigger on spam complaints
        on_suppression_created:
          type:
            - boolean
            - 'null'
          description: Trigger on suppression creation
        on_suppression_deleted:
          type:
            - boolean
            - 'null'
          description: Trigger on suppression deletion
        on_dns_error:
          type:
            - boolean
            - 'null'
          description: Trigger on DNS errors
        on_contact_created:
          type:
            - boolean
            - 'null'
          description: Trigger on contact creation
        on_contact_updated:
          type:
            - boolean
            - 'null'
          description: Trigger on contact updates
        on_contact_deleted:
          type:
            - boolean
            - 'null'
          description: Trigger on contact deletion
        on_contact_added_to_list:
          type:
            - boolean
            - 'null'
          description: Trigger when a contact is added to a list
        on_contact_removed_from_list:
          type:
            - boolean
            - 'null'
          description: Trigger when a contact is removed from a list
        on_contact_subscribed:
          type:
            - boolean
            - 'null'
          description: Trigger when a contact subscribes
        on_contact_unsubscribed:
          type:
            - boolean
            - 'null'
          description: Trigger when a contact unsubscribes
        on_contact_complained:
          type:
            - boolean
            - 'null'
          description: Trigger when a contact reports spam
        origins:
          type:
            - array
            - 'null'
          minItems: 1
          items:
            $ref: '#/components/schemas/WebhookOrigin'
          description: |
            The origins of the contact and suppression events that the webhook
            gets. Omit it or send `null` to keep the stored value; send all
            four origins to get every origin again. An empty array is refused
            with HTTP 400. An array that holds all four origins is saved as
            `null`, so that an origin added later reaches the webhook too.
        scope:
          type:
            - string
            - 'null'
          enum:
            - global
            - scoped
            - null
          description: Webhook scope. Omit or send null to keep the current scope.
        domains:
          type:
            - array
            - 'null'
          items:
            type: string
          description: |
            Omit or send null to leave domain associations unchanged. An array
            replaces associations when the resulting scope is `scoped`; `[]`
            explicitly clears them. Changing a global webhook to `scoped`
            requires a non-empty array in the same request and otherwise
            returns HTTP 400. Changing to `global` clears all associations;
            supplied domains are ignored when the resulting scope is global.
    Webhook:
      type: object
      properties:
        object:
          type: string
          enum:
            - webhook
          description: Object type identifier
        id:
          type: string
          format: uuid
          description: Unique identifier for the webhook
        created_at:
          type: string
          format: date-time
          description: When the webhook was created
        updated_at:
          type: string
          format: date-time
          description: When the webhook was last updated
        name:
          type: string
          description: Webhook name
        url:
          type: string
          format: uri
          description: Webhook URL
        enabled:
          type: boolean
          description: Whether the webhook is enabled
        on_reception:
          type: boolean
          description: Trigger on message reception
        on_delivered:
          type: boolean
          description: Trigger on message delivery
        on_transient_error:
          type: boolean
          description: Trigger on transient errors
        on_failed:
          type: boolean
          description: Trigger on permanent failures
        on_bounced:
          type: boolean
          description: Trigger on bounces
        on_suppressed:
          type: boolean
          description: Trigger on suppressions
        on_opened:
          type: boolean
          description: Trigger on opens
        on_clicked:
          type: boolean
          description: Trigger on clicks
        on_unsubscribed:
          type: boolean
          description: Trigger on unsubscribes
        on_complained:
          type: boolean
          description: Trigger on spam complaints
        on_suppression_created:
          type: boolean
          description: Trigger on suppression creation
        on_suppression_deleted:
          type: boolean
          description: Trigger on suppression deletion
        on_dns_error:
          type: boolean
          description: Trigger on DNS errors
        on_contact_created:
          type: boolean
          description: Trigger on contact creation
        on_contact_updated:
          type: boolean
          description: Trigger on contact updates
        on_contact_deleted:
          type: boolean
          description: Trigger on contact deletion
        on_contact_added_to_list:
          type: boolean
          description: Trigger when a contact is added to a list
        on_contact_removed_from_list:
          type: boolean
          description: Trigger when a contact is removed from a list
        on_contact_subscribed:
          type: boolean
          description: Trigger when a contact subscribes
        on_contact_unsubscribed:
          type: boolean
          description: Trigger when a contact unsubscribes
        on_contact_complained:
          type: boolean
          description: Trigger when a contact reports spam
        origins:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/WebhookOrigin'
          description: |
            The origins of the contact and suppression events that the webhook
            gets, or `null` for every origin. Message events and
            `domain.dns_error` have no origin, and the webhook always gets them.
        scope:
          type: string
          enum:
            - global
            - scoped
          description: Webhook scope
        domains:
          type: array
          items:
            type: string
          description: >-
            Domains this webhook applies to. Always present; global webhooks
            return an empty array.
        success_count:
          type: integer
          minimum: 0
          description: Number of successful calls
        error_count:
          type: integer
          minimum: 0
          description: Number of unsuccessful calls
        errors_since_last_success:
          type: integer
          minimum: 0
          description: |
            Number of consecutive failed calls. Reset to zero by the next
            successful call.
        last_request_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the webhook was last called
      required:
        - object
        - id
        - created_at
        - updated_at
        - name
        - url
        - enabled
        - on_reception
        - on_delivered
        - on_transient_error
        - on_failed
        - on_bounced
        - on_suppressed
        - on_opened
        - on_clicked
        - on_unsubscribed
        - on_complained
        - on_suppression_created
        - on_suppression_deleted
        - on_dns_error
        - on_contact_created
        - on_contact_updated
        - on_contact_deleted
        - on_contact_added_to_list
        - on_contact_removed_from_list
        - on_contact_subscribed
        - on_contact_unsubscribed
        - on_contact_complained
        - origins
        - scope
        - domains
        - success_count
        - error_count
        - errors_since_last_success
        - last_request_at
    ErrorResponse:
      type: object
      description: |
        Human-readable API error. The server currently sends no stable machine
        error code. In particular, clients must not parse `message` to
        distinguish IP-allow-list, scope, ownership, plan, self-lockout,
        suppression-duplicate, or other errors that share an HTTP status.
      additionalProperties: false
      required:
        - message
      properties:
        message:
          type: string
          description: Error description
      example:
        message: Error message
    WebhookOrigin:
      type: string
      enum:
        - recipient
        - api
        - dashboard
        - system
      description: |
        Who made a change that a contact or suppression event reports:
        `recipient` for the contact or recipient, through an unsubscribe link,
        a one-click unsubscribe, or a spam complaint; `api` for you, through
        the AhaSend API; `dashboard` for you, through the AhaSend dashboard;
        `system` for AhaSend, for example after a bounce, an expired message or
        an email validation, or when AhaSend support makes the change.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: aha-sk-64-CHARACTER-RANDOM-STRING
      description: |
        API key for authentication. Non-empty Security Requirement values are
        AhaSend API-key roles. Roles listed within one requirement object are
        jointly required; separate requirement objects are alternatives.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.