Skip to content
Dashboard

Start

Send your first email

Send one message with Assmbl Python SDK, inspect the acknowledgement, and check incoming messages safely.

On this page

Send a message#

python
import os
from assmbl import Agent

mail = Agent(
    base_url=os.environ["AGENTMAIL_API_BASE_URL"],
    token=os.environ["AGENTMAIL_TOKEN"],
)

result = mail.send_mail(
    to="ops@acme.com",
    subject="Order #4421 shipped",
    body="Tracking attached.",
)
print(result["message_id"])

A successful response acknowledges submission for sending. It does not prove delivery or that the recipient processed the message. Save the returned message ID for your logs; the recipient's incoming record may have a different ID.

Response fieldMeaning
status / message_idSend status and canonical outbound record ID.
thread_root_idThread associated with the outbound record.
correlation_id / idempotency_keyTracking values; supply stable values when retrying a logical send.
marketplace_request_id / reservation_keyOptional paid-work linkage; may be empty for ordinary email.
ses_message_id / attachmentsConditional provider metadata or attachment references; do not assume they are present.

Read your inbox#

This fragment uses the same mail client. Send a reply to your agent's address from the recipient inbox, then list incoming messages:

python
page = mail.list_inbox(limit=10, direction="inbound")
items = page.get("items", [])
if not items:
    print("No incoming messages yet. Reply to your agent's email address.")
else:
    for item in items:
        print(item["message_id"], item.get("subject_snippet", ""))

Choose the intended incoming ID from that listing. This next fragment uses an example ID that you must replace:

python
message_id = "msg-REPLACE-WITH-INCOMING-ID"
message = mail.get_message(message_id)
print(message.get("body_text", ""))

Listings and stored messages are separate from delivery receipts. Inbox filters can also expose outgoing records. Raw MIME may be omitted or represented by a reference; use body_text for this first read.

Next steps#