telnyx-email-curl
Send transactional email, batch sends, scheduled delivery, templates, email validation, and track delivery events. Use for notifications, alerts, and automated email workflows.
team-telnyx · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add team-telnyx/ai --skill telnyx-email-curl技能说明
name: telnyx-email-curl description: >- Send transactional email, batch sends, scheduled delivery, templates, email validation, and track delivery events. Use for notifications, alerts, and automated email workflows. metadata: author: telnyx product: email language: curl
Telnyx Email - curl
Installation
# curl is pre-installed on macOS, Linux, and Windows 10+
# jq is required for examples that capture IDs from responses:
# macOS: brew install jq
# Debian/Ubuntu: sudo apt-get install jq
Setup
export TELNYX_API_KEY="YOUR_API_KEY_HERE"
All examples below use $TELNYX_API_KEY for authentication.
Error Handling
All API calls can fail with network errors, rate limits (429), validation errors (400 or 422), or authentication errors (401). Preserve the response body so the Telnyx error code and detail remain available:
curl --fail-with-body \
-X POST \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": {"email": "sender@example.com", "name": "Example"},
"to": ["recipient@example.net"],
"subject": "Hello from Telnyx",
"text_body": "Your notification is ready."
}' \
"https://api.telnyx.com/v2/email_messages"
Common errors: 401 invalid credentials, 403 sender-domain eligibility or
verification failure, 404 resource not found, 413 body larger than
8,000,000 bytes, and 422 semantic validation or template-rendering failure.
A 429 is not necessarily a transient throughput limit: it can indicate a
reputation suspension or a daily policy limit. Inspect .errors[0].code and
.errors[0].detail before deciding whether to retry. See the full taxonomy in
references/api-details.md.
Important Notes
- Base URL: All paths in this skill are relative to
https://api.telnyx.com/v2. - Sender domain: The domain in
from.emailmust be authorized and ready for sending. A successful create response means accepted, queued, scheduled, or sandbox-created—not delivered. - Address input:
from,reply_to, and eachto/cc/bccitem accept either a string address or{ "email": "...", "name": "..." }. Recipients must be unique acrossto,cc, andbccafter case-insensitive normalization. - Body or template:
subjectis required unlesstemplate_idis supplied. Withtemplate_id, do not also sendsubject,html_body, ortext_body; pass Liquid values intemplate_variables. - Pagination: Core Email endpoints use
page_size(default 25, maximum 100) and the opaquepage_cursorreturned in.meta.page_cursor. Do not translate these names topage[size]orpage[cursor]. - Message listing:
GET /email_messagescurrently implements cursor pagination only; no message filters are exposed. Event and recipient list endpoints have their own filters.
Operational Caveats
- Scheduling is fail-open:
scheduled_atis the preferred field. If it is invalid or in the past, the API silently sends immediately. Validate the timestamp before sending and confirm the response status isscheduledwhen future delivery is required. The legacysend_atalias remains accepted; if both are present,scheduled_atwins. - Batch status:
POST /email_messages/batchalways returns207 Multi-Status, including when every item succeeds. It does not return 202. - Batch limit: A batch contains 1–50 messages. Split larger jobs and give each request its own idempotency key.
- Idempotency is endpoint-specific:
Idempotency-Keyis supported only onPOST /email_messages,POST /email_messages/batch,POST /email_templates,POST /email_validations, andPOST /email_validations/batch. Do not send it universally. - Sandbox behavior:
sandbox_mode: trueskips Kafka/MTA delivery, but still persists the message, emits a sandbox event, and creates a non-billable Email Detail Record (EDR). Batch-levelsandbox_modeoverrides every per-message value. - 429 requires classification: It can mean reputation suspension or a daily policy limit. Read the error code/detail; do not blindly back off and retry an account-policy failure.
- Attachments are in-band JSON: Put attachment content in the request as a Base64 string.
disposition: "inline"pluscontent_idsupports CID references. The whole request body is limited to 8,000,000 bytes (approximately 8 MB), including Base64 overhead. - Tags are not labels: Outbound
tagsare immutable billing/reporting attribution propagated to EDRs and Mission Control. Mailboxlabelsare mutable workflow state and are a different concept. - Threading is single-send only:
in_reply_to_message_id,reply_to_all, andforward_of_message_idare accepted by single send but not by batch send.in_reply_to_message_idandforward_of_message_idare mutually exclusive.
Reference Use Rules
Do not invent Telnyx parameters, enums, response fields, or webhook fields.
- If a parameter, enum, or response field is not shown inline, read references/api-details.md before writing the request or handler.
- Before using an operation in
## Additional Operations, read the parameter reference and the response schemas. - Before matching webhook fields or event names, read the webhook payload reference. Pollable and subscribable event enums are intentionally different.
- Treat the two delete-message routes marked not yet available as unreachable even though they appear in the OpenAPI contract.
Core Tasks
Send an email
Primary outbound transactional-email flow.
POST /v2/email_messages
| Parameter | Type | Required | Description |
|---|---|---|---|
from | string or email-address object | Yes | Sender address; ob |