Installation
Get started with Sendmator in just a few steps. Choose your preferred method below.
Get Your API Key
- Sign up for a Sendmator account
- Navigate to your API settings
- Generate a new API key
- Keep your API key secure - never expose it in client-side code. If you want to use in client-side projects, create a publishable key instead (limited permissions - can manage contacts and preferences but cannot trigger messages).
Your API key provides full access to your Sendmator account. Keep it secure and never commit it to version control.
Using the REST API
Sendmator provides a REST API that can be called from any programming language that supports HTTP requests. No SDK installation required - just make HTTP requests to our endpoints.
Example API Call
Here's how to send your first email:
curl -X POST https://api.sendmator.com/api/v1/messages/send \
-H "X-API-KEY: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"recipient_type": "direct_email",
"direct_email": "user@example.com",
"from_email": "noreply@yourdomain.com",
"from_name": "Your App",
"subject": "Hello from Sendmator",
"content": "<h1>Hello World!</h1><p>Welcome to Sendmator!</p>"
}'
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
recipient_type | string | Yes | How to identify the recipient. Options: direct_email, contact, tag, segment, all. |
direct_email | string | Conditional | Recipient's email address. Required when recipient_type is direct_email. |
contact_external_id | string | Conditional | Contact's external ID from your system. Required when recipient_type is contact. |
tag | array | Conditional | Array of tag names (e.g., ["premium", "vip"]). Required when recipient_type is tag. |
segment_id | string | Conditional | Segment UUID. Required when recipient_type is segment. |
from_email | string | Yes | Verified sender email address (e.g., noreply@yourdomain.com). Must be verified in your Sendmator account. |
from_name | string | No | Sender's display name (e.g., Your App). Shows as the friendly name in email clients. |
subject | string | Conditional | Email subject line. Required when not using a template. |
content | string | Conditional | HTML or plain text email content. Required when not using a template. Supports variable substitution like {{contact_first_name}}. |
template_key | string | No | Template identifier to use instead of inline content. If provided, subject and content are loaded from the template. |
variables | object | No | Custom variables for template substitution (e.g., {"company": "Acme Corp", "discount": "20%"}). |
attachment_ids | array | No | Array of file UUIDs to attach to the email. Files must be uploaded first via the Files API. |
metadata | object | No | Custom metadata to store with the message (e.g., {"campaign_id": "summer-2024"}). |
message_category | string | No | Message category for queue routing. Options: transactional (OTP, alerts - priority queue) or promotional (marketing - normal queue). Defaults to transactional. |
triggerAt | string | No | Schedule message for future delivery. ISO 8601 timestamp (e.g., 2024-12-01T10:00:00Z). |
Recipient Types Explained
contact: Send to a stored contact using theirexternal_idtag: Send to all contacts with specific tagssegment: Send to all contacts in a segmentall: Send to all active contactsdirect_email: Send to a single email address without storing as a contactdirect_sms: Send to a single phone number without storing as a contactdirect_whatsapp: Send to a single WhatsApp number without storing as a contactdirect_push: Send to a single device token without storing as a contact
Response
Success Response (201 Created):
{
"success": true,
"trigger_id": "550e8400-e29b-41d4-a716-446655440000",
"job_id": "660f9511-f39c-52e5-b827-557766551111",
"message": "Message queued successfully"
}
Error Response (400 Bad Request):
{
"statusCode": 400,
"message": [
"from_email must be an email",
"direct_email is required when not using template_key"
],
"error": "Bad Request"
}
Error Response (401 Unauthorized):
{
"statusCode": 401,
"message": "Unauthorized",
"error": "Unauthorized"
}
Environment Variables
For security, we recommend storing your API key in environment variables:
# .env file
SENDMATOR_API_KEY=your-api-key-here
Multi-Channel Messages
The /messages/send endpoint is for email-only messages. To send messages across multiple channels (Email, SMS, WhatsApp, Push) simultaneously, use the Multi-Channel Trigger API.
Next Steps
- Authentication - Learn about API authentication
- Quick Start - Send your first email
- Multi-Channel Trigger API - Send across multiple channels
- API Overview - Explore all available endpoints