Локализовано с помощью ИИ
{
  "name": "Ваша компания",
  "email": "hello@yourdomain.com"
}
{
  "name": "Иван Иванов", 
  "email": "ivan@example.com"
}
{
  "filename": "счет.pdf",
  "content": "base64-encoded-content",
  "type": "application/pdf",
  "disposition": "attachment"
}
{
  "id": "email_abc123def456",
  "status": "sent",
  "from": "hello@yourdomain.com",
  "to": ["user@example.com"],
  "subject": "Добро пожаловать в наш сервис!",
  "created_at": "2024-01-15T10:30:00Z",
  "scheduled_at": null
}
{
  "id": "email_abc123def456",
  "status": "delivered",
  "from": {
    "name": "Ваша компания",
    "email": "hello@yourdomain.com"
  },
  "to": [
    {
      "name": "Иван Иванов",
      "email": "ivan@example.com"
    }
  ],
  "subject": "Добро пожаловать в наш сервис!",
  "html": "<h1>Добро пожаловать!</h1><p>Спасибо за регистрацию.</p>",
  "text": "Добро пожаловать!\n\nСпасибо за регистрацию.",
  "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": ["приветствие", "онбординг"],
  "metadata": {
    "user_id": "12345",
    "campaign": "welcome_series"
  }
}
{
  "data": [
    {
      "id": "email_abc123def456",
      "status": "delivered",
      "from": "hello@yourdomain.com",
      "to": ["ivan@example.com"],
      "subject": "Добро пожаловать в наш сервис!",
      "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": "Email адрес получателя неверен",
    "param": "to"
  }
}
{
  "error": {
    "type": "validation_error",
    "code": "missing_required_field",
    "message": "Поле темы обязательно для заполнения",
    "param": "subject"
  }
}
{
  "error": {
    "type": "resource_error",
    "code": "email_not_found",
    "message": "Письмо с указанным ID не найдено"
  }
}
{
  "error": {
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded",
    "message": "Слишком много запросов. Превышен лимит скорости."
  }
}
const response = await emailit.emails.send({
  from: 'welcome@yourdomain.com',
  to: 'новыйпользователь@example.com',
  template: 'welcome-template',
  variables: {
    name: 'Иван Иванов',
    company: 'ООО "Рога и копыта"',
    activation_url: 'https://yourdomain.com/activate?token=abc123'
  }
})
const response = await emailit.emails.send({
  from: 'счета@yourdomain.com',
  to: 'клиент@example.com',
  subject: 'Ваш счет №12345',
  html: '<p>Счет во вложении.</p>',
  attachments: [
    {
      filename: 'счет-12345.pdf',
      content: 'JVBERi0xLjQKJcOkw7zDqc...', // base64 кодировка
      type: 'application/pdf'
    }
  ]
})
const response = await emailit.emails.send({
  from: 'напоминания@yourdomain.com',
  to: 'пользователь@example.com',
  subject: 'Напоминание о встрече',
  html: '<p>Ваша встреча завтра в 14:00.</p>',
  scheduled_at: '2024-01-16T13:00:00Z' // Отправить за час до встречи
})
const emails = [
  {
    from: 'рассылка@yourdomain.com',
    to: 'пользователь1@example.com',
    subject: 'Еженедельная рассылка',
    template: 'newsletter',
    variables: { name: 'Алиса' }
  },
  {
    from: 'рассылка@yourdomain.com',
    to: 'пользователь2@example.com', 
    subject: 'Еженедельная рассылка',
    template: 'newsletter',
    variables: { name: 'Борис' }
  }
]

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