Prerequisites
Verified Domain
Make sure you have a verified domain added in AutoSend to send emails from.
API Key
Create an API key to authenticate your SDK requests.
Installation
Install the SDK using your preferred package manager:Quick Start
Initialize the SDK with your API key:Configuration Options
The SDK accepts optional configuration parameters:| Option | Type | Default | Description |
|---|---|---|---|
baseUrl | string | https://api.autosend.com/v1 | API base URL |
timeout | number | 30000 | Request timeout in milliseconds |
maxRetries | number | 3 | Number of retry attempts for failed requests |
debug | boolean | false | Enable debug logging |
Sending Emails
Plain Text Email
HTML Email
Using Templates
Send emails using a pre-built template with dynamic variables:Learn more about creating and managing templates in the Email
Templates documentation.
Bulk Emails
Send multiple emails in a single API call:Sync user data to Contacts on AutoSend
The SDK lets you create, retrieve, update, and delete contacts directly from your code—useful for syncing users from your app, updating custom fields, or managing unsubscribe preferences.Create a Contact
Add a new contact to your AutoSend account. You can assign them to one or more lists and include custom fields for segmentation.Get a Contact
Retrieve a contact’s details by their ID. This returns their email, name, list memberships, custom fields, and subscription status.Create or Update a Contact
Useupsert when you’re not sure if a contact already exists. If the email exists, it updates the contact; otherwise, it creates a new one. This is ideal for syncing users from your application.
Delete a Contact
Permanently remove a contact from your account. This removes them from all lists and deletes their data.Learn more about lists, segments, and custom fields in the
Contacts documentation.
Resend Adapter
If you’re migrating from Resend, the SDK provides a compatibility adapter that mirrors the Resend API patterns:The Resend adapter uses
properties instead of customFields for contacts, and remove()
instead of delete() to match Resend’s API conventions.TypeScript Support
The SDK is written in TypeScript and provides full type definitions out of the box. All methods, parameters, and responses are fully typed for better developer experience and IDE support.Troubleshooting
Authentication failed
Authentication failed
Possible causes:
- Invalid or expired API key
- API key not included in the request
- Verify your API key in the Dashboard
- Ensure you’re passing the API key correctly when initializing the SDK
- Check that your API key hasn’t been revoked
Request timeout
Request timeout
Possible causes:
- Network connectivity issues
- Request payload too large
- Increase the timeout in configuration options
- Check your network connection
- For bulk emails, reduce the batch size
Domain not verified
Domain not verified
Possible causes:
- Sending from an unverified domain
- DNS records not properly configured
- Verify your sending domain in the Dashboard
- Ensure SPF and DKIM records are properly set up
- Check the Domain Configuration guide
Rate limit exceeded
Rate limit exceeded
Possible causes:
- Too many requests in a short period
- Implement exponential backoff in your application
- Use bulk sending instead of individual requests
- Check the Rate Limits documentation for your plan’s limits