Request Requirements
Required headers on every request

Every endpoint requires these headers. Missing any of them returns 400.

X-Tenant-ID: <tenant-uuid>
X-APIKEY: <api-key>
X-Hostname: <calling-hostname>
Content-Type: application/json
HeaderPurpose
X-Tenant-IDSelects tenant-scoped templates, sender settings, provider config, and audit records.
X-APIKEYAuthorizes the caller and is forwarded when the service fetches tenant secrets.
X-HostnameIdentifies the caller hostname for audit logging and downstream authorization checks.
API Key
Caller key configuration

The caller must send a valid API key in X-APIKEY.

The sendByEmail setting is configured in the key store, not in tenant properties.

If the request sends raw email addresses like { "email": "recipient@example.com" }, the API key must have this property:

sendByEmail = true

1 is also accepted instead of true. If this property is missing, the caller can only send to recipients resolved by userId.

Tenant Properties
Required tenant configuration

For provider-based sending, configure these tenant properties in the Auth/Tenant system:

PropertyRequiredPurpose
email_providerYesSelects whether the resent or smtp configuration is used.
sender_nameYesDisplay name shown as the sender.
sender_emailYesSender email address stored as a tenant property.
SMTP Settings
Additional configuration for SMTP tenants

If email_provider=smtp, configure these additional tenant properties:

smtp_username
smtp_host
smtp_port

For SMTP tenants, smtp_username is used as the effective sender email address.

Tenant Secrets
Provider credentials are loaded dynamically

Provider credentials are not stored in this service. They must exist as tenant secrets in the Auth/Tenant system.

ProviderSecret nameSecret value
ResendresentThe Resend API key.
SMTPsmtpThe SMTP password.

For SMTP, the username is not stored in the secret. Set it in the tenant property smtp_username.

Example
Direct send with all required headers
curl -X POST "https://email.magicrunez.com/send" \
  -H "Content-Type: application/json" \
  -H "X-Tenant-ID: <tenant-uuid>" \
  -H "X-APIKEY: <api-key>" \
  -H "X-Hostname: app.example.com" \
  -d '{
    "subject": "Welcome to MagicStack",
    "htmlBody": "<h1>Hello</h1><p>Your account is ready.</p>",
    "to": [{ "email": "recipient@example.com" }]
  }'

See Send Email for full direct-send and template-send request bodies.