API Reference
Comprehensive reference for the @multivrs/mail SDK classes, methods, parameters, and error types.
This page provides the complete technical specification for all methods, options, and interfaces exported by the @multivrs/mail package.
Constructor: new MultivrsMail()
init.ts
import { MultivrsMail } from "@multivrs/mail";
const mail = new MultivrsMail(apiKey?, options?);- apiKey (optional): Multivrs Mail API key. Defaults to process.env.MULTIVRS_API_KEY.
- options.baseUrl (optional): Custom API base URL for enterprise private VPC proxies.
- options.timeout (optional): Request timeout in milliseconds (default: 30000).
mail.emails.send(payload)
- from: string (required) - Sender address, e.g. 'Acme <hello@yourdomain.com>'.
- to: string | string[] (required) - One or more recipient email addresses.
- subject: string (required) - Subject line of the email.
- html: string - HTML body content.
- text: string - Plain text body fallback.
- scheduledAt: Date | string - Future schedule timestamp.
- attachments: Array of { filename, content, contentType }.
mail.emails.get(id)
status.ts
const { data: email } = await mail.emails.get("msg_88492019");
console.log(email.status); // 'delivered' | 'bounced' | 'queued'mail.emails.cancel(id)
cancel.ts
const { data } = await mail.emails.cancel("msg_88492019");
console.log("Cancelled:", data.cancelled);mail.domains API
- mail.domains.create({ name }): Registers a new domain and returns required DNS records.
- mail.domains.verify(id): Checks DNS propagation and activates sending status.
- mail.domains.list(): Returns all configured domains for your project.
Error Handling
error-handling.ts
const { data, error } = await mail.emails.send({ ... });
if (error) {
console.error("Error name:", error.name);
console.error("HTTP status:", error.statusCode);
console.error("Error details:", error.message);
}