# Send emails with FastAPI

## Prerequisites

Before you start, you'll need:

- A Resend [API key](/guides/get-started-create-an-api-key)
- A [verified domain](/guides/get-started-add-a-domain)

## Guide

:::::steps
::::step{title="Install"}
Get the Resend Python SDK.

:::code-group
```bash Pip theme={"theme":{"light":"github-light","dark":"vesper"}}
pip install resend
```
:::
::::

:::step{title="Send email using HTML"}
The easiest way to send an email is by using the `html` parameter.

```py main.py theme={"theme":{"light":"github-light","dark":"vesper"}}
import os
from typing import Dict
from fastapi import FastAPI
import resend

resend.api_key = os.environ["RESEND_API_KEY"]

app = FastAPI()

@app.post("/")
def send_mail() -> Dict:
    params: resend.Emails.SendParams = {
        "from": "Acme <onboarding@resend.dev>",
        "to": ["delivered@resend.dev"],
        "subject": "hello world",
        "html": "<strong>it works!</strong>",
    }
    email: resend.Emails.SendResponse = resend.Emails.send(params)
    return email
```
:::
:::::

## Examples

::::card-grid
:::card{title="FastAPI App" href="https://github.com/resend/resend-examples/blob/main/python-resend-examples/examples/fastapi_app.py" icon="arrow-up-right-from-square"}
Full FastAPI web application
:::

:::card{title="Basic Send" href="https://github.com/resend/resend-examples/blob/main/python-resend-examples/examples/basic_send.py" icon="arrow-up-right-from-square"}
Basic email sending
:::

:::card{title="Attachments" href="https://github.com/resend/resend-examples/blob/main/python-resend-examples/examples/with_attachments.py" icon="arrow-up-right-from-square"}
Send emails with file attachments
:::

:::card{title="Templates" href="https://github.com/resend/resend-examples/blob/main/python-resend-examples/examples/with_template.py" icon="arrow-up-right-from-square"}
Send emails using Resend hosted templates
:::

:::card{title="Scheduling" href="https://github.com/resend/resend-examples/blob/main/python-resend-examples/examples/scheduled_send.py" icon="arrow-up-right-from-square"}
Schedule emails for future delivery
:::

:::card{title="Audiences" href="https://github.com/resend/resend-examples/blob/main/python-resend-examples/examples/audiences.py" icon="arrow-up-right-from-square"}
Manage contacts and audiences
:::

:::card{title="Domains" href="https://github.com/resend/resend-examples/blob/main/python-resend-examples/examples/domains.py" icon="arrow-up-right-from-square"}
Create and manage sending domains
:::

:::card{title="Inbound Webhooks" href="https://github.com/resend/resend-examples/blob/main/python-resend-examples/examples/inbound.py" icon="arrow-up-right-from-square"}
Receive and process inbound emails
:::

:::card{title="Double Opt-in" href="https://github.com/resend/resend-examples/blob/main/python-resend-examples/examples/double_optin_subscribe.py" icon="arrow-up-right-from-square"}
Double opt-in subscription flow
:::
::::

## Related pages

- [Send emails with Python](./get-started-send-with-python.md)
- [Send emails with Flask](./get-started-send-with-flask.md)
- [Send emails with Django](./get-started-send-with-django.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
