API
REST API for integrating with the MXGuard mail filtering system.
API Basics
Endpoint
https://my.mxguard.net/panelv32/api/?token=YOUR_API_TOKEN
Request Format
Requests are sent via POST with a JSON body. GET with URL parameters is also supported.
POST body (JSON)
{
"request": "module_name",
"action": "action_name",
"parameters": "values"
}Authorization
The token is passed in the URL parameter token. You can generate a token in the control panel under "Access Tokens".
Supported Modules
| request | Description |
|---|---|
tracker | Email processing history |
message | Details of a specific email |
queue | Delivery queue |
domains | List of domains |
domain | Manage a single domain |
boxes | List of mailboxes |
box | Manage a single mailbox |
whitelists | Whitelist |
blacklists | Blacklist |
stats | Statistics |
Tracker
History of email message processing.
List of Emails
Request
{
"request": "tracker",
"action": "list",
"status": "quarant",
"date": "day",
"mail_to": "example.com"
}| Parameter | Description | Example |
|---|---|---|
status | Email status | quarant, deliv, reject, error |
date | Period | day, lastday, week, month |
subject | Email subject | "Promotion" |
mail_from | Sender | "sender@domain.com" |
mail_to | Recipient | "user@example.com" |
smid | Email ID | "2508200002183574501" |
ip_from | Sender IP | "192.168.1.1" |
perpage | Records per page | 50 |
page | Page number | 1 |
Response
{
"perpage": "50",
"page": 1,
"records": 453,
"pages": 10,
"rows": {
"1": {
"byid": {"key": "byid", "val": "2508200002183574501"},
"status": {"key": "status", "val": "zonde",
"view": "Spam traps"},
"date": {"key": "date", "val": "today at 00:02, Wed"},
"subject": {"key": "subject", "val": "Contract Tender Notice"},
"mail_from": {"key": "mail_from","val": "srm@lukoil.com"},
"mail_to": {"key": "mail_to", "val": "yuri@mydomain.com"},
"status_info": {"key": "status_info","val": "237"}
}
}
}Detailed Email Information
Request
{
"request": "message",
"action": "view",
"byid": "2508200324264421504"
}| Field | Description |
|---|---|
byid | Unique email ID |
smid | MXGuard Message ID |
date | Date and time of processing |
helo | Sender's EHLO greeting |
ip_from | Sender's IP address |
mail_from | Sender's email |
mail_to | Recipient's email |
subject | Email subject |
msize | Email size |
quarantine | Quarantine flag (0/1) |
status | Processing status code |
status_text | Text description of status |
head | Email headers (raw) |
log | Email processing log |
Response (success)
{
"records": 1,
"code": "success",
"rows": {
"1": {
"byid": {"key":"byid","val":"2508200324264421504"},
"smid": {"key":"smid","val":"2508200324264421504"},
"date": {"key":"date","val":"August 20 at 03:24:26"},
"ip_from": {"key":"ip_from","val":"10.255.7.3"},
"mail_from": {"key":"mail_from","val":"sender@example.com"},
"mail_to": {"key":"mail_to","val":"sn@mydomain.com"},
"subject": {"key":"subject","val":"Sample email subject"},
"msize": {"key":"msize","val":"2.5 Kb"},
"quarantine": {"key":"quarantine","val":"0"},
"status_text": {"key":"status_text",
"val":"Email delivered to destination"},
"head": {"key":"head","val":"Email headers..."},
"log": {"key":"log","val":"Processing log..."}
}
}
}Response (error)
{
"records": 0,
"code": "failed",
"error": "notfound",
"text": "Record not found",
"module": "tracker",
"request": "view"
}Email Queue
Queue list
{
"request": "queue",
"action": "list",
"mail_from": "sn@example.com",
"date": "day",
"perpage": 50,
"page": 1
}Force-send all
{
"request": "queue",
"action": "sendall"
}Frequent use of
sendall may cause receiving servers to block you due to the burst of outgoing traffic.Response (list)
{
"records": 1, "code": "success",
"rows": {
"1": {
"byid": {"key":"byid","val":"2508221749084133220"},
"status": {"key":"status","val":"queue",
"view":"Queued"},
"date": {"key":"date","val":"today at 17:49, Fri"},
"mail_from": {"key":"mail_from","val":"sn@example.com"},
"mail_to": {"key":"mail_to",
"val":"recipient@example.com"},
"status_info":{"key":"status_info","val":"340"}
}
},
"actions": ["list", "sendall"],
"module": "tracker", "request": "list"
}Response (sendall)
{
"code": "success",
"message": "All queued emails have been sent",
"sent_count": 15,
"module": "tracker",
"request": "sendall"
}Domain Management
List of Domains
Request
{
"request": "domains",
"action": "list",
"active": "1",
"domain": "example"
}Response
{
"records": 1, "code": "success",
"rows": {
"1": {
"byid": {"key":"byid","val":"mydomain.com"},
"status": {"key":"status","val":"normal",
"view":"Active"},
"domain": {"key":"domain","val":"mydomain.com"},
"emailcnt": {"key":"emailcnt","val":"31"},
"mx_fail": {"key":"mx_fail","val":"0"},
"mxs_mx": {"key":"mxs_mx",
"val":"001:mx.mxguard.net;020:mx1.mxguard.net"},
"spamlevel": {"key":"spamlevel","val":"6982 (90 %)"}
}
}
}View Domain Settings
Request
{"request":"domain","action":"view","byid":"mydomain.com"}| Field | Description |
|---|---|
smtpserver | Primary SMTP delivery server |
smtpserver2 | Backup SMTP server |
port | SMTP server port |
databytes | Email size limit |
num1 | Spam filtering level (1–10) |
boxtype | Mailbox management type (add_safe / manual) |
masquarade | Sender masquerading (yes/no) |
weblearn | Web-based spam-filter training (enable/disable) |
dkim_selector | DKIM selector |
dkim_pub | DKIM public key |
Adding a Domain
Request
{
"request": "domain",
"action": "add",
"domain": "newdomain.com",
"smtpserver": "mx.yandex.ru",
"boxtype": "add_safe",
"masquarade": "yes"
}| Parameter | Required |
|---|---|
domain | Yes |
smtpserver | Yes |
smtpserver2 | No |
port | No |
boxtype | No |
masquarade | No |
comment | No |
Response (success)
{
"code": "success",
"rows": {"byid": 1855},
"actions": ["view","save","add","delete","check"],
"module": "domain", "request": "add"
}Validation Error
{
"code": "failed",
"error": "fields",
"rows": {
"smtpserver": {
"errors": [{"error":"badhost",
"error_text":"Host is invalid"}]
}
},
"text": "Error filling in fields"
}Editing a Domain
Request
{
"request": "domain",
"action": "save",
"byid": "mydomain.com",
"smtpserver": "mx1.yandex.ru",
"num1": "7.00"
}The response contains the changed fields along with their old and new values:
{"code":"success","rows":[{
"field":"smtpserver","old":"mx.yandex.ru","val":"mx1.yandex.ru"
}]}Deleting a Domain
Request
{
"request": "domain",
"action": "delete",
"byid": "example.com"
}All mailboxes on the domain must be deleted before the domain itself can be deleted. This operation cannot be undone.
| Error Code | Description |
|---|---|
notfound | Domain not found |
access_denied | No permission to delete |
has_mailboxes | Domain has mailboxes |
has_aliases | Domain has aliases |
system_domain | System domain |
Mailbox Management
List of Mailboxes
{
"request": "boxes",
"action": "list",
"domain": "mydomain.com",
"status": "active",
"email": "admin@",
"perpage": 100,
"page": 1
}View Mailbox
{
"request": "box",
"action": "view",
"byid": "user@mydomain.com"
}Adding a Mailbox
{
"request": "box",
"action": "add",
"email": "newuser@mydomain.com",
"password": "securepassword123"
}Editing a Mailbox
{
"request": "box",
"action": "save",
"byid": "user@mydomain.com",
"comment": "Administrator",
"password": "newpassword456"
}Deleting a Mailbox
{
"request": "box",
"action": "delete",
"byid": "user@mydomain.com"
}| Response Field | Description |
|---|---|
byid | Mailbox email (ID) |
status | active / disabled / zonde |
email | Full email address |
emailcnt | Number of emails |
boxunused | Unused flag |
boxnospam | Disable filtering |
comment | Comment |
spamlevel | Spam level |
| Error Code | Description |
|---|---|
notfound | Mailbox not found |
already_exists | Mailbox already exists |
invalid_email | Invalid email format |
domain_not_exists | Domain does not exist |
password_too_weak | Password is too weak |
quota_exceeded | Mailbox quota exceeded |
Whitelist
List Entries
{
"request": "whitelists",
"action": "list",
"status": "personal",
"address": "gmail.com",
"to_address": "user@mydomain.com"
}Adding an Entry
{
"request": "whitelists",
"action": "add",
"address": "partner@company.com",
"to_address": "user@mydomain.com",
"status": "personal",
"comment": "Trusted partner"
}Editing / Deleting
{
"request": "whitelists",
"action": "save",
"byid": "61539",
"comment": "Updated comment"
}
{"request":"whitelists","action":"delete","byid":"61539"}Sample List Response
{
"records": 483, "code": "success",
"rows": {
"1": {
"byid": {"key":"byid","val":"61539"},
"status": {"key":"status","val":"personal",
"view":"Personal"},
"address": {"key":"address",
"val":"partner@gmail.com"},
"to_address": {"key":"to_address",
"val":"eg@mydomain.com"},
"comment": {"key":"comment",
"val":"Partner LLC"}
}
}
}Entries with
to_address: "(for all)" apply to every recipient on the domain. Whitelisting an entire domain (gmail.com) can significantly reduce the filtering level.Blacklist
List Entries
{
"request": "blacklists",
"action": "list",
"status": "domain",
"address": "*.com"
}Adding an Entry
{
"request": "blacklists",
"action": "add",
"address": "*.spammer.com",
"to_address": "(for all)",
"status": "domain",
"comment": "Known spammer"
}Editing / Deleting
{"request":"blacklists","action":"save",
"byid":"192605","comment":"Updated"}
{"request":"blacklists","action":"delete","byid":"192605"}| Type | Example address |
|---|---|
spammer@example.com | |
| Domain | *.example.com |
| IP | 192.168.1.1 |
| IP range | 192.168.1.* |
| status | Description |
|---|---|
personal | Personal entry |
domain | Entire domain |
ip | By IP address |
Statistics
Retrieving Statistics
{
"request": "stats",
"action": "list",
"period": "month",
"domain": "example.com"
}Detailed Statistics
{
"request": "stats",
"action": "view",
"byid": "2024-08",
"domain": "example.com"
}| Parameter | Description |
|---|---|
period | day, week, month, year |
domain | Filter by domain |
date_from | Period start (YYYY-MM-DD) |
date_to | Period end (YYYY-MM-DD) |
Error Codes
| HTTP | Status | Description |
|---|---|---|
| 200 | Success | Request completed successfully |
| 400 | Bad Request | Invalid request syntax |
| 401 | Unauthorized | Invalid or missing token |
| 403 | Forbidden | Access denied |
| 404 | Not Found | Object not found |
| 500 | Internal Error | Internal server error |
| error | Description |
|---|---|
notfound | Record not found |
access_denied | No access |
denied | No permission for this operation |
fields | Field validation errors |
required | Required field not filled in |
badhost | Invalid host format |
invalid_email | Invalid email format |
invalid_domain | Invalid domain format |
invalid_address | Invalid address format |
invalid_ip | Invalid IP format |
already_exists | Record already exists |
domain_exists | Domain already exists |
has_mailboxes | Domain contains mailboxes |
quota_exceeded | Quota exceeded |
password_too_weak | Password is too weak |
queue_empty | Queue is empty |
database_error | Database error |
Example Requests
GET Request with URL Parameters
cURL
curl -X GET \
'https://my.mxguard.net/panelv32/api/?token=YOUR_TOKEN&request=tracker&action=list&mail_from=newsletter@company.com&date=week&status=quarant' \
-H 'Content-Type: application/json'POST Request with JSON Body
cURL
curl -X POST \
'https://my.mxguard.net/panelv32/api/?token=YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"request": "tracker",
"action": "list",
"mail_from": "billing@service.com",
"date": "month",
"status": "deliv",
"subject": "Invoice",
"perpage": 100,
"page": 1
}'Python
import requests, json
TOKEN = "YOUR_API_TOKEN"
URL = f"https://my.mxguard.net/panelv32/api/?token={TOKEN}"
def api(payload):
r = requests.post(URL, json=payload,
headers={"Content-Type": "application/json"})
return r.json()
# List of quarantined emails
print(api({"request":"tracker","action":"list","status":"quarant","date":"day"}))
# Add a domain
print(api({"request":"domain","action":"add",
"domain":"example.com","smtpserver":"mail.example.com"}))
# Working with the queue
queue = api({"request":"queue","action":"list","perpage":100})
if queue.get("records", 0) > 0:
api({"request":"queue","action":"sendall"})