Skip to main content
AhaSend CLI webhooks commands let you manage, forward and trigger email event webhooks; this page lists their arguments and flags. For the complete local testing workflow, use the webhook testing guide. For dashboard setup, see the webhooks guide. Before running the examples, log in with an API key that has the read, write and delete webhook scopes for all domains, and replace YOUR_RESOURCE_ID with the ID of one of your webhooks. In the --domains examples, replace example.com and example.org with domains in your account; for any other domain, the API answers 400 invalid domain: <domain>.

Overview

Available subcommands:
  • list - List webhooks
  • create - Create a webhook
  • get - Get a webhook
  • update - Update a webhook
  • delete - Delete a webhook
  • listen - Listen for webhook events in real-time
  • trigger - Trigger webhook events for testing
webhooks get, webhooks update, webhooks delete and webhooks trigger take the webhook ID as their positional argument. A webhook ID that is not a UUID fails with exit code 4 before any request. Find IDs with ahasend webhooks list.

Event Types

--events on create, update, listen and trigger takes each event by its key or by its type, such as delivered or message.delivered. See the event reference for the payloads. --events can be given several times, and each value can hold several events separated by commas, so --events delivered,bounced is the same as --events delivered --events bounced. An unknown event, or the same event given twice (by its key, its type or both), fails with exit code 4 before any request.

List Webhooks

The API applies the --enabled filter, so a page holds up to --limit matching webhooks. Pages work as Lists and Pagination describes.

Create Webhook

  • --name and --url are required. When one is missing and stdin is a terminal, the command asks for it. With --non-interactive, or when stdin is not a terminal, a missing value fails with exit code 4.
  • On a terminal, without --events or --all-events, the command also asks for the events. A webhook created without events receives none until webhooks update gives it some.
  • --scope is global unless you set it. A global webhook receives the events of every domain. A scoped webhook receives only the events of the domains you give with --domains, which it requires. --domains without --scope scoped fails with exit code 4.
  • A webhook is enabled unless you set --enabled=false.
  • --url must be an HTTP or HTTPS URL with a host name and no user name or password. Use HTTPS in production: a plain HTTP URL for a host other than localhost or a loopback address prints a warning on stderr.
The output shows the webhook’s secret once. Save it to verify the webhook’s signatures; webhooks get does not show it.

Get Webhook

Show a webhook’s name, URL, status, events, scope and domains, its timestamps and its call counters (successful calls, failed calls, errors since the last success and the last call time). The output has no secret: the API returns it only when you create the webhook.

Update Webhook

Only the flags you set are sent; other settings stay as they are. Give at least one flag.
  • --events replaces the webhook’s events. --all-events selects every event type and --clear-events removes them all. These three flags cannot be combined.
  • --domains replaces the domains of a scoped webhook. The API ignores it on a global webhook unless you also give --scope scoped. --scope global --domains <domain> fails with exit code 4.
  • --scope global removes the domain restriction.

Delete Webhook

The command asks for confirmation first, as Prompts describes; --force (-f) skips it. A deleted webhook cannot be restored.

Listen for Events

webhooks listen streams webhook events to your terminal over a WebSocket connection, and can forward each event to a local endpoint. It prints events as text, whatever --output says, and runs until you press Ctrl+C or the connection closes.
The API key needs the webhooks:write:all scope. Without --webhook-id, the API creates a temporary webhook that stays after the command ends. Forwarded events are signed with a forwarding secret that the command prints when it connects. The webhook testing guide covers temporary webhooks, forwarding, signatures and exit codes.

Trigger Test Events

webhooks trigger asks the API to send test events to a webhook, so you can test your endpoint without waiting for real email events.
Give --events or --all-events, but not both; without either, the command fails with exit code 4. The output is the API’s message. A disabled webhook gets no events: the API answers that they are queued, and then drops them. Enable the webhook first with ahasend webhooks update YOUR_RESOURCE_ID --enabled.

Command Flags

These flags come from the CLI’s --help. All commands also accept the global flags.

webhooks create

webhooks delete

webhooks get

This command has no command-specific flags. See global flags.

webhooks list

webhooks listen

webhooks trigger

webhooks update