Skip to main content

Overview

Lovable is an AI-powered platform that lets you build full-stack web apps from natural language prompts. You can integrate AutoSend into any Lovable project to send transactional emails like welcome emails, password resets, order confirmations, and notifications.
Lovable
AutoSend works with Lovable through its REST API. Since the API requires an API key, Lovable will use Supabase Edge Functions to keep your credentials secure.

Prerequisites

Integration

1

Connect Supabase to your Lovable project

Lovable uses Supabase Edge Functions to securely handle API keys. If you haven’t connected Supabase yet, click the Supabase icon in your Lovable project and follow the authorization steps.
2

Add your AutoSend API key as a secret

  1. In your Lovable project, go to Supabase > Secrets
  2. Add a new secret with the name AUTOSEND_API_KEY
  3. Paste your AutoSend API key as the value
Get your API key from the API Keys page in your AutoSend dashboard.
3

Prompt Lovable to integrate AutoSend

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

API Details:
- Base URL: https://api.autosend.com/v1
- Auth: Bearer token using the AUTOSEND_API_KEY secret
- 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 Supabase Edge Function called "send-email" that:
1. Reads AUTOSEND_API_KEY from environment secrets
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
Lovable will generate a Supabase Edge Function and wire it into your app automatically.
4

Test your integration

Once Lovable finishes generating the code, 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"
  }
}

Example Use Cases

Here are some common ways to use AutoSend in your Lovable apps:
  • Contact forms that send a confirmation email to the user and a notification to your team
  • User signup flows with welcome emails or email verification
  • Order confirmations and shipping notifications for e-commerce apps
  • Password reset emails triggered from your auth flow
  • Newsletter signups that send a double opt-in confirmation

Troubleshooting

Make sure your AUTOSEND_API_KEY is correctly added in Supabase Secrets. Also verify that your sending domain is verified in AutoSend by checking Settings > Domains in your dashboard.
Double-check that the Edge Function is reading the secret correctly. The Authorization header should be Bearer YOUR_API_KEY with no extra spaces or quotes.
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.
Lovable may sometimes show false positive build errors. Always test your app live by triggering the actual email flow. If the Edge Function deploys successfully in Supabase, the integration is likely working.

Next Steps