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. Node.js Lambda Function

Install Dependencies

Create a package.json file:
JSON
Install dependencies:
npm

Basic Lambda Function

Create index.js:
JavaScript

Environment Variables

In AWS Lambda Console, add environment variables:
  • SENDPOST_API_KEY: your_sub_account_api_key

Deploy with AWS CLI

2. Python Lambda Function

Install Dependencies

Create requirements.txt:

Basic Lambda Function

Create lambda_function.py:
Python

Deploy with AWS CLI

3. Common Use Cases

Welcome Email Lambda

Node.js version:
JavaScript

Password Reset Email Lambda

Python version:
Python

4. API Gateway Integration

Create API Gateway Endpoint

  1. Create a new API Gateway REST API
  2. Create a POST method
  3. Set integration type to Lambda Function
  4. Select your Lambda function
  5. Deploy to a stage

Example Request

5. Using Lambda Layers (Node.js)

Create Layer

Use Layer in Lambda

Attach the layer to your Lambda function in the AWS Console or via CLI:

6. Error Handling & Logging

Enhanced Error Handling

JavaScript

7. Testing Locally

Using SAM CLI

Create template.yaml:
Test locally:

Using Lambda Runtime Interface Emulator

Test:
Make sure your sender email domain is verified in your SendPost account before sending emails.

8. Next Steps

Explore more examples and use cases:

AWS Lambda Documentation

Learn more about AWS Lambda

SendPost JavaScript SDK

View the official SDK package on npm

SendPost Python SDK

View the official SDK package on PyPI

Quickstart Example

Complete working example from this quickstart guide