Skip to main content
Replit
Replit is a collaborative, AI-powered development platform that lets you build and deploy apps from your browser. You can integrate AutoSend into any Replit project to send transactional emails like welcome emails, password resets, order confirmations, and notifications.

Prerequisites

Integration

1

Add your API key as a secret

  1. In your Replit project, open the Secrets tab (lock icon in the sidebar)
  2. Add a new secret with the key 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.
2

Prompt Replit Agent to integrate AutoSend

Copy and paste this prompt into Replit’s AI 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 server-side endpoint 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
Replit Agent will generate the backend code and connect it to your app.
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 correctly added in Replit Secrets. Also verify that your sending domain is verified in AutoSend by checking Settings > Domains in your dashboard.
Double-check that your code 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.

Next Steps