API Documentation

Welcome to the leveragers.xyz API documentation. Our RESTful API provides programmatic access to temporary email infrastructure, perfect for automated testing, development workflows, and secure messaging.

BASE URL: https://leveragers.xyz/api

Key Features

  • Instant Email Generation - Create temporary mailboxes in milliseconds
  • Real-time Inbox Access - Retrieve emails as they arrive
  • Custom Domain Support - Use your own domains for email generation
  • RESTful Architecture - Simple, predictable HTTP endpoints
  • JSON Responses - All responses in standard JSON format

Quick Start Guide

Get up and running with the leveragers.xyz API in just a few steps.

1 Create an Account

Sign up at leveragers.xyz/register to get your API key.

2 Get Your API Key

Navigate to your Profile page and copy your API key from the "API Credentials" section.

Keep it Secret

Your API key is like a password. Never share it publicly or commit it to version control.

3 Make Your First Request

Generate your first temporary email address:

CURL
curl -X POST https://leveragers.xyz/api/mail/generate \
  -H "X-API-KEY: your_api_key_here" \
  -H "Content-Type: application/json"
PYTHON (using MailAPI wrapper)
from api_wrapper import MailAPI, MailAPIException

# Initialize with your API key
api = MailAPI(api_key="your_api_key_here", base_url="https://leveragers.xyz")

try:
    # Generate a new temporary email
    new_mail = api.generate_email(domain="leveragers.xyz")
    print(f"Generated: {new_mail['email']}")
except MailAPIException as e:
    print(f"Error {e.status_code}: {e}")
JAVASCRIPT
const response = await fetch('https://leveragers.xyz/api/mail/generate', {
  method: 'POST',
  headers: {
    'X-API-KEY': 'your_api_key_here'
  }
});

const data = await response.json();
console.log('Generated:', data.email);

4 Check Your Inbox

Retrieve emails sent to your generated address:

CURL
curl https://leveragers.xyz/api/mail/list \
  -H "X-API-KEY: your_api_key_here"

Authentication

All API requests require authentication using your API key passed in the X-API-KEY header.

How It Works

Every request to the API must include your API key in the request headers. The server validates this key before processing your request.

AUTHENTICATION HEADER
X-API-KEY: your_api_key_here
Security Best Practices
  • Never expose your API key in client-side code
  • Use environment variables to store your key
  • Rotate your key regularly from the Profile page
  • Use HTTPS for all API requests

Email Generation

POST /mail/generate

Creates a new temporary email address. You can optionally specify a domain and custom prefix.

Request Parameters

Parameter Type Required Description
domain string No Target domain (defaults to leveragers.xyz)
prefix string No Custom email prefix (auto-generated if not provided)
REQUEST
curl -X POST https://leveragers.xyz/api/mail/generate \
  -H "X-API-KEY: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"domain": "leveragers.xyz", "prefix": "test"}'
REQUEST
import requests

url = "https://leveragers.xyz/api/mail/generate"
headers = {"X-API-KEY": "your_api_key_here"}
data = {"domain": "leveragers.xyz", "prefix": "test"}

response = requests.post(url, headers=headers, json=data)
print(response.json())
REQUEST
const response = await fetch('https://leveragers.xyz/api/mail/generate', {
  method: 'POST',
  headers: {
    'X-API-KEY': 'your_api_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    domain: 'leveragers.xyz',
    prefix: 'test'
  })
});

const data = await response.json();
console.log(data);
RESPONSE - 201 CREATED
{
  "message": "Email generated successfully",
  "email": "xk9mq2jfat@leveragers.xyz",
  "balance": 0.999,
  "id": 42
}

List Emails

GET /mail/list

Retrieves all emails for the authenticated user. Supports pagination.

Query Parameters

Parameter Type Default Description
page integer 1 Page number for pagination
per_page integer 10 Number of results per page (max: 100)
REQUEST
curl https://leveragers.xyz/api/mail/list?page=1&per_page=10 \
  -H "X-API-KEY: your_api_key_here"
RESPONSE - 200 OK
{
  "emails": [
    {
      "id": 1,
      "email_address": "test@leveragers.xyz",
      "domain_id": 2,
      "created_at": "2026-02-15T04:40:00Z"
    }
  ],
  "total": 1,
  "page": 1,
  "per_page": 10
}

Get Email Details

GET /mail/inbox/{email_address}

Retrieves all messages received for a specific email address. Syncs from the external mail server and persists new messages.

REQUEST
curl https://leveragers.xyz/api/mail/inbox/test@leveragers.xyz \
  -H "X-API-KEY: your_api_key_here"
RESPONSE - 200 OK
{
  "emails": [
    {
      "id": 42,
      "from": "noreply@example.com",
      "subject": "Verify your account",
      "body": "Click the link below to verify...",
      "html": "<html>...</html>",
      "received_at": "2026-02-15T04:41:00Z"
    }
  ]
}

Domain Management

GET /domains/user

Lists all domains owned by the authenticated user.

RESPONSE - 200 OK
{
  "domains": [
    {
      "id": 1,
      "domain_name": "example.com",
      "status": "active",
      "verified_at": "2026-02-14T10:00:00Z",
      "created_at": "2026-02-14T09:00:00Z"
    }
  ],
  "total": 1
}

Add Domain

POST /domains/add

Registers a new custom domain for email generation.

Parameter Type Required Description
domain string REQUIRED The domain name to register
REQUEST
curl -X POST https://leveragers.xyz/api/domains/add \
  -H "X-API-KEY: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"domain": "example.com"}'
RESPONSE - 201 CREATED
{
  "message": "Domain added successfully",
  "domain_id": 1,
  "domain": {
    "id": 1,
    "domain_name": "example.com",
    "mx_record": "mail.leveragers.xyz",
    "status": "pending"
  }
}

Verify Domain

POST /domains/{domain_id}/verify

Verifies DNS configuration for a registered domain.

DNS Configuration Required

Before verifying, ensure you've added the required MX and TXT records to your domain's DNS settings. You can find these records in the domain details on the Domains page.

REQUEST
curl -X POST https://leveragers.xyz/api/domains/1/verify \
  -H "X-API-KEY: your_api_key_here"
RESPONSE - 200 OK
{
  "status": "active",
  "message": "Domain verified successfully",
  "verified_at": "2026-02-15T04:42:00Z"
}

Python SDK

The official Leveragers MailAPI Python client wraps all REST API calls into a clean, typed interface. Drop it into any Python project for instant email generation and inbox polling — no raw HTTP needed.

Installation

TERMINAL
pip install requests

Then save the api_wrapper.py file below into your project directory.

api_wrapper.py — Full Source

PYTHON — api_wrapper.py
import requests
import json
from typing import Dict, List, Any


class MailAPIException(Exception):
    """Raised when the Leveragers API returns an error response."""
    def __init__(self, message: str, status_code: int = None, response_text: str = None):
        super().__init__(message)
        self.status_code = status_code
        self.response_text = response_text


class MailAPI:
    """
    Leveragers Mail Server API Client

    Focuses on two core operations:
      - generate_email()  →  create a temporary mailbox
      - get_inbox()       →  retrieve received messages

    Usage:
        api = MailAPI(api_key="your_key", base_url="https://leveragers.xyz")
        mail = api.generate_email(domain="leveragers.xyz")
        msgs = api.get_inbox(mail["email"])
    """

    def __init__(self, api_key: str, base_url: str = "https://leveragers.xyz"):
        """
        Args:
            api_key:  Your personal API key (Profile → API Credentials)
            base_url: Base URL of the Leveragers server (no trailing slash)
        """
        self.base_url = base_url.rstrip('/')
        self.api_key = api_key
        self.session = requests.Session()
        self.session.headers.update({
            'X-API-KEY': self.api_key,
            'Content-Type': 'application/json',
            'User-Agent': 'Leveragers-API-Client/2.0'
        })

    def _request(self, method: str, endpoint: str, **kwargs) -> Dict[str, Any]:
        """Internal helper — handles all HTTP calls and error parsing."""
        url = f"{self.base_url}{endpoint}"
        try:
            response = self.session.request(method, url, **kwargs)

            if response.status_code == 204:
                return {"success": True}

            try:
                data = response.json()
            except json.JSONDecodeError:
                raise MailAPIException(
                    "Invalid non-JSON response from server",
                    status_code=response.status_code,
                    response_text=response.text[:500]
                )

            if not response.ok:
                error_msg = data.get('error', data.get('message', f"HTTP {response.status_code}"))
                raise MailAPIException(
                    f"API Error: {error_msg}",
                    status_code=response.status_code,
                    response_text=response.text
                )

            return data

        except requests.RequestException as e:
            raise MailAPIException(f"Connection failed: {str(e)}")

    def generate_email(self, domain: str) -> Dict[str, Any]:
        """
        Generate a new temporary email address.

        Args:
            domain: Domain name to use (e.g. 'leveragers.xyz')

        Returns:
            {'email': str, 'id': int, 'balance': float}
        """
        return self._request('POST', '/api/mail/generate', json={'domain': domain})

    def get_inbox(self, email_address: str) -> List[Dict[str, Any]]:
        """
        Retrieve all messages for a specific email address.

        Args:
            email_address: The full email to check (e.g. 'xyz@leveragers.xyz')

        Returns:
            List of message dicts: from, subject, body, html, received_at
        """
        data = self._request('GET', f'/api/mail/inbox/{email_address}')
        return data.get('emails', [])

End-to-End Example

PYTHON — generate & poll inbox
from api_wrapper import MailAPI, MailAPIException

api = MailAPI(api_key="your_api_key_here", base_url="https://leveragers.xyz")

try:
    # 1. Generate a temporary email
    mail = api.generate_email(domain="leveragers.xyz")
    print(f"[+] Mailbox ready: {mail['email']}")
    print(f"    Balance remaining: ${mail['balance']:.4f}")

    # 2. Poll the inbox
    inbox = api.get_inbox(mail['email'])
    print(f"[+] {len(inbox)} message(s) found")

    for msg in inbox:
        print(f"\n  From    : {msg['from']}")
        print(f"  Subject : {msg['subject']}")
        print(f"  Received: {msg['received_at']}")
        print(f"  Body    : {msg['body'][:120]}...")

except MailAPIException as e:
    print(f"[-] API Error ({e.status_code}): {e}")
    if e.status_code == 401:
        print("    → Check your API key in Profile settings.")
    elif e.status_code == 402:
        print("    → Insufficient balance. Top up your account.")
    elif e.status_code == 429:
        print("    → Rate limited. Wait before retrying.")
except Exception as e:
    print(f"[-] Unexpected error: {e}")

MailAPIException Reference

Attribute Type Description
str(e) string Human-readable error message
e.status_code int | None HTTP status code from the server (401, 402, 429, 500…)
e.response_text string | None Raw server response body for debugging
Keep Your API Key Safe

Store your key in an environment variable, never in source code. Use os.getenv("LEVERAGERS_API_KEY") in production.

Error Codes

The API uses standard HTTP status codes to indicate success or failure.

Code Status Description
200 OK Request successful
201 Created Resource created successfully
400 Bad Request Invalid request parameters
401 Unauthorized Invalid or missing API key
404 Not Found Resource not found
500 Server Error Internal server error

Error Response Format

ERROR RESPONSE
{
  "error": "Invalid API key",
  "status": 401
}

Rate Limits

To ensure fair usage and system stability, API requests are rate-limited.

Free Tier

100

requests per hour

Pro Tier

1,000

requests per hour

Rate Limit Headers

All responses include X-RateLimit-Remaining and X-RateLimit-Reset headers to help you track your usage.