Node.js SDK
The official Node.js SDK for Zyntra lets you easily interact with the Zyntra API to manage mailboxes and read emails in automated tests or backend processes.
Installation
npm install zyntramail-api
Getting an API key
- Go to https://app.zyntra.app
- Register or sign in
- Navigate to the API Keys section
- Generate a new key and copy it
Getting your Team ID
To interact with mailboxes, you’ll need your Team ID, which is part of the email address (e.g. [email protected]
).
You can find your Team ID in the Zyntra web app:
- Go to https://app.zyntra.app
- Look at the bottom-left corner of the sidebar
- Copy the Team ID using the clipboard icon
It will look something like:
f72c2547
Use this value when constructing inbox addresses in your tests or API calls.
Environment variables (optional)
You can set the following environment variables to simplify SDK usage:
ZYNTRA_API_KEY
: API key used for authentication.ZYNTRA_TEAM_ID
: Team ID used when generating email addresses.
These allow you to skip passing apiKey
and teamId
directly:
const client = new ZyntraClient(); // Uses env vars if defined
Usage
import { ZyntraClient } from 'zyntramail-api';
const client = new ZyntraClient({
apiKey: 'your-api-key',
teamId: 'your-team-id',
});
const inbox = client.generateEmail();
console.log('📮 Generated inbox:', inbox);
// This method uses server-side long polling (~30s),
// so retries are not needed
const lastEmail = await client.getLastEmail(inbox);
console.log('📬 Last email subject:', lastEmail.subject);
// Get list of emails in a mailbox
const emails = await client.getEmails('[email protected]');
// Get single email by UUID
const email = await client.getEmailById('messageUuid');
// Delete email by UUID
await client.deleteEmail('messageUuid');
// Get attachments for an email
const attachments = await client.getAttachments('messageUuid');
// Download a specific attachment
const file = await client.downloadAttachment('attachmentUuid');
Methods
getEmails(inbox: string): Promise<EmailPreview[]>
Returns a list of email previews for the specified inbox.
getEmailById(uuid: string): Promise<Email>
Returns full email content including body, HTML, headers, and attachments.
deleteEmail(uuid: string): Promise<void>
Deletes a specific email from the inbox.
getLastEmail(inbox: string): Promise<Email>
Waits for the next email in the specified inbox.
Uses long-polling on the server (up to ~30 seconds), so you do not need to implement retry logic manually.
getAttachments(uuid: string): Promise<Attachment[]>
Returns metadata of all attachments for a given email.
downloadAttachment(uuid: string): Promise<Blob>
Downloads the raw content of the attachment.
Typings
All responses are fully typed with the following exports:
import type { Email, EmailPreview, Attachment } from 'zyntramail-api';