The Client is the main entry point for interacting with the Resend API. It manages authentication, HTTP communication, and provides access to all service endpoints.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/resend/resend-go/llms.txt
Use this file to discover all available pages before exploring further.
Client Structure
TheClient struct contains all the service interfaces for interacting with different Resend API endpoints:
Service for sending, retrieving, and managing emails
Service for sending batch emails
Service for managing API keys
Service for managing domains
Service for managing audience segments
Service for managing contacts
Service for managing broadcasts
Service for managing email templates
Service for managing topics
Service for managing webhooks
The API key used for authentication
The base URL for API requests (defaults to
https://api.resend.com/)The user agent string sent with requests
Constructors
NewClient
Your Resend API key. The function automatically trims whitespace and quotes.
A configured Resend client instance ready to use
NewCustomClient
Custom HTTP client for making requests. If
nil, uses the default client with a 1-minute timeout.Your Resend API key
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