---
title: FastAPI
description: Learn how to integrate Reloop with FastAPI to send emails.
icon: siFastapi
---
> For the complete documentation index, see [llms-docs.txt](/llms-docs.txt) or the site index [llms.txt](/llms.txt). Full docs corpus: [llms-full-docs.txt](/llms-full-docs.txt). Prefer markdown URLs (append `.md`) for agent consumption. Product skill: [skill.md](/skill.md).


# FastAPI Integration

Reloop can be easily integrated into any FastAPI application.

## Installation

Install the official Python SDK:

```bash
pip install reloop-email
```

## Setup Environment Variables

Add your API key to your environment:

```bash
export RELOOP_API_KEY="re_your_api_key_here"
```

## Sending an Email

Here is a simple FastAPI route that sends an email:

```python
import os
from fastapi import FastAPI, HTTPException
from reloop_email import Reloop

app = FastAPI()
reloop = Reloop(api_key=os.environ.get("RELOOP_API_KEY"))

@app.post("/send-email")
async def send_email():
    try:
        result = reloop.mail.send({
            "from": "onboarding@reloop.sh",
            "to": "delivered@resend.dev",
            "subject": "Hello from FastAPI",
            "html": "<p>Congrats on sending your first email via Reloop from FastAPI!</p>",
        })
        if result.email_error:
            raise result.email_error
        return result.response
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))
```
