Skip to main content

Quick Start

Send your first email with Sendmator in under 5 minutes. This guide will walk you through the basics.

Prerequisites

  • Sendmator account with API key
  • Ability to make HTTP requests (cURL, Postman, or any HTTP client)

Send Your First Email

Using cURL

curl -X POST https://api.sendmator.com/api/v1/messages/send \
-H "X-API-Key: $SENDMATOR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"recipient_type": "direct_email",
"direct_email": "recipient@example.com",
"subject": "Welcome to our app!",
"content": "<h1>Welcome!</h1><p>Thanks for signing up. We'\''re excited to have you on board.</p><a href=\"https://yourapp.com/dashboard\">Get Started</a>"
}'

Success Response

When your email is sent successfully, you'll receive a response like this:

{
"success": true,
"trigger_id": "211e62ab-2ddf-4032-9305-561fc6eb2102",
"job_id": "10",
"message": "Email queued successfully"
}

Send Email with Template

For more complex emails, use templates:

curl -X POST https://api.sendmator.com/api/v1/messages/send \
-H "X-API-Key: $SENDMATOR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"recipient_type": "direct_email",
"direct_email": "user@example.com",
"template_key": "welcome-email",
"variables": {
"user_name": "John Doe",
"app_name": "YourApp",
"dashboard_url": "https://yourapp.com/dashboard"
}
}'

Error Handling

When errors occur, the API returns appropriate HTTP status codes and error details:

# Example error response (400 Bad Request)
{
"error": {
"type": "validation_error",
"message": "Invalid email address",
"details": {
"field": "to",
"code": "invalid_email"
}
}
}

Track Email Status

Check the status of your sent emails using the trigger_id:

curl -H "X-API-Key: $SENDMATOR_API_KEY" \
https://api.sendmator.com/api/v1/triggers/211e62ab-2ddf-4032-9305-561fc6eb2102

Response includes status and execution details:

{
"id": "211e62ab-2ddf-4032-9305-561fc6eb2102",
"status": "completed",
"created_at": "2024-01-15T10:30:00Z",
"started_at": "2024-01-15T10:30:05Z",
"completed_at": "2024-01-15T10:30:45Z"
}

Possible statuses: pending, processing, completed, failed

Common Patterns

Bulk Email Sending

For multiple emails, make individual API calls:

# Send multiple emails with a simple script
for email in user1@example.com user2@example.com user3@example.com; do
curl -X POST https://api.sendmator.com/api/v1/messages/send \
-H "X-API-Key: $SENDMATOR_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"recipient_type\": \"direct_email\", \"direct_email\": \"$email\", \"subject\": \"Hello\", \"content\": \"<p>Hello from our app!</p>\"}"
done

What's Next?

Now that you've sent your first email, explore these features:

Need Help?