Send an email
send_emailSend an outbound email through your configured SES sender.
Instructions
Send an outbound email through your configured SES sender.
``to`` is a non-empty list of RFC-style email addresses. At
least one of ``body_text`` / ``body_html`` is required (both
is fine — multipart-alternative). Prefer including
``body_html``: open and click tracking only works for emails
with an HTML body. A plain-text-only email still gets sent,
delivered, and bounce events, but opens and clicks are never
tracked. ``cc``, ``bcc``, and
``reply_to`` are optional and follow the usual mail
conventions. Hail sets no ``reply_to`` of its own — to have
replies reach the human running this session, call ``whoami``
and pass their ``email``.
``recipient_consent`` is required and must be the JSON boolean
``true`` (strings and numbers are refused): attest that you (the caller
triggering this request) have obtained the lawful consent needed
to email this recipient. The API rejects the request (422) if
this is not ``true`` — Hail does not verify consent for you. Set
``message_type="marketing"`` for promotional email (this
additionally requires a non-empty ``consent_source`` describing
how/where consent was obtained) — leave as the default
``"informational"`` for transactional/service email.
``from_`` is optional only while the workspace has one verified
sender identity. With several, omitting it returns 422 listing
them — call ``list_email_domains`` and pass one. With none, the
server auto-mints a per-org hail-mail address of the form
``<user>+<org>@<base>`` if the operator configured
``HAIL_MAIL_BASE_DOMAIN`` (the ``<org>`` part is derived from your
organization id; the ``<user>`` part comes from ``HAIL_MAIL_FROM``
/ ``HAIL_MAIL_DEFAULT_USER_PREFIX``, or an explicit row created
via ``POST /email-domains``). When supplied, ``from_`` must match
a verified row already in ``email_domains`` (register one with
the website console or ``POST /email-domains``).
``from_name`` is an optional display name rendered on the
From: header ("Acme Billing <billing@acme.com>"). Control
characters are rejected.
``metadata`` is free-form JSON attached to the email record.
``idempotency_key`` defaults to a fresh UUID and is returned
in the response under ``idempotency_key`` — pass the same
value on a retry to replay rather than re-send. A new key
is a new message.
``attachment_ids`` are ids returned by ``upload_email_attachment``
— upload a file first, then pass its id(s) here to attach it.
Example:
send_email(to=["alice@example.com"],
subject="Welcome",
recipient_consent=True,
body_text="Thanks for signing up.")
Returns the ``EmailResponse`` dict (id, status, from_address,
to_addresses, sent_at, provider_message_id, ...). On failure
returns ``{"error": "<message>"}`` instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cc | No | ||
| to | Yes | ||
| bcc | No | ||
| from_ | No | ||
| subject | Yes | ||
| metadata | No | ||
| reply_to | No | ||
| body_html | No | ||
| body_text | No | ||
| from_name | No | ||
| message_type | No | informational | |
| attachment_ids | No | ||
| consent_source | No | ||
| idempotency_key | No | ||
| recipient_consent | Yes | ||
| consent_obtained_at | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||