Skip to main content
v0
v0 is Vercel’s AI-powered tool for generating UI components and full-stack applications. You can integrate AutoSend into your v0 project to send transactional emails like welcome emails, password resets, order confirmations, and notifications.

Prerequisites

Integration

1

Prompt v0 to integrate AutoSend

Copy and paste this prompt into v0’s chat:
Integrate AutoSend email API for sending transactional emails.

API Details:
- Base URL: https://api.autosend.com/v1
- Auth: Bearer token using API key stored in environment variable AUTOSEND_API_KEY
- Endpoint: POST /mails/send
- Content-Type: application/json

Request body format:
{
  "to": { "email": "[email protected]", "name": "Jane Doe" },
  "from": { "email": "[email protected]", "name": "Your App Name" },
  "subject": "Your subject line",
  "html": "<h1>Hello!</h1><p>Your email content here.</p>"
}

Response format:
{
  "success": true,
  "data": {
    "emailId": "698afb75ff4bc5466e3a797a",
    "message": "Email queued successfully.",
    "totalRecipients": 1
  }
}

Create a Next.js API route (app/api/send-email/route.ts) that:
1. Reads AUTOSEND_API_KEY from process.env
2. Accepts to, from, subject, and html in the request body
3. Calls the AutoSend API with Bearer token auth
4. Returns the response to the client

The "from" email must use a domain verified in AutoSend.

Docs: https://docs.autosend.com/quickstart/email-using-api
v0 will generate the API route and any UI components needed for your email flow.
2

Add your API key

When you deploy your v0 project to Vercel, add AUTOSEND_API_KEY as an environment variable in your Vercel project settings.For local development, add it to your .env.local file:
.env.local
AUTOSEND_API_KEY=your_api_key_here
Get your API key from the API Keys page in your AutoSend dashboard.
3

Test your integration

Trigger the email flow in your app (for example, submitting a contact form). Check your Email Activity in the AutoSend dashboard to confirm the email was delivered.

Using Email Templates

If you have created email templates in AutoSend, you can send emails using a templateId instead of inline HTML. Update the prompt to include:
Also support sending emails with a templateId and variables.

Example request body with template:
{
  "to": { "email": "[email protected]", "name": "Jane Doe" },
  "from": { "email": "[email protected]", "name": "Your App Name" },
  "subject": "Welcome!",
  "templateId": "your_template_id",
  "dynamicData": {
    "firstName": "Jane",
    "loginLink": "https://yourapp.com/login"
  }
}

Troubleshooting

Make sure your AUTOSEND_API_KEY is set in your Vercel environment variables (for production) or .env.local (for local development). Also verify that your sending domain is verified in AutoSend.
Double-check that the API route is reading the API key correctly from process.env.AUTOSEND_API_KEY. The Authorization header should be Bearer YOUR_API_KEY.
Make sure you have completed domain verification including SPF, DKIM, and DMARC records. We recommend using a subdomain like mail.yourdomain.com for sending. See our domain setup guide for details.

Next Steps