Transactional email with templates, domain verification and delivery tracking.
Overview
Base path:
/v1/emailPython namespace:
infra.emailtext
# Python
from infrai import infra
# TypeScript
import { InfraiClient } from "@infrai/sdk";
const client = new InfraiClient({ apiKey: process.env.INFRAI_API_KEY! });
// → client.emailMethods
email.send
POST /v1/email/send
Send a transactional email; supports templates, attachments and BYOK vendors.
Python
python
infra.email.send(to, subject, body, *, from_=None, html=False, cc=None, bcc=None, template_id=None, template_vars=None, attachments=None, vendor=None, idempotency_key=None)TypeScript
typescript
client.email.send(opts: EmailSendOptions): Promise<EmailRecord>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
to | string | string[] | Required | Recipient address or list of addresses. |
subject | string | Required | Subject line. |
text | string | Optional | Plain-text body. |
html | string | Optional | HTML body. |
from | string | Optional | Sender address (requires a verified domain). |
cc | string[] | Optional | Carbon-copy addresses. |
bcc | string[] | Optional | Blind carbon-copy addresses. |
template_id | string | Optional | Template id to render instead of a body. |
template_vars | Record<string, unknown> | Optional | Variables passed to the template. |
attachments | Array<{ filename, content, mime? }> | Optional | Files to attach. |
vendor | string | Optional | Pin a specific vendor instead of auto-routing. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
EmailRecord { email_id, state, to, subject, vendor, created_at }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
sent = infra.email.send(
to="alice@example.com",
subject="Welcome to Infrai",
body="<h1>Welcome!</h1><p>Your account is ready.</p>",
html=True,
)
print("message_id:", sent.get("message_id") or sent.get("id"))email.get
GET /v1/email/{id}
Fetch a single email record by id.
Python
python
infra.email.get(id=email_id)TypeScript
typescript
client.email.get(emailId: string): Promise<EmailRecord>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | The email record id. |
Returns
EmailRecordExample
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
rec = infra.email.get(id="msg_...")
print("state:", rec.get("state"), "| to:", rec.get("to"))email.list
GET /v1/email
List email records with state and pagination filters.
Python
python
infra.email.list(project_id=None, state=None, limit=None, cursor=None)TypeScript
typescript
client.email.list(query): Promise<{ items, next_cursor? }>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
state | string | Optional | Filter by record state. |
limit | number | Optional | Maximum items to return. |
cursor | string | Optional | Pagination cursor. |
Returns
{ items: EmailRecord[], next_cursor? }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
page = infra.email.list(state="delivered", limit=20)
for e in page.get("items", []):
print(e.get("email_id"), e.get("state"))email.suppress
POST /v1/email/suppress
Add an address to the suppression list.
Python
python
infra.email.suppress(...)TypeScript
typescript
// see ROUTES["email.suppress"]Returns
SuppressionRecordExample
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
s = infra.email.suppress(email="bounce@example.com", reason="hard_bounce")
print("suppressed:", s.get("email") or s.get("ok"))email.domain.verify
POST /v1/email/domains/verify
Verify a sending domain and return required DNS records.
Python
python
infra.email.domain.verify(domain=...)TypeScript
typescript
client.email.verifyDomain(domain: string): Promise<{ verified, records }>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
domain | string | Required | The domain to verify. |
Returns
{ verified, records: Array<{ type, name, value }> }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
res = infra.email.domain.verify(domain="mail.example.com")
print("verified:", res.get("verified"))
for rec in res.get("records", []):
print(" ", rec.get("type"), rec.get("name"), "->", rec.get("value"))