Sending Email via REST API

The CyberPanel Email REST API lets you send emails and retrieve analytics with simple HTTP requests. This guide covers authentication, endpoints, and code examples.

Authentication

Authenticate using your API key in one of two ways:

# Option 1: Authorization header (recommended)
Authorization: Bearer sk_live_YOUR_API_KEY

# Option 2: X-API-Key header
X-API-Key: sk_live_YOUR_API_KEY

Creating API Keys

  1. Go to https://platform.cyberpersons.com/email/api-keys/
  2. Click Create API Key
  3. Set a name and permissions:
    • can_send — Send emails
    • can_read_analytics — Read message status and account stats
  4. Optionally restrict to specific domains or IP addresses
  5. Copy the key — it’s only shown once!

Send Email

POST https://platform.cyberpersons.com/email/v1/send

Request Body

{
  "from": "[email protected]",       // Required - must be verified domain
  "to": "[email protected]",        // Required
  "subject": "Order Confirmation",       // Required
  "html": "<h1>Thank you!</h1>",       // Required (html or text)
  "text": "Thank you for your order.",  // Optional plain-text fallback
  "cc": "[email protected]",               // Optional
  "bcc": "[email protected]",             // Optional
  "reply_to": "[email protected]",  // Optional
  "tags": ["order", "confirmation"],   // Optional - for filtering in logs
  "metadata": {"order_id": "12345"},   // Optional - custom key-value pairs
  "headers": {"X-Custom": "value"}     // Optional - custom email headers
}

Success Response (202)

{
  "success": true,
  "data": {
    "message_id": "[email protected]",
    "status": "sent",
    "from": "[email protected]",
    "to": "[email protected]",
    "subject": "Order Confirmation",
    "sent_at": "2026-02-23T10:30:00Z"
  }
}

Get Message Status

GET https://platform.cyberpersons.com/email/v1/messages/{message_id}

Response

{
  "success": true,
  "data": {
    "message_id": "[email protected]",
    "status": "delivered",
    "from": "[email protected]",
    "to": "[email protected]",
    "subject": "Order Confirmation",
    "queued_at": "2026-02-23T10:30:00Z",
    "sent_at": "2026-02-23T10:30:01Z",
    "delivered_at": "2026-02-23T10:30:02Z",
    "opened": true,
    "opened_at": "2026-02-23T10:35:00Z",
    "open_count": 2,
    "clicked": false,
    "click_count": 0,
    "tags": ["order", "confirmation"],
    "metadata": {"order_id": "12345"}
  }
}

Get Account Stats

GET https://platform.cyberpersons.com/email/v1/account/stats

Response

{
  "success": true,
  "data": {
    "plan": "starter",
    "status": "active",
    "monthly_limit": 50000,
    "emails_sent_this_month": 12340,
    "emails_remaining": 37660,
    "reputation_score": 95,
    "domains_verified": 3,
    "rate_limits": {
      "per_minute": 60,
      "per_hour": 3600,
      "per_day": 1700
    },
    "this_month": {
      "total": 12340,
      "delivered": 12100,
      "bounced": 150,
      "opened": 8200,
      "clicked": 3100
    }
  }
}

Error Codes

HTTP Status Error Code Description
400 invalid_request Missing required fields or invalid email format
403 domain_not_verified Sending domain is not verified
403 domain_not_found Domain not registered to your account
403 account_inactive Account is suspended or inactive
403 forbidden API key domain/IP restriction or protected domain
404 not_found Message ID not found
429 rate_limit_exceeded Rate limit reached (includes retry_after)
500 send_failed Sending failed after failover attempts
503 service_unavailable No healthy mail nodes available

Code Examples

cURL

curl -X POST https://platform.cyberpersons.com/email/v1/send \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from":"[email protected]","to":"[email protected]","subject":"Hello","html":"<p>Hi there!</p>"}'

Python (requests)

import requests

resp = requests.post(
    "https://platform.cyberpersons.com/email/v1/send",
    headers={"Authorization": "Bearer sk_live_YOUR_KEY"},
    json={
        "from": "[email protected]",
        "to": "[email protected]",
        "subject": "Hello",
        "html": "<p>Hi there!</p>",
    }
)
print(resp.json())

Node.js (axios)

const axios = require('axios');

const resp = await axios.post('https://platform.cyberpersons.com/email/v1/send', {
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Hello',
  html: '<p>Hi there!</p>',
}, {
  headers: { Authorization: 'Bearer sk_live_YOUR_KEY' }
});
console.log(resp.data);

PHP (cURL)

$ch = curl_init('https://platform.cyberpersons.com/email/v1/send');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer sk_live_YOUR_KEY',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'from' => '[email protected]',
        'to' => '[email protected]',
        'subject' => 'Hello',
        'html' => '<p>Hi there!</p>',
    ]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;

Related Guides

← Back to Documentation Hub

Table of Contents