Administrator Email Integration API
Base URL: http://localhost:8000/api/v1
Prefix: /admins/platform-settings/integrations
Auth: Administrator JWT required
Headers: Content-Type: application/json
1. Get Email Configuration
Retrieve the saved integration state and sanitized configuration.
/admins/platform-settings/integrations/email/Auth: Required
Headers
Authorization: Bearer {{admin_access_token}}
Content-Type: application/jsonSuccess Example
{
"success": true,
"message": "Integration retrieved successfully.",
"data": {
"integration": {
"type": "email",
"is_enabled": true,
"configured": true,
"config": {
"provider": "smtp",
"smtp_host": "smtp.example.com",
"smtp_port": 587,
"default_from_email": "noreply@example.com",
"smtp_username": "replace-with-username",
"smtp_use_tls": true,
"smtp_use_ssl": false,
"has_smtp_password": true,
"has_mailgun_api_key": false,
"has_sendgrid_api_key": false,
"has_resend_api_key": false
},
"updated_at": "2026-11-24T10:00:00Z"
}
}
}Notes
Sensitive values are returned as has_* flags. configured means encrypted configuration exists; it does not verify provider credentials. A missing integration record is created disabled.
Applicable errors: 401 missing/invalid JWT; 403 administrator access required; 406 unsupported response format.
Unauthorized - HTTP 401
{
"success": false,
"message": "Authentication credentials were not provided.",
"errors": {}
}Forbidden - HTTP 403
{
"success": false,
"message": "You do not have permission to perform this action.",
"errors": {}
}2. Update Email Configuration
Save provider configuration and optionally enable or disable the integration.
/admins/platform-settings/integrations/email/Auth: Required
Headers
Authorization: Bearer {{admin_access_token}}
Content-Type: application/jsonRequest Body
| Field | Type | Requirement |
|---|---|---|
is_enabled | boolean | Optional; preserves the saved state when omitted. |
config | object | Optional; merges the submitted fields with saved configuration. |
SMTP
{
"is_enabled": true,
"config": {
"provider": "smtp",
"smtp_host": "smtp.example.com",
"smtp_port": 587,
"default_from_email": "noreply@example.com",
"smtp_username": "replace-with-username",
"smtp_password": "replace-with-password",
"smtp_use_tls": true,
"smtp_use_ssl": false
}
}Resend
{
"is_enabled": true,
"config": {
"provider": "resend",
"resend_api_key": "replace-with-api-key",
"default_from_email": "noreply@example.com"
}
}SendGrid
{
"is_enabled": true,
"config": {
"provider": "sendgrid",
"sendgrid_api_key": "replace-with-api-key",
"default_from_email": "noreply@example.com"
}
}Mailgun
{
"is_enabled": true,
"config": {
"provider": "mailgun",
"mailgun_api_key": "replace-with-api-key",
"mailgun_domain": "mg.example.com",
"default_from_email": "noreply@example.com"
}
}Success Example
{
"success": true,
"message": "Integration updated successfully.",
"data": {
"integration": {
"type": "email",
"is_enabled": true,
"configured": true,
"config": {
"provider": "smtp",
"smtp_host": "smtp.example.com",
"smtp_port": 587,
"default_from_email": "noreply@example.com",
"smtp_username": "replace-with-username",
"smtp_use_tls": true,
"smtp_use_ssl": false,
"has_smtp_password": true,
"has_mailgun_api_key": false,
"has_sendgrid_api_key": false,
"has_resend_api_key": false
},
"updated_at": "2026-11-24T10:00:00Z"
}
}
}Notes
Both is_enabled and config are optional. PATCH merges with saved configuration; omit unchanged secrets to retain them. Required values must exist in the merged configuration when enabled. Saving does not verify provider connectivity. Disable with { "is_enabled": false }; re-enable with { "is_enabled": true } when configuration is complete.
Providers: smtp, resend, sendgrid, mailgun. Send only fields belonging to the selected provider plus shared default_from_email. Use Send Test Email after enabling. It sends to the authenticated administrator's email address.
Required fields when enabled
| Provider | Required fields |
|---|---|
smtp | smtp_host, smtp_port, default_from_email |
resend | resend_api_key, default_from_email |
sendgrid | sendgrid_api_key, default_from_email |
mailgun | mailgun_api_key, mailgun_domain, default_from_email |
The selected provider is also required.
Configuration fields
| Field | Type | Details |
|---|---|---|
provider | enum | Optional in a partial update |
default_from_email | email string | Optional in a partial update |
backend | string | Maximum length: 255 |
smtp_host | string | Maximum length: 255 |
smtp_port | integer | Minimum: 1; Maximum: 65535 |
smtp_username | string | Maximum length: 255; blank allowed |
smtp_password | string | Maximum length: 255; blank allowed; write-only |
smtp_use_tls | boolean | Optional in a partial update |
smtp_use_ssl | boolean | Optional in a partial update |
mailgun_api_key | string | Maximum length: 255; blank allowed; write-only |
mailgun_domain | string | Maximum length: 255 |
sendgrid_api_key | string | Maximum length: 255; blank allowed; write-only |
resend_api_key | string | Maximum length: 255; blank allowed; write-only |
Disable without deleting configuration
{
"is_enabled": false
}Re-enable with complete saved configuration
{
"is_enabled": true
}When enabling SMTP without saved credentials - HTTP 400
{
"success": false,
"message": "Validation failed.",
"errors": {
"config": {
"smtp_host": "This field is required when enabling the integration.",
"smtp_port": "This field is required when enabling the integration.",
"default_from_email": "This field is required when enabling the integration."
}
}
}Applicable errors: 400 invalid/missing configuration or malformed JSON; 401 missing/invalid JWT; 403 administrator access required; 406 unsupported response format; 415 unsupported content type.
Unauthorized - HTTP 401
{
"success": false,
"message": "Authentication credentials were not provided.",
"errors": {}
}Forbidden - HTTP 403
{
"success": false,
"message": "You do not have permission to perform this action.",
"errors": {}
}3. Send Test Email
Send a test email through the enabled email provider to the authenticated administrator.
/admins/platform-settings/integrations/email/test-email/Auth: Required
Headers
Authorization: Bearer {{admin_access_token}}
Content-Type: application/jsonRequest Body
{}Success Example
{
"success": true,
"message": "Test email sent successfully.",
"data": {
"recipient": "admin@example.com"
}
}Notes
Sends a fixed test message to the authenticated administrator's email address. Email integration must be enabled. A custom recipient is not accepted.
Applicable errors: 400 disabled email integration, missing administrator email or malformed JSON; 401; 403; 406; 415. Unhandled provider failures may return 500 without the standard JSON envelope.
Unauthorized - HTTP 401
{
"success": false,
"message": "Authentication credentials were not provided.",
"errors": {}
}Forbidden - HTTP 403
{
"success": false,
"message": "You do not have permission to perform this action.",
"errors": {}
}Email integration disabled - HTTP 400
{
"success": false,
"message": "Validation failed.",
"errors": {
"non_field_errors": [
"Email integration is disabled."
]
}
}Administrator email missing - HTTP 400
{
"success": false,
"message": "Validation failed.",
"errors": {
"non_field_errors": [
"The current admin does not have an email address."
]
}
}