MessagePipedocs
SDKs

Python

messagepipe: typed responses, automatic retry, idempotency helper.

Install

pip install messagepipe
# or
uv add messagepipe

Initialise

import os
from messagepipe import MessagePipe

mp = MessagePipe(api_key=os.environ["MP_KEY"])

Send

send = mp.email.send(
    to="maya@example.com",
    subject="Welcome!",
    html="<p>Glad to have you.</p>",
)

print(send.id, send.status)  # msg_…  "queued"

Override the idempotency key when you have a natural stable id:

mp.email.send(
    to="...",
    template="welcome-email",
    data={"first_name": "Maya"},
    idempotency_key=f"order:{order_id}:confirmation",
)

Async client

import asyncio
from messagepipe import AsyncMessagePipe

async def main():
    async with AsyncMessagePipe(api_key=os.environ["MP_KEY"]) as mp:
        await mp.email.send(to="...", subject="Welcome!", html="<p>Hi</p>")

asyncio.run(main())

Catching errors

from messagepipe import MessagePipeError

try:
    mp.email.send(...)
except MessagePipeError as e:
    if e.code == "credits_exhausted":
        top_up_credits()
    else:
        raise