Envloped Docs

Send Email

API reference for sending emails with Envloped

Send Email

Send transactional emails using the Envloped API.

Endpoint

POST /v1/emails

Request Headers

HeaderRequiredDescription
AuthorizationYesBearer YOUR_API_KEY
Content-TypeYesapplication/json

Request Body

{
  "from": "sender@yourdomain.com",
  "to": "recipient@example.com",
  "subject": "Your subject line",
  "html": "<p>Your HTML content</p>",
  "text": "Your plain text content",
  "replyTo": "replies@yourdomain.com",
  "cc": ["cc@example.com"],
  "bcc": ["bcc@example.com"],
  "headers": {
    "X-Custom-Header": "value"
  }
}

Parameters

ParameterTypeRequiredDescription
fromstringYesSender email address. Must be from a verified domain.
tostring | string[]YesRecipient email address(es).
subjectstringYesEmail subject line.
htmlstringNo*HTML content of the email.
textstringNo*Plain text content of the email.
replyTostringNoReply-to email address.
ccstring[]NoCC recipient addresses.
bccstring[]NoBCC recipient addresses.
headersobjectNoCustom email headers.

*At least one of html or text is required.

Response

Success (200 OK)

{
  "id": "email_abc123xyz",
  "status": "sent",
  "from": "sender@yourdomain.com",
  "to": ["recipient@example.com"],
  "subject": "Your subject line",
  "createdAt": "2024-01-15T10:30:00Z"
}

Response Fields

FieldTypeDescription
idstringUnique identifier for the email.
statusstringStatus of the email: sent, queued, or failed.
fromstringSender email address.
tostring[]Recipient email addresses.
subjectstringEmail subject line.
createdAtstringISO 8601 timestamp of when the email was created.

Error Responses

400 Bad Request

{
  "error": {
    "code": "validation_error",
    "message": "Invalid request body",
    "details": [
      {
        "field": "to",
        "message": "Invalid email address format"
      }
    ]
  }
}

401 Unauthorized

{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key"
  }
}

403 Forbidden

{
  "error": {
    "code": "domain_not_verified",
    "message": "The sender domain is not verified"
  }
}

429 Too Many Requests

{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Please try again later.",
    "retryAfter": 60
  }
}

Code Examples

cURL

curl -X POST https://api.envloped.com/v1/emails \
  -H "Authorization: Bearer en_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "from": "hello@yourdomain.com",
    "to": "user@example.com",
    "subject": "Welcome to our service",
    "html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
    "text": "Welcome! Thanks for signing up."
  }'

JavaScript / TypeScript

async function sendEmail() {
  const response = await fetch('https://api.envloped.com/v1/emails', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.ENVLOPED_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      from: 'hello@yourdomain.com',
      to: 'user@example.com',
      subject: 'Welcome to our service',
      html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
      text: 'Welcome! Thanks for signing up.',
    }),
  });

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.error.message);
  }

  return response.json();
}

Python

import os
import requests

def send_email():
    response = requests.post(
        'https://api.envloped.com/v1/emails',
        headers={
            'Authorization': f'Bearer {os.environ["ENVLOPED_API_KEY"]}',
            'Content-Type': 'application/json',
        },
        json={
            'from': 'hello@yourdomain.com',
            'to': 'user@example.com',
            'subject': 'Welcome to our service',
            'html': '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
            'text': 'Welcome! Thanks for signing up.',
        }
    )

    response.raise_for_status()
    return response.json()

Go

package main

import (
    "bytes"
    "encoding/json"
    "net/http"
    "os"
)

type EmailRequest struct {
    From    string `json:"from"`
    To      string `json:"to"`
    Subject string `json:"subject"`
    HTML    string `json:"html"`
    Text    string `json:"text"`
}

func sendEmail() (*http.Response, error) {
    email := EmailRequest{
        From:    "hello@yourdomain.com",
        To:      "user@example.com",
        Subject: "Welcome to our service",
        HTML:    "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
        Text:    "Welcome! Thanks for signing up.",
    }

    body, _ := json.Marshal(email)

    req, _ := http.NewRequest("POST", "https://api.envloped.com/v1/emails", bytes.NewBuffer(body))
    req.Header.Set("Authorization", "Bearer "+os.Getenv("ENVLOPED_API_KEY"))
    req.Header.Set("Content-Type", "application/json")

    return http.DefaultClient.Do(req)
}

Rate Limits

PlanRequests per minuteEmails per day
Free10100
Pro10010,000
EnterpriseCustomCustom

When you exceed rate limits, the API returns a 429 status code with a retryAfter value indicating how many seconds to wait before retrying.

On this page