Send a text message
send_smsSends an outbound SMS to an E.164 number with required recipient consent; supports sender ID selection, marketing vs informational texts, and idempotency keys for safe retries.
Instructions
Send an outbound SMS.
``to`` must be E.164 (e.g. ``+14155551234``). ``body`` is the
message text. With no ``from_``: destinations where the sender-ID
carrier delivers a dynamic alphanumeric sender ID unchanged (about
110 countries, see core/hailhq/core/sender_id_corridors.py) use
your organization's sender ID
(or ``HAIL``, the platform default); Australia (+61) may use
``HAIL`` instead; every other destination,
including the US and Canada,
uses your organization's oldest active SMS-capable number and the
API returns 422 when there is none.
SMS never uses the shared voice-call pool.
``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 text 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 texts (this
additionally requires a non-empty ``consent_source``) — leave as
the default ``"informational"`` for transactional/service texts.
``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.
Example:
send_sms(to="+14155551234", body="Your order shipped!",
recipient_consent=True)
Returns the ``SmsResponse`` dict (id, status, from_e164,
to_e164, segment_count, ...). On failure returns
``{"error": "<message>"}`` instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | ||
| body | Yes | ||
| from_ | No | ||
| metadata | No | ||
| message_type | No | informational | |
| consent_source | No | ||
| idempotency_key | No | ||
| recipient_consent | Yes | ||
| consent_obtained_at | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||