Client Structure
TheClient struct contains all the service interfaces for interacting with different Resend API endpoints:
*EmailsSvcImpl
Service for sending, retrieving, and managing emails
BatchSvc
Service for sending batch emails
ApiKeysSvc
Service for managing API keys
DomainsSvc
Service for managing domains
SegmentsSvc
Service for managing audience segments
*ContactsSvcImpl
Service for managing contacts
BroadcastsSvc
Service for managing broadcasts
TemplatesSvc
Service for managing email templates
TopicsSvc
Service for managing topics
WebhooksSvc
Service for managing webhooks
string
The API key used for authentication
*url.URL
The base URL for API requests (defaults to
https://api.resend.com/)string
The user agent string sent with requests
Constructors
NewClient
string
required
Your Resend API key. The function automatically trims whitespace and quotes.
*Client
A configured Resend client instance ready to use
NewCustomClient
*http.Client
Custom HTTP client for making requests. If
nil, uses the default client with a 1-minute timeout.string
required
Your Resend API key
*Client
A configured Resend client instance with custom HTTP settings
Configuration
Base URL
The base URL for API requests can be configured using theRESEND_BASE_URL environment variable. This is useful for testing or when using a proxy.
Default: https://api.resend.com/
Example
HTTP Client Configuration
The default HTTP client has a 1-minute timeout. You can customize this usingNewCustomClient:
Context Support
All API methods in the Resend Go SDK support context for cancellation, timeouts, and passing request-scoped values. Example with timeoutUser Agent
The SDK automatically sets a user agent header in the formatresend-go/{version}. The current version is 3.1.1.
Error Handling
The client automatically handles errors from the API and returns appropriate error types:- Rate Limit Errors:
RateLimitErrorwith retry information - Invalid Request Errors: Standard errors for validation failures
- Other Errors: Generic errors with message from the API
Next Steps
Send Emails
Learn how to send emails using the SDK
Batch Emails
Send multiple emails in a single request
Manage Domains
Configure and verify your sending domains
Email Templates
Create and manage email templates