Learn how to programmatically send emails using our simple API.
All API requests require authentication using your API key. You can find your API key in the dashboard settings.
/v1/send
{ "recipient": "string", // Email address of the recipient (required) "email_type": "string", // Type of email to send (required) "data": { // Custom data to be used in the email template (optional) [key: string]: any // Any key-value pairs needed for your template } }
recipient
- Valid email address of the recipientemail_type
- String identifier for the email template type{ "success": true, "message": "Email sent successfully", "data": { "id": "uuid", // Email record ID "recipient": "string", // Recipient email address "sentAt": "string", // ISO date string of when the email was sent "type": "string" // The email type that was sent } }
The API is limited to 10 requests per second per API key. If you exceed this limit, you'll receive a 429 Too Many Requests response.
400 Bad Request
- Missing required fields or invalid email type
401 Unauthorized
- Invalid or missing API key
404 Not Found
- Email settings not found for the specified type
429 Too Many Requests
- Rate limit exceeded
500 Internal Server Error
- Server error
We recommend using the SDK for TypeScript projects. For more information, see the documentation.
import { EmailssarySDK } from 'emailssary-sdk';
const sdk = new EmailssarySDK('your-api-key');
async function sendWelcomeEmail() {
try {
const response = await sdk.sendEmail({
recipient: 'user@example.com',
email_type: 'welcome_email',
data: {
username: 'JohnDoe',
// Add any template variables here
}
});
console.log('Email sent:', response);
} catch (error) {
console.error('Error sending email:', error);
}
}