Getting started overview

This guide provides a structured approach to initiating development with Resend, a platform designed for sending transactional emails. The process involves account creation, domain verification, API key generation, and executing a foundational email send request. Resend focuses on developer experience, offering SDKs for multiple programming languages and first-class integration with React Email for templating Resend React Email documentation.

The initial setup ensures that your sending domain is authenticated, preventing email delivery issues and adhering to email sender best practices like DMARC. After domain verification, an API key acts as the credential for all programmatic interactions with the Resend API. This key should be managed securely, typically as an environment variable, to prevent unauthorized access to your sending capabilities.

Here is a quick reference for the steps involved:

Step What to do Where
1. Create Account Sign up for a new Resend account. Resend Sign-up Page
2. Add Domain Register the domain from which you will send emails. Resend Dashboard > Domains
3. Verify Domain Add DNS records (DKIM, SPF, DMARC) to your domain registrar. Your Domain Registrar's DNS Settings
4. Generate API Key Create a new API key for authentication. Resend Dashboard > API Keys
5. Install SDK Install the appropriate Resend SDK for your programming language. Your project's package manager (e.g., npm, pip)
6. Send First Email Write code to send a test email using the API key and SDK. Your development environment

Create an account and get keys

Before sending emails, you must establish an account with Resend and configure your sending domain. This process ensures authenticity and improves email deliverability.

1. Sign up for a Resend Account

Navigate to the official Resend sign-up page and complete the registration process. Resend offers a free tier that includes 3,000 emails per month, with a daily limit of 100 emails and support for one domain, which is suitable for initial development and testing Resend pricing details.

2. Add and Verify Your Sending Domain

After signing up, access your Resend dashboard. Locate the 'Domains' section and add the domain you intend to use for sending emails. Resend will provide a set of DNS records (typically DKIM, SPF, and sometimes DMARC) that you must add to your domain registrar's DNS settings. These records are critical for email authentication and preventing your emails from being marked as spam. For example, DKIM (DomainKeys Identified Mail) is a method for email senders to digitally sign outgoing email, verifying the sender's identity and helping to prevent email spoofing DKIM specification (RFC 6376). The verification process can take some time, ranging from a few minutes to several hours, depending on your domain registrar.

3. Generate an API Key

Once your domain is successfully verified, proceed to the 'API Keys' section within your Resend dashboard. Create a new API key. It is recommended to name your API key descriptively (e.g., development-key, production-backend) to easily identify its purpose. Resend will display the API key only once upon creation. Copy this key immediately and store it securely. Best practices dictate storing API keys as environment variables rather than hardcoding them directly into your application code.

Your first request

With your account configured, domain verified, and API key generated, you can now send your first email. This example uses the Node.js SDK, but similar steps apply to other supported SDKs (Python, Ruby, PHP, Go).

1. Install the Resend SDK

Open your project's terminal and install the Resend Node.js SDK:

npm install resend
# or
yarn add resend

2. Configure Your API Key

Set your Resend API key as an environment variable. For development, you might use a .env file and a package like dotenv. For production, use your hosting provider's environment variable management system.

# .env file example
RESEND_API_KEY=re_YOUR_API_KEY_HERE

3. Write the Code to Send an Email

Create a new file, for instance, send-email.js, and add the following code:

import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);

async function sendTestEmail() {
  try {
    const { data, error } = await resend.emails.send({
      from: '[email protected]', // Must be a verified domain or resend.dev
      to: '[email protected]', // Replace with your recipient email
      subject: 'Hello from Resend!',
      html: '<strong>It works!</strong> This is your first email sent with Resend.',
    });

    if (error) {
      console.error({ error });
      return;
    }

    console.log({ data });
  } catch (error) {
    console.error('An unexpected error occurred:', error);
  }
}

sendTestEmail();

Important considerations:

4. Run the Code

Execute the script from your terminal:

node send-email.js

Upon successful execution, you should see a log in your console indicating the email ID and confirmation. Check the recipient's inbox for the email titled "Hello from Resend!".

Common next steps

After successfully sending your first email, consider these common next steps to further integrate Resend into your application:

  • Integrate with React Email: Resend offers deep integration with React Email, allowing you to design email templates using React components. This provides a modern, component-based approach to email templating Resend React Email integration guide.
  • Implement Webhooks: Set up webhooks to receive real-time notifications about email delivery statuses (e.g., delivered, opened, clicked, bounced). This is crucial for tracking email performance and building robust communication flows Resend webhooks documentation.
  • Add More Domains: If your application needs to send emails from multiple domains, repeat the domain addition and verification process for each one in your Resend dashboard.
  • Manage Audiences and Broadcasts: For marketing emails or sending to groups of users, explore Resend's Audience and Broadcast features. These allow for managing contact lists and sending bulk emails efficiently.
  • Monitor Deliverability: Regularly review your Resend dashboard's analytics to monitor email deliverability rates, open rates, and click rates. Utilize features like DMARC monitoring to maintain a healthy sender reputation.
  • Explore Advanced Sending Options: Investigate options like batch sending for efficiency, scheduled sends for precise timing, and custom headers for specific email configurations Resend advanced sending options.

Troubleshooting the first call

If your first email request encounters issues, review these common troubleshooting points:

  • API Key Issues:
    • Incorrect Key: Double-check that the RESEND_API_KEY environment variable is correctly set and matches the key generated in your Resend dashboard. Ensure there are no leading or trailing spaces.
    • Key Permissions: Verify that the API key has the necessary permissions to send emails. By default, newly generated keys usually have full access, but custom permissions might restrict functionality.
  • Domain Verification:
    • Unverified Domain: The most frequent issue is an unverified sending domain. Ensure all required DNS records (DKIM, SPF) are correctly added to your domain registrar and have propagated. The Resend dashboard will indicate the verification status.
    • Incorrect 'From' Address: The from email address in your code must correspond to a verified domain in your Resend account. If testing, remember that [email protected] is a valid temporary sender.
  • Recipient Address:
    • Invalid Recipient: Ensure the to email address is valid and correctly formatted.
    • Blocked Recipient: Check if the recipient email address is on any blocklists or suppression lists within your Resend account.
  • Network or Environment Issues:
    • Internet Connection: Confirm your development environment has an active internet connection to reach Resend's API endpoints.
    • Firewall/Proxy: If you are within a corporate network, ensure that firewalls or proxies are not blocking outbound connections to Resend's API.
  • SDK and Dependencies:
    • Outdated SDK: Ensure your Resend SDK is up to date. Run npm update resend (or equivalent for your package manager).
    • Dependency Conflicts: Check for any dependency conflicts in your project that might interfere with the SDK.
  • Error Messages:
    • Carefully read any error messages returned by the API or logged by the SDK. These messages often provide specific clues about the problem. Consult the Resend API error reference for detailed explanations of error codes.