{"_id":"sendlayer","_rev":"6-f3c674f9d9ef8c18d9a56b8d47843f41","name":"sendlayer","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"sendlayer","version":"1.0.0","keywords":["sendlayer","email","api","sdk","typescript","nodejs","send email","send email api","send email sdk","send email typescript","send email nodejs","send email api typescript","send email api nodejs","sendlayer sdk","sendlayer api","sendlayer typescript","sendlayer nodejs","sendlayer api typescript","sendlayer api nodejs"],"author":"","license":"MIT","_id":"sendlayer@1.0.0","maintainers":[{"name":"sendlayer","email":"accounts@sendlayer.com"}],"dist":{"shasum":"604110441285055915cf5816869faa7a5e7d8f2c","tarball":"https://registry.npmjs.org/sendlayer/-/sendlayer-1.0.0.tgz","fileCount":17,"integrity":"sha512-9DEwEZqQRoj8CUixavQAYto+tijEjDayMjgNeiSlqVrOVOzXOW1zC0WRWYm9r/uUEfPkdhLA5ClLYf5TqRedvg==","signatures":[{"sig":"MEQCICY2CKhwrUWf6WrHnpMMP1BqKu7B7i2W9ErIXv8TMjqSAiAyA8UF8uagYanIb3UaLB9PIXwfRk2Zhrg1uq3IEg2chg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36881},"main":"./dist/index.js","types":"./dist/types/index.d.ts","gitHead":"182b5932013dfbc03665e4e0094f7547fcb307bf","scripts":{"lint":"eslint src/**/*.ts","test":"jest","build":"npm run clean && tsc","clean":"rm -rf dist","format":"prettier --write \"src/**/*.ts\"","test:watch":"jest --watch"},"_npmUser":{"name":"sendlayer","actor":{"name":"sendlayer","type":"user","email":"accounts@sendlayer.com"},"email":"accounts@sendlayer.com"},"_npmVersion":"10.8.2","description":"SendLayer JavaScript SDK","directories":{"dist":"./dist"},"sideEffects":false,"_nodeVersion":"18.20.8","dependencies":{"axios":"^1.6.7"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","dotenv":"^16.4.7","eslint":"^8.57.0","ts-jest":"^29.1.2","prettier":"^3.2.5","typescript":"^5.3.3","@types/jest":"^29.5.14","@types/node":"^20.11.24","@typescript-eslint/parser":"^7.1.0","@typescript-eslint/eslint-plugin":"^7.1.0"},"_npmOperationalInternal":{"tmp":"tmp/sendlayer_1.0.0_1750946902830_0.4996168504225016","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"sendlayer","version":"1.0.1","keywords":["sendlayer","email","api","sdk","typescript","nodejs","send email","send email api","send email sdk","send email typescript","send email nodejs","send email api typescript","send email api nodejs","sendlayer sdk","sendlayer api","sendlayer typescript","sendlayer nodejs","sendlayer api typescript","sendlayer api nodejs"],"author":{"name":"SendLayer","email":"support@sendlayer.com"},"license":"MIT","_id":"sendlayer@1.0.1","maintainers":[{"name":"sendlayer","email":"accounts@sendlayer.com"}],"contributors":[{"url":"https://github.com/gyrationtechs","name":"David Ozokoye"}],"dist":{"shasum":"9278a9f8921cabf73acba76c1ecbb531a5f21159","tarball":"https://registry.npmjs.org/sendlayer/-/sendlayer-1.0.1.tgz","fileCount":17,"integrity":"sha512-U6pgFyhb4bh9qXbUU9ONTs4aCRo8ndL8HEBv4z0Wuvw9W3rGgJmop7KE5vsx4vg7ZSwEl+V139t2648+XX2MQw==","signatures":[{"sig":"MEYCIQCsyxXVlHqeXD3MJppNXseU+i2uGbeNSzMIQbZFr5vpVwIhAK4SCAJ39PlNrDiM1pWpF36jvP/I29lpKKRTDRoKhzMZ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37337},"main":"./dist/index.js","types":"./dist/types.d.ts","gitHead":"2fd9d006436e298463609eeee28db7bcb935decd","scripts":{"lint":"eslint src/**/*.ts","test":"jest","build":"npm run clean && tsc","clean":"rm -rf dist","format":"prettier --write \"src/**/*.ts\"","test:watch":"jest --watch"},"_npmUser":{"name":"sendlayer","email":"accounts@sendlayer.com"},"_npmVersion":"10.8.2","description":"SendLayer JavaScript SDK","directories":{"dist":"./dist"},"sideEffects":false,"_nodeVersion":"18.20.8","dependencies":{"axios":"^1.6.7"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","dotenv":"^16.4.7","eslint":"^8.57.0","ts-jest":"^29.1.2","prettier":"^3.2.5","typescript":"^5.3.3","@types/jest":"^29.5.14","@types/node":"^20.11.24","@typescript-eslint/parser":"^7.1.0","@typescript-eslint/eslint-plugin":"^7.1.0"},"_npmOperationalInternal":{"tmp":"tmp/sendlayer_1.0.1_1764684926404_0.9842447521465483","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"sendlayer","version":"1.0.2","keywords":["sendlayer","email","send email","send email api","send email sdk","send email typescript","send email nodejs","sendlayer sdk","sendlayer api","sendlayer typescript","sendlayer nodejs"],"author":{"name":"SendLayer","email":"support@sendlayer.com"},"license":"MIT","_id":"sendlayer@1.0.2","maintainers":[{"name":"sendlayer","email":"accounts@sendlayer.com"}],"contributors":[{"url":"https://github.com/gyrationtechs","name":"David Ozokoye"}],"dist":{"shasum":"3575ec7d9f2cfeebbf2ab0f6a65c639a05ba889d","tarball":"https://registry.npmjs.org/sendlayer/-/sendlayer-1.0.2.tgz","fileCount":17,"integrity":"sha512-UGFcj7c+jO90fSgxoMBCtap59kjIG8yWq3BGIg6WditMb3rcZNC3z/h5WWLTS1Xu9Q9N41p/juV2CupuoCwkZg==","signatures":[{"sig":"MEUCIC2/eFdwFFMccu8+07f7Lq4pHjuqUcIpJJlvf6650+/DAiEAl/U9B2S/xDLt/Co6V30Gv9oErL09/V3S+fXVsddgyTs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37118},"main":"./dist/index.js","types":"./dist","gitHead":"b524231afb7309c42975a59fdb2b99850d1c7d20","scripts":{"lint":"eslint src/**/*.ts","test":"jest","build":"npm run clean && tsc","clean":"rm -rf dist","format":"prettier --write \"src/**/*.ts\"","test:watch":"jest --watch"},"_npmUser":{"name":"sendlayer","email":"accounts@sendlayer.com"},"_npmVersion":"10.8.2","description":"SendLayer JavaScript SDK","directories":{"dist":"./dist"},"sideEffects":false,"_nodeVersion":"18.20.8","dependencies":{"axios":"^1.6.7"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","dotenv":"^16.4.7","eslint":"^8.57.0","ts-jest":"^29.1.2","prettier":"^3.2.5","typescript":"^5.3.3","@types/jest":"^29.5.14","@types/node":"^20.11.24","@typescript-eslint/parser":"^7.1.0","@typescript-eslint/eslint-plugin":"^7.1.0"},"_npmOperationalInternal":{"tmp":"tmp/sendlayer_1.0.2_1765521458415_0.8114942521554309","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"sendlayer","version":"1.0.3","keywords":["sendlayer","email","send email","send email api","send email sdk","send email typescript","send email nodejs","sendlayer sdk","sendlayer api","sendlayer typescript","sendlayer nodejs"],"author":{"name":"SendLayer","email":"support@sendlayer.com"},"license":"MIT","_id":"sendlayer@1.0.3","maintainers":[{"name":"sendlayer","email":"accounts@sendlayer.com"}],"contributors":[{"url":"https://github.com/gyrationtechs","name":"David Ozokoye"}],"dist":{"shasum":"96e5490300d486562e17d80696b915d5ab043dcd","tarball":"https://registry.npmjs.org/sendlayer/-/sendlayer-1.0.3.tgz","fileCount":17,"integrity":"sha512-9dVeHCkVJX0G0IoLFJqUXBzPP7QA9+q0S8tZF+fdLyWSyqaRzGG30hGaZ5eITxH02HdvNeF3Bf0kd5JyFp77mg==","signatures":[{"sig":"MEUCIQDdM38e4FYd7erSW8yKJzgvI3nOrC6cBQeulxEe7cRhKgIgLAkP15WvAegKQv6OK7Yquhc8cFGB69eC5mgpXiJDA6Y=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37119},"main":"./dist/index.js","types":"./dist","gitHead":"7b5038417d8d6505584236f2f73db91c0004f38a","scripts":{"lint":"eslint src/**/*.ts","test":"jest","build":"npm run clean && tsc","clean":"rm -rf dist","format":"prettier --write \"src/**/*.ts\"","test:watch":"jest --watch"},"_npmUser":{"name":"sendlayer","email":"accounts@sendlayer.com"},"_npmVersion":"10.8.2","description":"SendLayer JavaScript SDK","directories":{"dist":"./dist"},"sideEffects":false,"_nodeVersion":"18.20.8","dependencies":{"axios":"^1.6.7"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","dotenv":"^16.4.7","eslint":"^8.57.0","ts-jest":"^29.1.2","prettier":"^3.2.5","typescript":"^5.3.3","@types/jest":"^29.5.14","@types/node":"^20.11.24","@typescript-eslint/parser":"^7.1.0","@typescript-eslint/eslint-plugin":"^7.1.0"},"_npmOperationalInternal":{"tmp":"tmp/sendlayer_1.0.3_1770630365362_0.13847550069742187","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"sendlayer","version":"1.1.0","description":"SendLayer JavaScript SDK","main":"./dist/index.js","directories":{"dist":"./dist"},"types":"./dist","sideEffects":false,"scripts":{"clean":"rm -rf dist","build":"npm run clean && tsc","test":"jest","test:watch":"jest --watch","lint":"eslint src/**/*.ts","format":"prettier --write \"src/**/*.ts\""},"keywords":["sendlayer","email api","send email nodejs"],"author":{"name":"SendLayer","email":"support@sendlayer.com"},"contributors":[{"name":"David Ozokoye","url":"https://github.com/gyrationtechs"}],"license":"MIT","devDependencies":{"@types/jest":"^29.5.14","@types/node":"^20.11.24","@typescript-eslint/eslint-plugin":"^7.1.0","@typescript-eslint/parser":"^7.1.0","dotenv":"^16.4.7","eslint":"^8.57.0","jest":"^29.7.0","prettier":"^3.2.5","ts-jest":"^29.1.2","typescript":"^5.3.3"},"dependencies":{"axios":"^1.19.0"},"_id":"sendlayer@1.1.0","gitHead":"5edc0aaa6534a775057fc2f71168f94e26b44179","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Be6KHD1uUTJijZbmwiqUuyS0vEP5fENaeIyuZlVxVV/pcw1FyDXHoWmoRI0KxNENf6Td6jrA3zTQYR8L4q04Ag==","shasum":"7db8d9c8800e4fb3436928e413e961f25c55e8eb","tarball":"https://registry.npmjs.org/sendlayer/-/sendlayer-1.1.0.tgz","fileCount":18,"unpackedSize":52564,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCvRcVr6H6H9kXFCkyspnGaOk1S/w9a6ssyWVqOYflyxwIhAKCa75FuMuOFhie2Lk1TeuuEbhXKZf7coILNJ7j4S1FN"}]},"_npmUser":{"name":"sendlayer","email":"accounts@sendlayer.com"},"maintainers":[{"name":"ndozor","email":"davidozokoye@gmail.com"},{"name":"sendlayer","email":"accounts@sendlayer.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sendlayer_1.1.0_1787342148588_0.010124758351356178"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-26T14:08:22.829Z","modified":"2026-08-21T19:55:48.891Z","1.0.0":"2025-06-26T14:08:23.019Z","1.0.1":"2025-12-02T14:15:26.591Z","1.0.2":"2025-12-12T06:37:38.558Z","1.0.3":"2026-02-09T09:46:05.507Z","1.1.0":"2026-08-21T19:55:48.719Z"},"author":{"name":"SendLayer","email":"support@sendlayer.com"},"license":"MIT","keywords":["sendlayer","email api","send email nodejs"],"description":"SendLayer JavaScript SDK","contributors":[{"name":"David Ozokoye","url":"https://github.com/gyrationtechs"}],"maintainers":[{"name":"ndozor","email":"davidozokoye@gmail.com"},{"name":"sendlayer","email":"accounts@sendlayer.com"}],"readme":"<a href=\"https://sendlayer.com\">\n<picture>\n  <source media=\"(prefers-color-scheme: light)\" srcset=\"https://sendlayer.com/wp-content/themes/sendlayer-theme/assets/images/svg/logo-dark.svg\">\n  <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://sendlayer.com/wp-content/themes/sendlayer-theme/assets/images/svg/logo-light.svg\">\n  <img alt=\"SendLayer Logo\" width=\"200px\" src=\"https://sendlayer.com/wp-content/themes/sendlayer-theme/assets/images/svg/logo-light.svg\">\n</picture>\n</a>\n\n### SendLayer Node.js SDK\n\nThe official JavaScript SDK for interacting with the SendLayer API, providing a simple and intuitive interface for sending emails, managing webhooks, and retrieving email events. Supports both CommonJS and ES Modules.\n\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE) ![NPM Version](https://img.shields.io/npm/v/sendlayer) [![Publish to npm Registry](https://github.com/SendLayer/sendlayer-node/actions/workflows/publish.yaml/badge.svg)](https://github.com/SendLayer/sendlayer-node/actions/workflows/publish.yaml)\n\n\n## Installation\n\n```bash\nnpm install sendlayer\n```\n\n## Configuration\n\nPass an optional config object as the second argument:\n\n```javascript\nconst sendlayer = new SendLayer('your-api-key', {\n  timeout: 30000,               // request timeout in ms (default: 30000)\n  attachmentURLTimeout: 30000,  // remote attachment fetch timeout in ms\n  axios: {                      // extra options for the underlying axios client\n    headers: { 'X-Custom-Header': 'value' }\n  }\n});\n```\n\nRequests time out after 30 seconds by default and reject with `SendLayerError`.\nCustom `axios.headers` are merged with the SDK's own, so authentication is\npreserved.\n\n## Usage\n\n### Sending an Email\n\n```javascript\nimport { SendLayer } from 'sendlayer';\n\n// Initialize the client\nconst sendlayer = new SendLayer('your-api-key');\n\n\nconst params = {\n  from: 'sender@example.com',\n  to: 'recipient@example.com', // or array of recipients\n  subject: 'Test Email',\n  text: 'This is a test email'\n}\n\n// Send a simple email\nconst response = await sendlayer.Emails.send(params);\n\nconsole.log('Email sent! Message ID:', response.MessageID);\n```\n\n### HTML Email with Plain-Text Fallback\n\nSupply both `html` and `text` and both parts are sent -- recommended for\ndeliverability. `ContentType` is reported to the API as `HTML` whenever an HTML\nbody is present, and as `Text` when only `text` is supplied.\n\n```javascript\nconst response = await sendlayer.Emails.send({\n  from: 'sender@example.com',\n  to: 'recipient@example.com',\n  subject: 'Welcome!',\n  text: 'Welcome to our platform!',\n  html: '<h1>Welcome!</h1><p>Welcome to our platform!</p>'\n});\n```\n\nSending Emails with additional parameters\n\n```javascript\nimport { SendLayer } from 'sendlayer';\n\n// Initialize the client\nconst sendlayer = new SendLayer('your-sendlayer-api-key');\n\nconst params = {\n  from: {email: 'sender@example.com', name: 'Test Sender'},\n  to: [\n    { email: 'recipient1@example.com', name: 'Recipient 1' },\n    { email: 'recipient2@example.com', name: 'Recipient 2' }\n  ], \n  subject: 'Test Email',\n  html: '<p>This is a test email</p>', // or text for plain text emails\n  text: 'This is a test email', // optional, for plain text version\n  cc: [{ email: 'cc@example.com', name: 'CC Recipient' }], // optional\n  bcc: [{ email: 'bcc@example.com', name: 'BCC Recipient' }], // optional\n  replyTo: [{ email: 'reply@example.com', name: 'Reply To' }], // optional\n  tags: ['tag1', 'tag2'], // optional\n  headers: { 'X-Custom-Header': 'value' }, // optional\n  attachments: [{ // optional\n    path: 'path/to/file.pdf',\n    type: 'application/pdf',\n  }]\n}\n\n// Send an email with additional parameters\nconst response = await sendlayer.Emails.send(params);\n\nconsole.log('Email Sent successfully! MessageID:', response.MessageID)\n```\n\n### Events\n\n```javascript\nimport { SendLayer } from 'sendlayer';\n\n// Initialize the client\nconst sendlayer = new SendLayer('your-api-key');\n\n\n// Get all events\nconst allEvents = await sendlayer.Events.get();\n\nconsole.log('All Events:', allEvents);\n\n// Get events with optional filters\nconst params = {\n  startDate: new Date(Date.now() - 24 * 60 * 60 * 1000), // optional, last 24 hours\n  endDate: new Date(), // optional\n  event: 'opened', // optional, filter by event type\n}\nconst filteredEvents = await sendlayer.Events.get(params);\n\nconsole.log('Filtered Events', filteredEvents)\n```\n\n### Webhooks\n\n```javascript\nimport { SendLayer } from 'sendlayer';\n\n// Initialize the client\nconst sendlayer = new SendLayer('your-api-key');\n\n// Create a webhook\n// Webhook event options: bounce, click, open, unsubscribe, complaint, delivery\nconst params = {\n  url: 'https://your-domain.com/webhook',\n  event: 'open'\n}\n\nconst webhook = await sendlayer.Webhooks.create(params);\nconsole.log('Webhook created:', webhook);\n\n// Get all webhooks\nconst allWebhooks = await sendlayer.Webhooks.get();\nconsole.log('Webhooks:', allWebhooks);\n\n// Delete a webhook\nawait sendlayer.Webhooks.delete(123);\n```\n\n## Error Handling\n\nEvery SDK error extends `SendLayerError`, so one `catch` handles them all. Use\n`instanceof` when you need to branch:\n\n```javascript\nimport {\n  SendLayer,\n  SendLayerError,\n  SendLayerRateLimitError,\n  SendLayerValidationError\n} from 'sendlayer';\n\ntry {\n  await sendlayer.Emails.send({\n    from: 'sender@example.com',\n    to: 'recipient@example.com',\n    subject: 'Test Email',\n    text: 'This is a test plain text email message'\n  });\n} catch (error) {\n  if (error instanceof SendLayerRateLimitError) {\n    console.error('Rate limited:', error.message);\n  } else if (error instanceof SendLayerValidationError) {\n    console.error('Invalid request:', error.message);\n  } else if (error instanceof SendLayerError) {\n    console.error(`SendLayer error ${error.statusCode}:`, error.message);\n  }\n}\n```\n\n### Error Types\n\n- `SendLayerError`: base error for everything the SDK throws\n- `SendLayerAuthenticationError`: invalid API key (401)\n- `SendLayerValidationError`: invalid parameters, for 400 and 422 as well as\n  input the SDK rejects locally\n- `SendLayerNotFoundError`: resource not found (404)\n- `SendLayerRateLimitError`: rate limit exceeded (429)\n- `SendLayerInternalServerError`: internal server error (500 only)\n- `SendLayerAPIError`: any status not covered above, including other 5xx\n\n### Error Details\n\nEvery error carries the same properties, so you can read them without first\nnarrowing to a subclass:\n\n| Property | Description |\n| --- | --- |\n| `message` | The API's own message text, or the SDK's message for local errors |\n| `statusCode` | HTTP status of the response; `undefined` for local errors |\n| `response` | Decoded response body, or `undefined` when unavailable |\n| `errors` | Raw SendLayer `Errors` entries, each with a numeric `Code` and `Message` |\n| `codes` | The numeric codes from `errors`, for convenient branching |\n\n```javascript\ntry {\n  await sendlayer.Emails.send(params);\n} catch (error) {\n  console.error(error.message);        // e.g. \"Recipient email is suppressed\"\n\n  for (const entry of error.errors) {\n    console.error(entry.Code, entry.Message);   // e.g. 14 Recipient email is suppressed\n  }\n\n  if (error.codes.includes(14)) {\n    // recipient suppressed\n  }\n}\n```\n\n`errors` is an empty array when the SDK raises the error locally (input\nvalidation, network failures) and when the API returns a body that isn't the\nJSON `Errors` shape, so check `error.errors.length` before relying on it.\n\n`message` holds the API's text verbatim, joining multiple messages with `; `.\nNote that `SendLayerAPIError` is the one type whose `message` keeps an\n`API Error <status>: ` prefix.\n\nThe numeric `Code` values are a fixed set defined by the API -- see the\n[SendLayer error codes reference](https://developers.sendlayer.com/api-reference/error-codes)\nfor the full table (`14` = recipient suppressed, `17` = email quota reached,\n`32` = domain not activated, and so on).\n\n\n## More Details\nTo learn more about using the SendLayer SDK, be sure to check our [Developer Documentation](https://developers.sendlayer.com/sdks/nodejs).\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for a list of changes and version history.\n\n\n## License\n\nMIT License - see [LICENSE](./LICENSE) file for details ","readmeFilename":"README.md"}