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
| Header | Purpose |
|---|---|
X-Tenant-ID | Selects tenant-scoped templates, sender settings, provider config, and audit records. |
X-APIKEY | Authorizes the caller and is forwarded when the service fetches tenant secrets. |
X-Hostname | Identifies the caller hostname for audit logging and downstream authorization checks. |
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.
For provider-based sending, configure these tenant properties in the Auth/Tenant system:
| Property | Required | Purpose |
|---|---|---|
email_provider | Yes | Selects whether the resent or smtp configuration is used. |
sender_name | Yes | Display name shown as the sender. |
sender_email | Yes | Sender email address stored as a tenant property. |
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.
Provider credentials are not stored in this service. They must exist as tenant secrets in the Auth/Tenant system.
| Provider | Secret name | Secret value |
|---|---|---|
| Resend | resent | The Resend API key. |
| SMTP | smtp | The SMTP password. |
For SMTP, the username is not stored in the secret. Set it in the tenant property smtp_username.
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.