Core Concepts
Understand the core concepts and architecture behind Metigan. This section covers the fundamental principles that make Metigan a powerful email infrastructure platform.
Architecture Overview
Metigan is built on a modern, scalable architecture designed to handle high volumes of emails with reliability and performance. The SDK provides a simple interface while handling complex operations behind the scenes.
RESTful API
Metigan uses a RESTful API design, making it easy to integrate with any programming language or framework. All operations follow standard HTTP methods and status codes.
Type Safety
Built with TypeScript from the ground up, Metigan provides complete type definitions and type safety out of the box. No additional type packages needed.
Scalable Infrastructure
Metigan's infrastructure is designed to scale automatically, handling everything from single emails to millions of messages per day.
Developer Experience
Simple, intuitive API design with comprehensive documentation, examples, and tooling to make integration as smooth as possible.
Key Components
Metigan consists of several key components that work together to provide a complete email solution:
Email API
Send transactional and marketing emails with support for HTML, templates, attachments, and advanced features like tracking and analytics.
View Email API →Contact Management
Manage contacts, subscribers, and customer data with built-in validation, deduplication, and segmentation capabilities.
View Contacts API →Templates & Forms
Create reusable email templates and build custom forms with drag-and-drop form builder for collecting leads and subscriptions.
View Templates API →Webhooks & Events
Receive real-time notifications about email events, form submissions, and other actions through webhooks.
View Webhooks API →Basic Usage Pattern
Here's the typical pattern for using Metigan in your application:
import Metigan from 'metigan';
import type { EmailApiResponse, EmailSuccessResponse } from 'metigan';
// 1. Initialize the client
const metigan = new Metigan({
apiKey: process.env.METIGAN_API_KEY!
});
// 2. Type guard for responses
function isEmailSuccess(response: EmailApiResponse): response is EmailSuccessResponse {
return 'success' in response && response.success === true;
}
// 3. Make API calls
async function sendEmail() {
try {
const result = await metigan.email.sendEmail({
from: 'sender@example.com',
recipients: ['recipient@example.com'],
subject: 'Hello',
content: '<p>Hello World!</p>'
});
// 4. Handle responses with type safety
if (isEmailSuccess(result)) {
console.log('Success!', result.successfulEmails);
} else {
console.error('Error:', result.message || result.error);
}
} catch (error) {
// 5. Handle errors
console.error('Exception:', error);
}
}Now that you understand the core concepts, check out the Error Handling guideand Rate Limits documentation to learn about handling errors and managing quotas.