Guides API Reference

API Reference

Complete REST API documentation for managing mailboxes and messages

Quick Start

The DevInbox API provides REST endpoints for creating temporary and persistent mailboxes and retrieving messages. All API requests use HTTPS and return JSON responses. Perfect for integration testing and automated workflows.

Authentication

API Key Authentication

Include your API key in the X-Api-Key header of all requests:

curl -H "X-Api-Key: your_api_key_here" \
  https://api.devinbox.io/mailboxes
Find your API key in your dashboard under Settings ? API Keys

Base URL

https://api.devinbox.io

Status Endpoints

GET /status

Returns OK if the API service is running and available. This endpoint does not require authentication.

Response 200 OK

200 OK

Example

curl https://api.devinbox.io/status

Mailbox Endpoints

POST /mailboxes

Creates a new mailbox (temporary or persistent). Returns a unique mailbox key and password for SMTP authentication. Note: Persistent mailboxes can only be created via the web portal - API only supports temporary mailboxes.

Request Body

{
  "name": null,
  "projectName": "my-project",
  "isTemporary": true
}

Request Parameters

  • name - Optional name for persistent mailboxes (API creates temporary only)
  • projectName - Project to associate mailbox with (uses default if not specified)
  • isTemporary - Must be true for API requests (default: true)

Response 200 OK

{
  "key": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
  "password": "xyz789abcdef123456..."
}
The mailbox email address is: {key}@devinbox.io

Example

curl -X POST https://api.devinbox.io/mailboxes \
  -H "X-Api-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"projectName": "test-project", "isTemporary": true}'

Error Responses

  • 400 - Project not found or persistent mailbox creation attempted
  • 401 - Invalid or missing API key
  • 429 - Rate limit exceeded

Message Endpoints

GET /messages/{'{key}'}/count

Returns the total number of messages in the specified mailbox.

Response 200 OK

{
  "key": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
  "count": 3
}

Example

curl -H "X-Api-Key: your_api_key_here" \
  https://api.devinbox.io/messages/a1b2c3d4e5f6/count
GET /messages/{'{key}'}?skip=0&take=10

Retrieves messages from a mailbox with pagination support.

Query Parameters

  • skip - Number of messages to skip (default: 0)
  • take - Number of messages to return (default: 10, max: 25)

Response 200 OK

{
  "key": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
  "count": 1,
  "messages": [
    {
      "uniqueId": "12345678-1234-1234-1234-123456789abc",
      "from": [ "noreply@example.com" ],
      "to": [ "a1b2c3d4@devinbox.io" ],
      "cc": null,
      "bcc": null,
      "subject": "Welcome to Our Service!",
      "body": "<h1>Welcome!</h1><p>Thank you for signing up...</p>",
      "isHtml": true,
      "received": "2024-01-15T10:35:00Z"
    }
  ]
}

Example

curl -H "X-Api-Key: your_api_key_here" \
  "https://api.devinbox.io/messages/a1b2c3d4e5f6?skip=0&take=5"
GET /messages/{'{key}'}/single

Returns the message when the mailbox contains exactly one message. Returns error if mailbox contains 0 or more than 1 message.

Response 200 OK

{
  "uniqueId": "12345678-1234-1234-1234-123456789abc",
  "from": [ "noreply@example.com" ],
  "to": [ "a1b2c3d4@devinbox.io" ],
  "cc": null,
  "bcc": null,
  "subject": "Welcome!",
  "body": "Thank you for registering...",
  "isHtml": false,
  "received": "2024-01-15T10:35:00Z"
}
Perfect for integration tests that expect exactly one email notification.

Example

curl -H "X-Api-Key: your_api_key_here" \
  https://api.devinbox.io/messages/a1b2c3d4e5f6/single
GET /messages/{'{key}'}/last

Returns the most recent message from the mailbox. Returns error if mailbox is empty.

Example

curl -H "X-Api-Key: your_api_key_here" \
  https://api.devinbox.io/messages/a1b2c3d4e5f6/last
GET /messages/{'{key}'}/get?id={'{guid}'}

Retrieves a specific message from the specified mailbox using its unique ID.

Query Parameters

  • id - The unique GUID of the message

Example

curl -H "X-Api-Key: your_api_key_here" \
  "https://api.devinbox.io/messages/a1b2c3d4e5f6/get?id=12345678-1234-1234-1234-123456789abc"

Template Verification

Template verification allows you to validate that emails match expected patterns and extract structured data from them. Templates must be created in your project before using these endpoints.
GET /messages/{'{key}'}/{'{template}'}/single

Returns the single message and parses it using the specified template. The mailbox must contain exactly one message. The response includes the original message data plus parsed template parameters.

Response 200 OK

{
  "uniqueId": "12345678-1234-1234-1234-123456789abc",
  "from": [ "noreply@example.com" ],
  "to": [ "user123@devinbox.io" ],
  "cc": null,
  "bcc": null,
  "subject": "Welcome to DevInbox, John Smith!",
  "body": "<h1>Welcome John!</h1><p>Your verification code is ABC123</p>",
  "isHtml": true,
  "received": "2024-01-15T10:35:00Z",
  "templateData": {
    "subjectParams": {
      "UserName": "John Smith",
      "ProductName": "DevInbox"
    },
    "bodyParams": {
      "FirstName": "John",
      "VerificationCode": "ABC123",
      "CompanyName": "Acme Corp"
    },
    "templateName": "welcome-email",
    "matchSuccess": true
  }
}
The templateData object contains the extracted parameters from both subject and body, plus metadata about the template matching process.

Template Match Failure Response

{
  "uniqueId": "12345678-1234-1234-1234-123456789abc",
  "from": [ "noreply@example.com" ],
  "to": [ "user123@devinbox.io" ],
  "subject": "Unexpected email format",
  "body": "This email doesn't match the template",
  "isHtml": false,
  "received": "2024-01-15T10:35:00Z",
  "templateData": {
    "subjectParams": null,
    "bodyParams": null,
    "templateName": "welcome-email",
    "matchSuccess": false,
    "matchFailureReason": "Subject pattern did not match template"
  }
}

Example

curl -H "X-Api-Key: your_api_key_here" \
  https://api.devinbox.io/messages/a1b2c3d4e5f6/welcome-email/single
GET /messages/{'{key}'}/{'{template}'}/last

Returns the most recent message and parses it using the specified template. Response format is identical to the single message endpoint above.

Common Use Cases

# Get password reset email and extract reset token
curl -H "X-Api-Key: your_key" \
  https://api.devinbox.io/messages/a1b2c3d4e5f6/password-reset/last

# Verify welcome email contains correct user data
curl -H "X-Api-Key: your_key" \
  https://api.devinbox.io/messages/a1b2c3d4e5f6/user-registration/single

# Extract order details from confirmation email
curl -H "X-Api-Key: your_key" \
  https://api.devinbox.io/messages/a1b2c3d4e5f6/order-confirmation/last

Template Parameter Extraction

Templates use named capture groups to extract parameters:

  • Subject Template: Welcome to (?<ProductName>.*), (?<UserName>.*)!
  • Body Template: Hello (?<FirstName>.*?).*code is (?<VerificationCode>\w+)
  • Extracted Data: Parameters become key-value pairs in templateData

Error Handling

HTTP Status Codes

  • 200 OK - Request succeeded
  • 400 Bad Request - Invalid request parameters, template not found, or mailbox constraints not met
  • 401 Unauthorized - Invalid or missing API key
  • 403 Forbidden - Access denied to resource or tenant mismatch
  • 404 Not Found - Mailbox or message not found
  • 429 Too Many Requests - Rate limit exceeded

Error Response Example

{
  "error": "Rate limit exceeded",
  "message": "Monthly mailbox creation limit reached",
  "retryAfter": "60"
}

Common Error Messages

  • Template 'template-name' not found or you don't have access to it
  • Mailbox 'key' contains X messages (for /single endpoint)
  • Mailbox 'key' doesn't contain messages (for /last endpoint)
  • Project 'project-name' not found
  • Creation of persistent mailboxes via API is not supported
  • Template verification failed: message does not match template pattern
  • Invalid template format: missing required capture groups

Rate Limits

Rate Limit Headers

The API includes rate limit information in response headers:

  • X-RateLimit-Remaining - Operations remaining
  • X-RateLimit-Limit-Type - Type of limit (Monthly, Daily)

Operation Types

  • MailboxCreated - Creating new mailboxes via POST /mailboxes
  • MessageVerified - Template verification endpoints (/template/single, /template/last)
  • ApiCall - All other message retrieval operations

Plan Limits

Plan Mailboxes/Month Verifications/Month
Developer (Free) 500 1,000
Team 5,000 10,000
Business 25,000 50,000
Enterprise 100,000 200,000

Code Examples

import requests
import time

API_KEY = "your_api_key"
BASE_URL = "https://api.devinbox.io"
headers = {"X-Api-Key": API_KEY}

# Create temporary mailbox
response = requests.post(
    f"{BASE_URL}/mailboxes",
    headers=headers,
    json={"isTemporary": True})
mailbox = response.json()
email_address = f"{mailbox['key']}@devinbox.io"

# Wait for email and get single message
time.sleep(5)  # Wait for email delivery
response = requests.get(
    f"{BASE_URL}/messages/{mailbox['key']}/single",
    headers=headers)
message = response.json()
print(f"Subject: {message['subject']}")

# Get message with template verification
template_response = requests.get(
    f"{BASE_URL}/messages/{mailbox['key']}/welcome-email/single",
    headers=headers)
template_message = template_response.json()

# Extract and validate template parameters
if template_message['templateData']['matchSuccess']:
    user_name = template_message['templateData']['subjectParams']['UserName']
    verification_code = template_message['templateData']['bodyParams']['VerificationCode']
    print(f"Template matched! User: {user_name}, Code: {verification_code}")
else:
    print(f"Template match failed: {template_message['templateData']['matchFailureReason']}")

What's Next?