Skip to main content

Prerequisites

To get the most out of this guide, you’ll need to:
You can find your API keys in your SendPost Dashboard. Make sure to use your Sub-Account API Key for sending emails.

1. Install Dependencies

npm

2. Environment Setup

Add environment variables in Vercel Dashboard or vercel.json:
JSON
Or use Vercel CLI:

3. Serverless Function (API Route)

Basic Email Function

Create api/send-email.js:
JavaScript

TypeScript Version

Create api/send-email.ts:
TypeScript

4. Common Use Cases

Welcome Email Function

Create api/welcome-email.js:
JavaScript

Password Reset Email

Create api/password-reset.js:
JavaScript

5. Using with Next.js

If you’re using Next.js on Vercel, you can use the same API routes: Create pages/api/send-email.js or app/api/send-email/route.js:
JavaScript

6. Testing Locally

Install Vercel CLI:
Run locally:
Test your function:

7. Deploy

Deploy to Vercel:
Or connect your GitHub repository for automatic deployments.
Make sure your sender email domain is verified in your SendPost account before sending emails.

8. Next Steps

Explore more examples and use cases:

Vercel Documentation

Learn more about Vercel Functions

SendPost JavaScript SDK

View the official SDK package on npm

Quickstart Example

View a complete working example on GitHub