Resend
Official Python SDK for the Resend transactional email API. Active, frequently updated. v2.0 (May 2024) added TypedDict-based type hinting. Module-level api_key pattern is the primary auth method. No class instantiation — all methods are called as class methods on resend.Emails, resend.Contacts, etc.
Warnings
- gotcha No client class to instantiate — resend.api_key is set at the module level, then all API calls are made as class methods (resend.Emails.send(), resend.Contacts.list(), etc.). Code from other SDKs that tries to instantiate a client object fails.
- gotcha The 'to' field must always be a list, even for a single recipient. Passing a string raises a validation error.
- gotcha The 'from' field must use a domain verified in the Resend dashboard. Using unverified domains or personal email addresses returns 403. The address 'onboarding@resend.dev' works only in testing with the test API key.
- gotcha Module-level api_key is global state — in multi-tenant or async applications with different API keys, setting resend.api_key is not thread-safe. Concurrent requests may use the wrong key.
Install
-
pip install resend
Imports
- resend
import resend import os resend.api_key = os.environ['RESEND_API_KEY'] params: resend.Emails.SendParams = { 'from': 'Acme <onboarding@resend.dev>', 'to': ['user@example.com'], 'subject': 'Hello', 'html': '<strong>Hello!</strong>' } email = resend.Emails.send(params) print(email['id'])
Quickstart
import os
import resend
resend.api_key = os.environ['RESEND_API_KEY']
params: resend.Emails.SendParams = {
'from': 'Acme <onboarding@resend.dev>',
'to': ['delivered@resend.dev'],
'subject': 'Hello from Resend',
'html': '<strong>It works!</strong>'
}
email = resend.Emails.send(params)
print(email['id']) # e.g. '49a3999c-0ce1-4ea6-ab68-b08b6e9a5fe2'