Skip to content
Splashify Pro
Email docsEmail

Python Quickstart

This guide uses requests. Prefer a package? See the Python SDK.

bash
pip install requests
export SPLASHIFY_API_KEY="pk_live_..."
python
import os, requests

r = requests.post(
    "https://api.splashifypro.com/api/v1/partner/email/send",
    headers={
        "Authorization": f"Bearer {os.environ['SPLASHIFY_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "from": "[email protected]",
        "to": ["[email protected]"],
        "subject": "Welcome to our app",
        "html_body": "<h1>Welcome 👋</h1>",
        "text_body": "Welcome.",
    },
)
r.raise_for_status()
print(r.json()["results"][0]["message_id"])

Handling errors

Use this in place of r.raise_for_status():

python
if not r.ok:
    raise RuntimeError(f"{r.status_code}: {r.json().get('message')}")

Async (httpx)

bash
pip install httpx
python
import asyncio, os, httpx

async def send():
    async with httpx.AsyncClient() as c:
        r = await c.post(
            "https://api.splashifypro.com/api/v1/partner/email/send",
            headers={"Authorization": f"Bearer {os.environ['SPLASHIFY_API_KEY']}"},
            json={
                "from": "[email protected]",
                "to": ["[email protected]"],
                "subject": "Welcome",
                "text_body": "Welcome.",
            },
        )
        r.raise_for_status()
        return r.json()

print(asyncio.run(send()))

What's next