{"_id":"@emailit/node","_rev":"3-23a968ebb957beefff326bd54d6c3925","name":"@emailit/node","dist-tags":{"latest":"2.0.4"},"versions":{"2.0.0":{"name":"@emailit/node","version":"2.0.0","keywords":["emailit","email","api","sdk"],"license":"MIT","_id":"@emailit/node@2.0.0","maintainers":[{"name":"georgezizka","email":"jiri.zizka@funfirst.cz"}],"homepage":"https://emailit.com","dist":{"shasum":"ba291ca7b5e809e9b1fbfe4f4095cb60728dbf25","tarball":"https://registry.npmjs.org/@emailit/node/-/node-2.0.0.tgz","fileCount":55,"integrity":"sha512-4gHjrVWr++vzS/c+G4kbnlQQfTwFwxWqi0Qob+ox81+gRGI35O4aWsZrxpz9q+1NGu1K8x9BO0OcrSfMWFanTQ==","signatures":[{"sig":"MEYCIQD5jxR/jROtwvkMAV00521nfWGsxj9GNkqSu5/L8o/C9AIhAIa/E7+MIlZ2cIQgr5INqnNXz0y6UEHDs1D/6VDGFRBC","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":102037},"main":"./src/index.js","type":"module","engines":{"node":">=18.0.0"},"exports":{".":"./src/index.js"},"gitHead":"e9dbcb7a729bf61fc6bb100eb2e4e0d670f3c574","scripts":{"test":"vitest run","test:watch":"vitest"},"_npmUser":{"name":"georgezizka","email":"jiri.zizka@funfirst.cz"},"_npmVersion":"10.9.3","description":"Node.js SDK for the Emailit Email API","directories":{},"_nodeVersion":"22.18.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.0.18"},"_npmOperationalInternal":{"tmp":"tmp/node_2.0.0_1772705019277_0.8822142115138019","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"@emailit/node","version":"2.0.1","keywords":["emailit","email","api","sdk"],"license":"MIT","_id":"@emailit/node@2.0.1","maintainers":[{"name":"georgezizka","email":"jiri.zizka@funfirst.cz"}],"homepage":"https://emailit.com","dist":{"shasum":"a5606558bcaded1938f0cdd6b1e0c596997953ab","tarball":"https://registry.npmjs.org/@emailit/node/-/node-2.0.1.tgz","fileCount":55,"integrity":"sha512-UqlTG7CWmz7wbaXR8neZeijOs+tmmtAjHUD/pJUQbosMfis1fgwMFx358qxbw1djvVLqTayN3Q84+TG2ka7H6g==","signatures":[{"sig":"MEUCIHJQrFtGuVhLqsMARNDIpf7myUWKGM0Ir/LeoYLxMpuDAiEAnYKtFi0P85tFfagZDdlnXQ1fvbtKsfoPIyEP9+wdHek=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":101972},"main":"./src/index.js","type":"module","engines":{"node":">=18.0.0"},"exports":{".":"./src/index.js"},"gitHead":"e54154e8dfef6a25568792d45a2f1092857b2c7b","scripts":{"test":"vitest run","test:watch":"vitest"},"_npmUser":{"name":"georgezizka","email":"jiri.zizka@funfirst.cz"},"_npmVersion":"10.9.3","description":"Node.js SDK for the Emailit Email API","directories":{},"_nodeVersion":"22.18.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.0.18"},"_npmOperationalInternal":{"tmp":"tmp/node_2.0.1_1772705608789_0.9032510514496512","host":"s3://npm-registry-packages-npm-production"}},"2.0.4":{"name":"@emailit/node","version":"2.0.4","description":"Node.js SDK for the Emailit Email API","type":"module","main":"./src/index.js","exports":{".":"./src/index.js"},"engines":{"node":">=18.0.0"},"scripts":{"test":"vitest run","test:watch":"vitest"},"keywords":["emailit","email","api","sdk"],"homepage":"https://emailit.com","license":"MIT","devDependencies":{"vitest":"^4.0.18"},"repository":{"type":"git","url":"git+https://github.com/emailit/emailit-node.git"},"_id":"@emailit/node@2.0.4","gitHead":"850161d3d4dac0fabb6567c2717b65527570949e","bugs":{"url":"https://github.com/emailit/emailit-node/issues"},"_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-HF6dADb5HKZ720zYa9GpGmkQoCQXOT2XaXTQy8Pk9wLEPidqa5kP9opZi/jh+cxVlqpUOlhLbf1fdIlVp6Ip8A==","shasum":"53a78f9d4639dce4c4758f95bf5f810afd5ec067","tarball":"https://registry.npmjs.org/@emailit/node/-/node-2.0.4.tgz","fileCount":55,"unpackedSize":102136,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@emailit%2fnode@2.0.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIH7XhuAvOpqlZ5IjWzX4NthRUjoToUyTxrNcImELN2qfAiBovt9QKWlmrBUoQkMJHVdFOFTGhGdYpJSwz/U2bWIFMA=="}]},"_npmUser":{"name":"georgezizka","email":"jiri.zizka@funfirst.cz"},"directories":{},"maintainers":[{"name":"georgezizka","email":"jiri.zizka@funfirst.cz"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/node_2.0.4_1772709428916_0.38683870329114445"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-05T10:03:39.150Z","modified":"2026-03-05T11:17:09.426Z","2.0.0":"2026-03-05T10:03:39.449Z","2.0.1":"2026-03-05T10:13:28.962Z","2.0.4":"2026-03-05T11:17:09.066Z"},"license":"MIT","homepage":"https://emailit.com","keywords":["emailit","email","api","sdk"],"description":"Node.js SDK for the Emailit Email API","maintainers":[{"name":"georgezizka","email":"jiri.zizka@funfirst.cz"}],"readme":"# Emailit Node.js\n\n[![Tests](https://img.shields.io/github/actions/workflow/status/emailit/emailit-node/tests.yml?label=tests&style=for-the-badge&labelColor=111827)](https://github.com/emailit/emailit-node/actions)\n[![npm Version](https://img.shields.io/npm/v/@emailit/node?style=for-the-badge&labelColor=111827)](https://www.npmjs.com/package/@emailit/node)\n[![License](https://img.shields.io/github/license/emailit/emailit-node?style=for-the-badge&labelColor=111827)](https://github.com/emailit/emailit-node/blob/main/LICENSE)\n\nThe official Node.js SDK for the [Emailit](https://emailit.com) Email API.\n\n## Requirements\n\n- Node.js 18+\n\n## Installation\n\n```bash\nnpm install @emailit/node\n```\n\n## Getting Started\n\n```js\nimport { Emailit } from '@emailit/node';\n\nconst emailit = new Emailit('your_api_key');\n\nconst email = await emailit.emails.send({\n  from: 'hello@yourdomain.com',\n  to: ['user@example.com'],\n  subject: 'Hello from Emailit',\n  html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>',\n});\n\nconsole.log(email.id);     // em_abc123...\nconsole.log(email.status); // pending\n```\n\nAll service methods return resource objects with direct property access -- just like the Stripe SDK.\n\n## Available Services\n\n| Service | Property | Description |\n|---------|----------|-------------|\n| Emails | `emailit.emails` | Send, list, get, cancel, retry emails |\n| Domains | `emailit.domains` | Create, verify, list, manage sending domains |\n| API Keys | `emailit.apiKeys` | Create, list, manage API keys |\n| Audiences | `emailit.audiences` | Create, list, manage audiences |\n| Subscribers | `emailit.subscribers` | Add, list, manage subscribers in audiences |\n| Templates | `emailit.templates` | Create, list, publish email templates |\n| Suppressions | `emailit.suppressions` | Create, list, manage suppressed addresses |\n| Email Verifications | `emailit.emailVerifications` | Verify email addresses |\n| Email Verification Lists | `emailit.emailVerificationLists` | Create, list, get results, export |\n| Webhooks | `emailit.webhooks` | Create, list, manage webhooks |\n| Contacts | `emailit.contacts` | Create, list, manage contacts |\n| Events | `emailit.events` | List and retrieve events |\n\n## Usage\n\n### Emails\n\n#### Send an email\n\n```js\nconst email = await emailit.emails.send({\n  from: 'hello@yourdomain.com',\n  to: ['user@example.com'],\n  subject: 'Hello from Emailit',\n  html: '<h1>Welcome!</h1>',\n});\n\nconsole.log(email.id);\nconsole.log(email.status);\n```\n\n#### Send with a template\n\n```js\nconst email = await emailit.emails.send({\n  from: 'hello@yourdomain.com',\n  to: 'user@example.com',\n  template: 'welcome_email',\n  variables: {\n    name: 'John Doe',\n    company: 'Acme Inc',\n  },\n});\n```\n\n#### Send with attachments\n\n```js\nimport { readFileSync } from 'node:fs';\n\nconst email = await emailit.emails.send({\n  from: 'invoices@yourdomain.com',\n  to: 'customer@example.com',\n  subject: 'Your Invoice #12345',\n  html: '<p>Please find your invoice attached.</p>',\n  attachments: [\n    {\n      filename: 'invoice.pdf',\n      content: readFileSync('invoice.pdf').toString('base64'),\n      content_type: 'application/pdf',\n    },\n  ],\n});\n```\n\n#### Schedule an email\n\n```js\nconst email = await emailit.emails.send({\n  from: 'reminders@yourdomain.com',\n  to: 'user@example.com',\n  subject: 'Appointment Reminder',\n  html: '<p>Your appointment is tomorrow at 2 PM.</p>',\n  scheduled_at: '2026-01-10T09:00:00Z',\n});\n\nconsole.log(email.status);       // scheduled\nconsole.log(email.scheduled_at); // 2026-01-10T09:00:00Z\n```\n\n#### List emails\n\n```js\nconst emails = await emailit.emails.list({ page: 1, limit: 10 });\n\nfor (const email of emails) {\n  console.log(`${email.id} — ${email.status}`);\n}\n\nif (emails.hasMore()) {\n  // fetch next page\n}\n```\n\n#### Cancel / Retry\n\n```js\nawait emailit.emails.cancel('em_abc123');\nawait emailit.emails.retry('em_abc123');\n```\n\n---\n\n### Domains\n\n```js\n// Create a domain\nconst domain = await emailit.domains.create({\n  name: 'example.com',\n  track_loads: true,\n  track_clicks: true,\n});\nconsole.log(domain.id);\n\n// Verify DNS\nconst verified = await emailit.domains.verify('sd_123');\n\n// List all domains\nconst domains = await emailit.domains.list();\n\n// Get a domain\nconst d = await emailit.domains.get('sd_123');\n\n// Update a domain\nawait emailit.domains.update('sd_123', { track_clicks: false });\n\n// Delete a domain\nawait emailit.domains.delete('sd_123');\n```\n\n---\n\n### API Keys\n\n```js\n// Create an API key\nconst key = await emailit.apiKeys.create({\n  name: 'Production Key',\n  scope: 'full',\n});\nconsole.log(key.key); // only available on create\n\n// List all API keys\nconst keys = await emailit.apiKeys.list();\n\n// Get an API key\nconst k = await emailit.apiKeys.get('ak_123');\n\n// Update an API key\nawait emailit.apiKeys.update('ak_123', { name: 'Renamed Key' });\n\n// Delete an API key\nawait emailit.apiKeys.delete('ak_123');\n```\n\n---\n\n### Audiences\n\n```js\n// Create an audience\nconst audience = await emailit.audiences.create({ name: 'Newsletter' });\nconsole.log(audience.id);\nconsole.log(audience.token);\n\n// List audiences\nconst audiences = await emailit.audiences.list();\n\n// Get an audience\nconst a = await emailit.audiences.get('aud_123');\n\n// Update an audience\nawait emailit.audiences.update('aud_123', { name: 'Updated Newsletter' });\n\n// Delete an audience\nawait emailit.audiences.delete('aud_123');\n```\n\n---\n\n### Subscribers\n\nSubscribers belong to an audience, so the audience ID is always the first argument.\n\n```js\n// Add a subscriber\nconst subscriber = await emailit.subscribers.create('aud_123', {\n  email: 'user@example.com',\n  first_name: 'John',\n  last_name: 'Doe',\n});\n\n// List subscribers in an audience\nconst subscribers = await emailit.subscribers.list('aud_123');\n\n// Get a subscriber\nconst s = await emailit.subscribers.get('aud_123', 'sub_456');\n\n// Update a subscriber\nawait emailit.subscribers.update('aud_123', 'sub_456', {\n  first_name: 'Jane',\n});\n\n// Delete a subscriber\nawait emailit.subscribers.delete('aud_123', 'sub_456');\n```\n\n---\n\n### Templates\n\n```js\n// Create a template\nconst template = await emailit.templates.create({\n  name: 'Welcome',\n  subject: 'Welcome!',\n  html: '<h1>Hi {{name}}</h1>',\n});\n\n// List templates\nconst templates = await emailit.templates.list();\n\n// Get a template\nconst t = await emailit.templates.get('tem_123');\n\n// Update a template\nawait emailit.templates.update('tem_123', { subject: 'New Subject' });\n\n// Publish a template\nawait emailit.templates.publish('tem_123');\n\n// Delete a template\nawait emailit.templates.delete('tem_123');\n```\n\n---\n\n### Suppressions\n\n```js\n// Create a suppression\nconst suppression = await emailit.suppressions.create({\n  email: 'spam@example.com',\n  type: 'hard_bounce',\n  reason: 'Manual suppression',\n});\n\n// List suppressions\nconst suppressions = await emailit.suppressions.list();\n\n// Get a suppression\nconst sup = await emailit.suppressions.get('sup_123');\n\n// Update a suppression\nawait emailit.suppressions.update('sup_123', { reason: 'Updated' });\n\n// Delete a suppression\nawait emailit.suppressions.delete('sup_123');\n```\n\n---\n\n### Email Verifications\n\n```js\nconst result = await emailit.emailVerifications.verify({\n  email: 'test@example.com',\n});\n\nconsole.log(result.status); // valid\nconsole.log(result.score);  // 0.95\nconsole.log(result.risk);   // low\n```\n\n---\n\n### Email Verification Lists\n\n```js\n// Create a verification list\nconst list = await emailit.emailVerificationLists.create({\n  name: 'Marketing List Q1',\n  emails: [\n    'user1@example.com',\n    'user2@example.com',\n    'user3@example.com',\n  ],\n});\nconsole.log(list.id);     // evl_abc123...\nconsole.log(list.status); // pending\n\n// List all verification lists\nconst lists = await emailit.emailVerificationLists.list();\n\n// Get a verification list\nconst vl = await emailit.emailVerificationLists.get('evl_abc123');\nconsole.log(vl.stats.successful_verifications);\n\n// Get verification results\nconst results = await emailit.emailVerificationLists.results('evl_abc123', { page: 1, limit: 50 });\n\nfor (const r of results) {\n  console.log(`${r.email} — ${r.result}`);\n}\n\n// Export results as XLSX\nimport { writeFileSync } from 'node:fs';\nconst response = await emailit.emailVerificationLists.export('evl_abc123');\nwriteFileSync('results.xlsx', response.body);\n```\n\n---\n\n### Webhooks\n\n```js\n// Create a webhook\nconst webhook = await emailit.webhooks.create({\n  name: 'My Webhook',\n  url: 'https://example.com/hook',\n  all_events: true,\n  enabled: true,\n});\nconsole.log(webhook.id);\n\n// List webhooks\nconst webhooks = await emailit.webhooks.list();\n\n// Get a webhook\nconst wh = await emailit.webhooks.get('wh_123');\n\n// Update a webhook\nawait emailit.webhooks.update('wh_123', { enabled: false });\n\n// Delete a webhook\nawait emailit.webhooks.delete('wh_123');\n```\n\n---\n\n### Contacts\n\n```js\n// Create a contact\nconst contact = await emailit.contacts.create({\n  email: 'user@example.com',\n  first_name: 'John',\n  last_name: 'Doe',\n});\nconsole.log(contact.id);\n\n// List contacts\nconst contacts = await emailit.contacts.list();\n\n// Get a contact\nconst c = await emailit.contacts.get('con_123');\n\n// Update a contact\nawait emailit.contacts.update('con_123', { first_name: 'Jane' });\n\n// Delete a contact\nawait emailit.contacts.delete('con_123');\n```\n\n---\n\n### Events\n\n```js\n// List events\nconst events = await emailit.events.list({ type: 'email.delivered' });\n\nfor (const event of events) {\n  console.log(event.type);\n}\n\n// Get an event\nconst event = await emailit.events.get('evt_123');\nconsole.log(event.type);\nconsole.log(event.data.email_id);\n```\n\n## Webhook Events\n\nThe SDK provides typed event classes for all Emailit webhook event types under the events module, plus a `WebhookSignature` class for verifying webhook request signatures.\n\n### Verifying Webhook Signatures\n\n```js\nimport { WebhookSignature, EmailDelivered } from '@emailit/node';\n\nconst rawBody = await request.text();\nconst signature = request.headers.get('x-emailit-signature');\nconst timestamp = request.headers.get('x-emailit-timestamp');\nconst secret = 'your_webhook_signing_secret';\n\ntry {\n  const event = WebhookSignature.verify(rawBody, signature, timestamp, secret);\n\n  // event is automatically typed based on the event type\n  console.log(event.type);     // e.g. \"email.delivered\"\n  console.log(event.event_id); // e.g. \"evt_abc123\"\n\n  // Access the event data\n  const data = event.getEventData();\n\n  if (event instanceof EmailDelivered) {\n    // Handle delivered email\n  }\n} catch (e) {\n  // Invalid signature or timestamp\n  return new Response(e.message, { status: 401 });\n}\n```\n\nYou can disable replay protection by passing `null` for tolerance, or set a custom tolerance in seconds:\n\n```js\n// Skip replay check\nconst event = WebhookSignature.verify(rawBody, signature, timestamp, secret, null);\n\n// Custom 10-minute tolerance\nconst event = WebhookSignature.verify(rawBody, signature, timestamp, secret, 600);\n```\n\n### Available Event Types\n\n**Emails:** `email.accepted`, `email.scheduled`, `email.delivered`, `email.bounced`, `email.attempted`, `email.failed`, `email.rejected`, `email.suppressed`, `email.received`, `email.complained`, `email.clicked`, `email.loaded`\n\n**Domains:** `domain.created`, `domain.updated`, `domain.deleted`\n\n**Audiences:** `audience.created`, `audience.updated`, `audience.deleted`\n\n**Subscribers:** `subscriber.created`, `subscriber.updated`, `subscriber.deleted`\n\n**Contacts:** `contact.created`, `contact.updated`, `contact.deleted`\n\n**Templates:** `template.created`, `template.updated`, `template.deleted`\n\n**Suppressions:** `suppression.created`, `suppression.updated`, `suppression.deleted`\n\n**Email Verifications:** `email_verification.created`, `email_verification.updated`, `email_verification.deleted`\n\n**Email Verification Lists:** `email_verification_list.created`, `email_verification_list.updated`, `email_verification_list.deleted`\n\nEach event type has a corresponding class (e.g. `EmailDelivered`, `DomainCreated`). You can use `instanceof` checks or the `EVENT_TYPE` static property for routing:\n\n```js\nimport { EmailDelivered, EmailBounced, ContactCreated } from '@emailit/node';\n\nif (event instanceof EmailDelivered) {\n  handleDelivered(event);\n} else if (event instanceof EmailBounced) {\n  handleBounce(event);\n} else if (event instanceof ContactCreated) {\n  handleNewContact(event);\n}\n```\n\n## Error Handling\n\nThe SDK throws typed exceptions for API errors:\n\n```js\nimport {\n  AuthenticationException,\n  InvalidRequestException,\n  RateLimitException,\n  UnprocessableEntityException,\n  ApiConnectionException,\n  ApiErrorException,\n} from '@emailit/node';\n\ntry {\n  await emailit.emails.send({ /* ... */ });\n} catch (e) {\n  if (e instanceof AuthenticationException) {\n    // Invalid API key (401)\n  } else if (e instanceof InvalidRequestException) {\n    // Bad request or not found (400, 404)\n  } else if (e instanceof RateLimitException) {\n    // Too many requests (429)\n  } else if (e instanceof UnprocessableEntityException) {\n    // Validation failed (422)\n  } else if (e instanceof ApiConnectionException) {\n    // Network error\n  } else if (e instanceof ApiErrorException) {\n    // Any other API error\n    console.log(e.httpStatus);\n    console.log(e.httpBody);\n    console.log(e.jsonBody);\n  }\n}\n```\n\n## License\n\nMIT -- see [LICENSE](LICENSE) for details.\n","readmeFilename":"README.md","repository":{"type":"git","url":"git+https://github.com/emailit/emailit-node.git"},"bugs":{"url":"https://github.com/emailit/emailit-node/issues"}}