Questions · Updated 2026-09-23

How do I send email from AWS Lambda?

Send email from AWS Lambda by running the Node client inside the handler. Set AGENTISEND_API_KEY on the function, then call POST /emails. The handler reads process.env, which is how Lambda exposes environment variables to Node.js.

Send email from AWS Lambda by running the Node client inside the handler. The client reads AGENTISEND_API_KEY from the environment when you do not pass a key to the constructor. The call is POST /emails. Read it back with GET /emails/{id}. Create the key with POST /api-keys.

The handler

This block is the repository quickstart. It is executed against a real API on every build.

import { AgentiSend } from 'agentisend';

const agentisend = new AgentiSend(process.env.AGENTISEND_API_KEY);
const { id } = await agentisend.emails.send({
  from: 'you@yourdomain.com',
  to: 'someone@example.com',
  subject: 'Hello from AgentiSend',
  text: 'Ten minutes, start to sent.',
});
console.log(id);
the repository README; executed against the live API on every build

As of September 2026, the Lambda Node.js handler page says a handler reads environment variables with process.env: Define Lambda function handler in Node.js. The environment-variables page says you set them in the console under Configuration, Environment variables, Edit, Add environment variable, then a key and a value: Working with Lambda environment variables. Put the API key in that value. The same page says an update-function-configuration call replaces the whole variables map, so a CLI update has to include the variables you want to keep.

The From address

from has to be on a domain POST /domains/{id}/verify has verified, or the send returns domain_not_verified. To rehearse with no delivery, address the recipient at simulator.agentisend.com, as the test page describes.

Next