> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autosend.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate AutoSend with Bolt

> Send emails from your Bolt app using AutoSend's email API.

![Bolt](https://mintcdn.com/autosend-13920f5c/i6ZwoNOMtaBsEIWa/images/ai-tools/autosendxbolt.jpg?fit=max\&auto=format\&n=i6ZwoNOMtaBsEIWa\&q=85\&s=0f14c21c3b8eca19d0813db967c853e1)

Bolt is an AI-powered platform that lets you build full-stack web apps from natural language prompts. You
can integrate AutoSend into any Bolt project to send transactional emails like welcome emails,
password resets, order confirmations, and notifications.

## Prerequisites

> [card] [AutoSend Account](https://autosend.com/signup)
>
> Sign up for an AutoSend account to get started with sending emails.

> [card] [Verified Domain](https://docs.autosend.com/domain.md)
>
> Make sure you have a verified domain added in AutoSend.

> [card] [API Key](https://docs.autosend.com/api-keys.md)
>
> Create a new API key from your AutoSend dashboard.

> [card] [Bolt Account](https://bolt.new)
>
> Sign up for Bolt to start building apps.

## Integration

### 1. Prompt Bolt to integrate AutoSend

Copy and paste this prompt into Bolt's chat:

```text theme={null}
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": "recipient@example.com", "name": "Jane Doe" },
  "from": { "email": "hello@mail.yourdomain.com", "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 server-side API route or function that:
1. Reads AUTOSEND_API_KEY from environment variables
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
```

> [!NOTE]
>
> Bolt will generate the backend code and wire it into your app automatically.

### 2. Add your API key

Add your AutoSend API key as an environment variable in your Bolt project settings with the name `AUTOSEND_API_KEY`.

> [!NOTE]
>
> Get your API key from the [API Keys](https://autosend.com/account/api-key) 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](https://autosend.com/email-activities) in the AutoSend dashboard to confirm the email was delivered.

## Using Email Templates

If you have created [email templates](https://docs.autosend.com/transactional-emails/email-templates.md) in AutoSend, you can send emails using a `templateId` instead of inline HTML. Update the prompt to include:

```text theme={null}
Also support sending emails with a templateId and variables.

Example request body with template:
{
  "to": { "email": "recipient@example.com", "name": "Jane Doe" },
  "from": { "email": "hello@yourdomain.com", "name": "Your App Name" },
  "subject": "Welcome!",
  "templateId": "your_template_id",
  "dynamicData": {
    "firstName": "Jane",
    "loginLink": "https://yourapp.com/login"
  }
}
```

## Troubleshooting

> [accordion] Emails are not being sent
>
> Make sure your `AUTOSEND_API_KEY` is correctly added in your project's environment variables. Also verify that your sending domain is verified in AutoSend by checking **Settings > Domains** in your dashboard.

> [accordion] Getting a 401 Unauthorized error
>
> Double-check that your code is reading the API key from environment variables correctly. The Authorization header should be `Bearer YOUR_API_KEY` with no extra spaces or quotes.

> [accordion] Emails landing in spam
>
> 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](https://docs.autosend.com/domain.md) for details.

## Next Steps

> [card] [Email Templates](https://docs.autosend.com/transactional-emails/email-templates.md)
>
> Create reusable email templates with dynamic variables.

> [card] [Email Activity](https://docs.autosend.com/transactional-emails/email-activity.md)
>
> Monitor delivery status and engagement for all emails.

> [card] [API Reference](https://docs.autosend.com/api-reference/introduction.md)
>
> Full API documentation with all endpoints and parameters.

> [card] [Variables](https://docs.autosend.com/transactional-emails/variables.md)
>
> Personalize emails with dynamic variables.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.