mailenv
MailEnv Public API

API reference

A managed REST API wrapper for Amazon SES, with API key authentication. JSON in, JSON out. Everything you need to send transactional email from your own code.

Introduction

The MailEnv Public API sends email over HTTPS. Every endpoint requires a valid API key in the Authorization header, accepts a JSON body, and returns JSON.

Base URL
https://pub-api.mailenv.com
Auth
API key in the Authorization header
Format
application/json
Base URL
https://pub-api.mailenv.com

Authentication

Authenticate every request with your API key in the Authorization header. Requests without a valid, active key return 401.

Keep keys out of client-side code and version control. Load them from an environment variable or a secrets manager.

Authorization: your-api-key-here

Errors

MailEnv uses standard HTTP status codes. Errors return a JSON body with "result": "error" and a human-readable message.

StatusMeaningWhen it happens
201CreatedThe mail request was accepted.
400Bad RequestValidation failed: a required field is missing or the JSON is invalid.
401UnauthorizedThe API key is invalid, or the account is locked.
403ForbiddenInvalid tokens, or your email volume has expired.
429Too Many RequestsYou hit the throttling limit. Back off and retry.
500Internal Server ErrorSomething went wrong on our side. Retry with backoff.

Send mail

POST /api/v1/send-mail

Sends an email message using the provided parameters. Requires authentication.

Headers

  • Authorizationstringrequired

    Your API key.

  • Content-Typestringrequired

    Must be application/json.

Body parameters

  • tostringrequired

    Recipient email address.

  • fromstringrequired

    Sender email address.

  • subjectstringrequired

    Email subject line.

  • messagestringrequired

    Email message body.

Response

  • result.idstringrequired

    Unique identifier for the mail request (UUID).

Notes

  • All email addresses must be in a valid email format.
  • The API key must be active and not locked for the request to succeed.
Request
curl -X POST "https://pub-api.mailenv.com/api/v1/send-mail" \
  -H "Authorization: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "recipient@example.com",
    "from": "sender@example.com",
    "subject": "Test Email",
    "message": "This is a test email message"
  }'
Response
{
  "result": {
    "id": "550e8400-e29b-41d4-a716-446655440000"
  }
}

Code examples

Complete, copy-paste examples for POST /api/v1/send-mail. Replace your-api-key-here with your key.

curl -X POST "https://pub-api.mailenv.com/api/v1/send-mail" \
  -H "Authorization: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "recipient@example.com",
    "from": "sender@example.com",
    "subject": "Test Email",
    "message": "This is a test email message"
  }'

Need help with the API?

Questions, migrations, or something not working the way you expect: talk to the team that builds it.