{
  "name": "Your Company",
  "email": "hello@yourdomain.com"
}
{
  "name": "John Doe", 
  "email": "john@example.com"
}
{
  "filename": "invoice.pdf",
  "content": "base64-encoded-content",
  "type": "application/pdf",
  "disposition": "attachment"
}
{
  "id": "email_abc123def456",
  "status": "sent",
  "from": "hello@yourdomain.com",
  "to": ["user@example.com"],
  "subject": "Welcome to our service!",
  "created_at": "2024-01-15T10:30:00Z",
  "scheduled_at": null
}
{
  "id": "email_abc123def456",
  "status": "delivered",
  "from": {
    "name": "Your Company",
    "email": "hello@yourdomain.com"
  },
  "to": [
    {
      "name": "John Doe",
      "email": "john@example.com"
    }
  ],
  "subject": "Welcome to our service!",
  "html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
  "text": "Welcome!\n\nThanks for signing up.",
  "created_at": "2024-01-15T10:30:00Z",
  "sent_at": "2024-01-15T10:30:05Z",
  "delivered_at": "2024-01-15T10:30:15Z",
  "opened_at": "2024-01-15T11:45:22Z",
  "clicks": [
    {
      "url": "https://yourdomain.com/welcome",
      "clicked_at": "2024-01-15T11:46:10Z"
    }
  ],
  "tags": ["welcome", "onboarding"],
  "metadata": {
    "user_id": "12345",
    "campaign": "welcome_series"
  }
}
{
  "data": [
    {
      "id": "email_abc123def456",
      "status": "delivered",
      "from": "hello@yourdomain.com",
      "to": ["john@example.com"],
      "subject": "Welcome to our service!",
      "created_at": "2024-01-15T10:30:00Z",
      "delivered_at": "2024-01-15T10:30:15Z"
    }
  ],
  "has_more": true,
  "next_cursor": "email_xyz789abc123"
}
{
  "id": "email_abc123def456",
  "status": "cancelled",
  "cancelled_at": "2024-01-15T09:15:00Z"
}
{
  "id": "email_def456ghi789",
  "original_id": "email_abc123def456",
  "status": "sent",
  "created_at": "2024-01-15T14:20:00Z"
}
{
  "error": {
    "type": "validation_error",
    "code": "invalid_email",
    "message": "The recipient email address is invalid",
    "param": "to"
  }
}
{
  "error": {
    "type": "validation_error",
    "code": "missing_required_field",
    "message": "The subject field is required",
    "param": "subject"
  }
}
{
  "error": {
    "type": "resource_error",
    "code": "email_not_found",
    "message": "No email found with the provided ID"
  }
}
{
  "error": {
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded",
    "message": "Too many requests. Rate limit exceeded."
  }
}
const response = await emailit.emails.send({
  from: 'welcome@yourdomain.com',
  to: 'newuser@example.com',
  template: 'welcome-template',
  variables: {
    name: 'John Doe',
    company: 'Acme Inc',
    activation_url: 'https://yourdomain.com/activate?token=abc123'
  }
})
const response = await emailit.emails.send({
  from: 'invoices@yourdomain.com',
  to: 'customer@example.com',
  subject: 'Your Invoice #12345',
  html: '<p>Please find your invoice attached.</p>',
  attachments: [
    {
      filename: 'invoice-12345.pdf',
      content: 'JVBERi0xLjQKJcOkw7zDqc...', // base64 encoded
      type: 'application/pdf'
    }
  ]
})
const response = await emailit.emails.send({
  from: 'reminders@yourdomain.com',
  to: 'user@example.com',
  subject: 'Appointment Reminder',
  html: '<p>Your appointment is tomorrow at 2 PM.</p>',
  scheduled_at: '2024-01-16T13:00:00Z' // Send 1 hour before appointment
})
const emails = [
  {
    from: 'newsletter@yourdomain.com',
    to: 'user1@example.com',
    subject: 'Weekly Newsletter',
    template: 'newsletter',
    variables: { name: 'Alice' }
  },
  {
    from: 'newsletter@yourdomain.com',
    to: 'user2@example.com', 
    subject: 'Weekly Newsletter',
    template: 'newsletter',
    variables: { name: 'Bob' }
  }
]

const responses = await Promise.all(
  emails.map(email => emailit.emails.send(email))
)