Courier (trycourier)

7.9.0 · active · verified Fri Mar 27

Python SDK for Courier notification API (multi-channel: email, SMS, push, in-app). Current version is 7.9.0. Install name is trycourier (pip install trycourier) but import name changed to courier in v5+ (from courier.client import Courier). The SDK was completely rewritten with Fern code generation in v5, breaking all v4 code.

Warnings

Install

Imports

Quickstart

v5+ API. Install is trycourier, import is courier. Sync and async clients available.

# pip install trycourier
from courier.client import Courier
import courier

client = Courier(
    authorization_token='YOUR_COURIER_AUTH_TOKEN'
    # or set env var COURIER_AUTH_TOKEN
)

# Send using a template (workflow)
response = client.send(
    message=courier.TemplateMessage(
        template='your-template-id',  # template ID from Courier dashboard
        to=courier.UserRecipient(
            email='user@example.com',
            user_id='user-123'
        ),
        data={
            'name': 'Alice',
            'action_url': 'https://yourapp.com'
        }
    )
)
print('Request ID:', response.request_id)

# Async client
from courier.client import AsyncCourier
import asyncio

async def send():
    async with AsyncCourier(authorization_token='YOUR_TOKEN') as client:
        await client.send(message=courier.TemplateMessage(
            template='your-template-id',
            to=courier.UserRecipient(email='user@example.com')
        ))

asyncio.run(send())

view raw JSON →