Skip to content

Repository files navigation

Resend Python SDK

Code style: blackBuildcodecovLicense: MITPyPIPyPI - Python Version


Installation

To install Resend Python SDK, simply execute the following command in a terminal:

pip install resend

Setup

First, you need to get an API key, which is available in the Resend Dashboard.

importresendimportosresend.api_key="re_yourkey"

Example

You can get an overview about all parameters in the Send Email API reference.

importosimportresendresend.api_key="re_yourkey"params: resend.Emails.SendParams= {
"from": "onboarding@resend.dev",
"to": ["delivered@resend.dev"],
"subject": "hi",
"html": "<strong>hello, world!</strong>",
"reply_to": "to@gmail.com",
"bcc": "bcc@resend.dev",
"cc": ["cc@resend.dev"],
"tags": [
{"name": "tag1", "value": "tagvalue1"},
{"name": "tag2", "value": "tagvalue2"},
],
}
email: resend.Emails.SendResponse=resend.Emails.send(params)
print(email)

Async Support

The SDK supports async operations via httpx. Install the async extra:

pip install resend[async]

Once installed, async methods (suffixed with _async) work automatically — no extra setup needed:

importasyncioimportresendresend.api_key="re_yourkey"asyncdefmain():
params: resend.Emails.SendParams= {
"from": "onboarding@resend.dev",
"to": ["delivered@resend.dev"],
"subject": "hi",
"html": "<strong>hello, world!</strong>",
}
email: resend.Emails.SendResponse=awaitresend.Emails.send_async(params)
print(email)
if__name__=="__main__":
asyncio.run(main())

Custom async client

To use a custom async HTTP client or configure options like timeouts, set resend.default_async_http_client:

importresendresend.api_key="re_yourkey"resend.default_async_http_client=resend.HTTPXClient(timeout=60)

About

Resend's official python sdk

Resources

Stars

128 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages