import { FetchOptions } from "ofetch"; interface MailChannelsClientOptions { /** * Override the MailChannels API base URL. * Useful for local testing against a simulator. * @default "https://api.mailchannels.net" */ baseUrl?: string; /** * Number of times to retry a request in case of network errors and retryable HTTP responses. * Retries are attempted for the following scenarios: * - `408` - Request Timeout * - `409` - Conflict * - `425` - Too Early (Experimental) * - `429` - Too Many Requests * - `500` - Internal Server Error * - `502` - Bad Gateway * - `503` - Service Unavailable * - `504` - Gateway Timeout * @default false */ retry?: number | false; /** * Request timeout in milliseconds. * Set to `false` or `0` to disable timeout handling. * @default 120000 */ timeout?: number | false; /** * Abort signal applied to requests made by the client. */ signal?: AbortSignal; } declare class MailChannelsClient { #private; private static readonly DEFAULT_BASE_URL; private static readonly DEFAULT_TIMEOUT; private readonly options; constructor(key: string, options?: MailChannelsClientOptions); protected _fetch(path: string, options: FetchOptions<"json">): Promise; post(path: string, options?: Omit, "method">): Promise; get(path: string, options?: Omit, "method">): Promise; delete(path: string, options?: Omit, "method">): Promise; put(path: string, options?: Omit, "method">): Promise; patch(path: string, options?: Omit, "method">): Promise; } type ErrorType = "invalid_request_error" | "authentication_error" | "permission_error" | "not_found" | "conflict_error" | "payload_too_large_error" | "unprocessable_entity_error" | "rate_limit_error" | "internal_server_error" | "validation_error" | "application_error" | "api_error"; interface ErrorResponse { /** * A human-readable description of the error. */ message: string; /** * The HTTP status code from the API, or `null` if the error is not related to an HTTP request. * * This field is intended for diagnostic use only and should not be relied upon. */ statusCode: number | null; /** * A string identifier for the type of error. * * This field is intended for diagnostic use only and should not be relied upon. */ type: ErrorType; } interface SuccessResponse { /** * Whether the operation was successful. */ success: boolean; /** * Error information if the operation failed. */ error: ErrorResponse | null; } type DataResponse = { /** * The response data. */ data: T; /** * Error information if the operation failed. */ error: null; } | { /** * The response data. */ data: null; /** * Error information if the operation failed. */ error: ErrorResponse; }; interface EmailsSendRecipient { /** * The email address of the recipient. */ email: string; /** * The name of the recipient. Display name in raw text, e.g. John Doe, 张三. */ name?: string; } interface EmailsSendAttachment { /** * The attachment data, encoded in base64. */ content: string; /** * The name of the attachment file. */ filename: string; /** * The MIME type of the attachment. */ type?: string; /** * The `Content-ID` header value for inline attachments, referenced from HTML with `cid:`. */ contentId?: string; /** * The `Content-Disposition` header value for the attachment. */ disposition?: "attachment" | "inline"; } interface EmailsSendTracking { /** * Track when a recipient clicks a link in your email. */ click?: { /** * @default false */ enable?: boolean; }; /** * Track when a recipient opens your email. Please note that some email clients may not support open tracking. */ open?: { /** * @default false */ enable?: boolean; }; } type EmailsSendTemplateType = "mustache"; type EmailsSendTemplateValue = string | boolean | number | EmailsSendTemplateValue[] | { [key: string]: EmailsSendTemplateValue; }; interface EmailsSendTemplate { /** * The template type of the content */ type: EmailsSendTemplateType; /** * Template variables, overridable per-personalization. * An object containing key-value pairs of variables to set for template rendering. * * Keys must be strings, and values can be one of the following types: * - string * - number * - boolean * - list, whose values are all of permitted types * - map, whose keys must be strings, and whose values are all of permitted types */ data?: Record; } interface EmailsSendContent { /** * The MIME type of the content you are including in your email. */ type: string; /** * The actual content of the specified MIME type that you are including in the message. */ value: string; } type EmailsSendRecipientInput = EmailsSendRecipient[] | EmailsSendRecipient | string[] | string; interface EmailsSendDkim { /** * Domain used for DKIM signing. */ domain?: string; /** * DKIM private key encoded in Base64. */ privateKey?: string; /** * DKIM selector in the domain DNS records. */ selector?: string; } interface EmailsSendPersonalization { /** * The BCC recipients for this personalization. */ bcc?: EmailsSendRecipientInput; /** * The CC recipients for this personalization. */ cc?: EmailsSendRecipientInput; /** * DKIM settings for this personalization. */ dkim?: EmailsSendDkim; /** * Optional envelope sender for this personalization. */ envelopeFrom?: EmailsSendRecipient | string; /** * Optional sender override for this personalization. */ from?: EmailsSendRecipient | string; /** * Custom headers for this personalization. */ headers?: Record; /** * Reply-to override for this personalization. */ replyTo?: EmailsSendRecipient | string; /** * Subject override for this personalization. */ subject?: string; /** * The recipients for this personalization. */ to: EmailsSendRecipientInput; /** * Per-personalization template data. Merged with (and overrides) root-level `template.data`. */ template?: Required>; } interface EmailsSendOptionsBase { /** * An array of attachments to be sent with the email. */ attachments?: (EmailsSendAttachment | Promise)[]; /** * The campaign identifier. If specified, this ID will be included in all relevant webhooks. It can be up to 48 UTF-8 characters long and must not contain spaces. */ campaignId?: string; /** * The BCC recipients of the email. Can be an array of email addresses or an array of objects with email and name properties or a single email address string or an object with email and name properties. * @example * [ * { email: 'email1@example.com', name: 'Example1' }, * { email: 'email2@example.com', name: 'Example2' } * ] * @example * { email: 'email@example.com', name: 'Example' } * @example * ['email1@example.com', 'email2@example.com'] * @example * 'email@example.com' * @example * 'Name ' */ bcc?: EmailsSendRecipientInput; /** * The CC recipients of the email. Can be an array of email addresses or an array of objects with email and name properties or a single email address string or an object with email and name properties. * @example * [ * { email: 'email1@example.com', name: 'Example1' }, * { email: 'email2@example.com', name: 'Example2' } * ] * @example * { email: 'email@example.com', name: 'Example' } * @example * ['email1@example.com', 'email2@example.com'] * @example * 'email@example.com' * @example * 'Name ' */ cc?: EmailsSendRecipientInput; /** * The DKIM settings for the email. */ dkim?: EmailsSendDkim; /** * Optional envelope sender address. If not set, the envelope sender defaults to the `from.email` field. Can be overridden per-personalization. Only the email portion is used; the name field is ignored. * @example * { email: 'email@example.com', name: 'Example' } * @example * 'email@example.com' * @example * 'Name ' */ envelopeFrom?: EmailsSendRecipient | string; /** * The sender of the email. Can be a string or an object with email and name properties. * @example * { email: 'email@example.com', name: 'Example' } * @example * 'email@example.com' * @example * 'Name ' */ from: EmailsSendRecipient | string; /** * An object containing key-value pairs, where both keys (header names) and values must be strings. These pairs represent custom headers to be substituted. * * Please note the following restrictions and behavior: * - **Reserved headers**: The following headers cannot be modified: `Authentication-Results`, `BCC`, `CC`, `Content-Transfer-Encoding`, `Content-Type`, `DKIM-Signature`, `From`, `Message-ID`, `Received`, `Reply-To`, `Subject`, `To`. * - **Header precedence**: If a header is defined in both the personalizations object and the root headers, the value from personalizations will be used. * - **Case sensitivity**: Headers are treated as case-insensitive. If multiple headers differ only by case, only one will be used, with no guarantee of which one. */ headers?: Record; /** * Explicit personalization objects. Use this for advanced MailChannels payloads with multiple recipient groups or per-personalization overrides. */ personalizations?: EmailsSendPersonalization[]; /** * The recipient of the email. Can be an array of email addresses or an array of objects with `email` and `name` properties or a single email address string or an object with `email` and `name` properties. * @example * [ * { email: 'email1@example.com', name: 'Example1' }, * { email: 'email2@example.com', name: 'Example2' }, * ] * @example * { email: 'email@example.com', name: 'Example' } * @example * ['email1@example.com', 'email2@example.com'] * @example * 'email@example.com' * @example * 'Name ' */ to?: EmailsSendRecipientInput; /** * Adjust open and click tracking for the message. Please note that enabling tracking for your messages requires a subscription that supports open and click tracking. * * Only links (`` tags) meeting all of the following conditions are processed for click tracking: * - The URL is non-empty. * - The URL starts with `http` or `https`. * - The link does not have a `clicktracking` attribute set to `off`. */ tracking?: EmailsSendTracking; /** * A single `replyTo` recipient object, or a single email address. * @example * { email: 'email@example.com', name: 'Example' } * @example * 'email@example.com' * @example * 'Name ' */ replyTo?: EmailsSendRecipient | string; /** * The subject of the email. */ subject: string; /** * Template configuration for rendering email content with a template engine. */ template?: EmailsSendTemplate; /** * Mark these messages as transactional or non-transactional. In order for a message to be marked as non-transactional, it must have exactly one recipient per personalization, and it must be DKIM signed. 400 Bad Request will be returned if there are more than one recipient in any personalization for non-transactional messages. If a message is marked as non-transactional, it changes the sending process as follows: * * List-Unsubscribe headers will be added. * @default true */ transactional?: boolean; } type EmailsSendTargetOptions = { personalizations: (Omit & { template?: never; })[]; to?: never; cc?: never; bcc?: never; } | { template: EmailsSendTemplate; personalizations: EmailsSendPersonalization[]; to?: never; cc?: never; bcc?: never; } | { personalizations?: never; to: EmailsSendRecipientInput; cc?: EmailsSendRecipientInput; bcc?: EmailsSendRecipientInput; }; type EmailsSendOptions = EmailsSendOptionsBase & EmailsSendTargetOptions & ({ /** * The HTML content of the email. * @example * '

Hello World

' */ html: string; /** * The plain text content of the email (optional when `html` is provided). * @example * 'Hello World' */ text?: string; /** * Additional content parts. Cannot contain a `text/html` entry when `html` is set, or a `text/plain` entry when `text` is set. */ content?: EmailsSendContent[]; } | { /** * The HTML content of the email (optional when `text` is provided). * @example * '

Hello World

' */ html?: string; /** * The plain text content of the email. * @example * 'Hello World' */ text: string; /** * Additional content parts. Cannot contain a `text/html` entry when `html` is set, or a `text/plain` entry when `text` is set. */ content?: EmailsSendContent[]; } | { /** * The HTML content of the email (optional when `content` is provided). * @example * '

Hello World

' */ html?: string; /** * The plain text content of the email (optional when `content` is provided). * @example * 'Hello World' */ text?: string; /** * Send the body of your message in multiple different formats. The recipient's email client will render the message using the content type that best fits their environment. Cannot contain a `text/html` entry when `html` is set, or a `text/plain` entry when `text` is set. */ content: EmailsSendContent[]; }); type EmailsSendResponse = DataResponse<{ /** * Fully rendered message if `dryRun` was set to `true`. A string representation of a rendered message, one per personalization in the request. */ rendered?: string[]; /** * The Request ID is a unique identifier generated by the service to track the HTTP request. It will also be included in all webhooks for reference. */ requestId?: string; results?: { /** * The index of the personalization in the request. Starts at 0. */ index?: number; /** * The Message ID is a unique identifier generated by the service. Each personalization has a distinct Message ID, which is also used in the `Message-Id` header and included in webhooks. */ messageId: string; /** * A human-readable explanation of the status. */ reason?: string; /** * The status of the message. Note that 'sent' is a temporary status; the final status will be provided through webhooks, if configured. */ status: "sent" | "failed"; }[]; }>; type EmailsQueueResponse = DataResponse<{ /** * ISO 8601 timestamp when the request was queued for processing. */ queuedAt: string; /** * Unique identifier for tracking this async request. Will be included in all webhook events for this request. */ requestId: string; }>; /** @deprecated Use `EmailsQueueResponse` instead. */ type EmailsSendAsyncResponse = EmailsQueueResponse; declare class Emails { protected mailchannels: MailChannelsClient; constructor(mailchannels: MailChannelsClient); private _sendEmail; /** * Sends an email message to one or more recipients. * @param options - The email options to send. * @param dryRun - When set to `true`, the message will not be sent. Instead, the fully rendered message will be returned in the `data` property of the response. The default value is `false`. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.emails.send({ * to: 'to@example.com', * from: 'from@example.com', * subject: 'Test', * html: 'Test' * }) * ``` */ send(options: EmailsSendOptions, dryRun?: boolean): Promise; /** * Queues an email message for asynchronous processing and returns immediately with a request ID. * * The email will be processed in the background, and you'll receive webhook events for all delivery status updates (e.g. `dropped`, `processed`, `delivered`, `hard-bounced`). These webhook events are identical to those sent for the synchronous /send endpoint. * * Use this endpoint when you need to send emails without waiting for processing to complete. This can improve your application's response time, especially when sending to multiple recipients. * @param options - The email options to send. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.emails.queue({ * to: 'to@example.com', * from: 'from@example.com', * subject: 'Test', * html: 'Test' * }) * ``` */ queue(options: EmailsSendOptions): Promise; /** * @deprecated Use `queue` instead. */ sendAsync(options: EmailsSendOptions): Promise; } interface DomainsDkimCreateOptions { /** * Algorithm used for the new key pair Currently, only RSA is supported. * @default "rsa" */ algorithm?: "rsa"; /** * Key length in bits. For RSA, must be a multiple of 1024. Common values: 1024 or 2048. * @default 2048 */ length?: 1024 | 2048 | 3072 | 4096; /** * Selector for the new key pair. Must be a maximum of 63 characters. */ selector: string; } type DomainsDkimKeyStatus = "active" | "retired" | "revoked" | "rotated"; interface DomainsDkimKey { /** * Algorithm used for the key pair. */ algorithm: string; /** * Timestamp when the key pair was created. */ createdAt?: string; /** * Suggested DNS records for the DKIM key. */ dnsRecords: { name: string; type: string; value: string; }[]; /** * Domain associated with the key pair. */ domain: string; /** * UTC timestamp after which you can no longer use the rotated key for signing. */ gracePeriodExpiresAt?: string; /** * Key length in bits. */ length: 1024 | 2048 | 3072 | 4096; publicKey: string; /** * UTC timestamp when a rotated key pair is retired. */ retiresAt?: string; /** * Selector assigned to the key pair. */ selector: string; /** * Status of the key. */ status: DomainsDkimKeyStatus; /** * Timestamp when the key was last modified. */ statusModifiedAt?: string; } type DomainsDkimCreateResponse = DataResponse; interface DomainsDkimListOptions { /** * Selector to filter keys by. Must be a maximum of 63 characters. */ selector?: string; /** * Status to filter keys by. */ status?: DomainsDkimKey["status"]; /** * Number of keys to skip before returning results. * @default 0 */ offset?: number; /** * Maximum number of keys to return. Maximum is `100` and minimum is `1`. * @default 10 */ limit?: number; /** * If `true`, includes the suggested DKIM DNS record for each returned key. * @default false */ includeDnsRecord?: boolean; } type Optional = Omit & Partial>; type DomainsDkimListResponse = DataResponse[]>; interface DomainsDkimUpdateStatusOptions { /** * Selector of the DKIM key pair to update. Must be a maximum of 63 characters. */ selector: string; /** * New status of the DKIM key pair. * - `revoked`: Indicates that the key is compromised and should not be used. * - `retired`: Indicates that the key has been rotated and is no longer in use. * - `rotated`: Indicates that the key is going through the rotation process. Only active key pairs can be updated to this status, and no new key pair is created. The rotated key can be used to sign emails for 3 days after the status update, and will automatically change to `retired` 2 weeks after update. For a smooth key transition, it is recommended to create and publish a new key pair before signing is disabled for the rotated key. */ status: Exclude; } interface DomainsDkimRotateOptions { newKey: { /** * Selector for the new key pair. Must be a maximum of 63 characters. */ selector: string; }; } type DomainsDkimRotateResponse = DataResponse<{ new: DomainsDkimKey; rotated: DomainsDkimKey; }>; declare class DomainsDkim { private mailchannels; constructor(mailchannels: MailChannelsClient); /** * Create a DKIM key pair for a specified domain and selector using the specified algorithm and key length, for the current customer. * @param domain - The domain to create the DKIM key for. * @param options - DKIM key creation options. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.domains.dkim.create('example.com', { * selector: 'mailchannels' * }) * ``` */ create(domain: string, options: DomainsDkimCreateOptions): Promise; /** * Search for DKIM keys by domain, with optional filters. If selector is provided, at most one key will be returned. * @param domain - The domain to search DKIM keys for. * @param options - The options to filter DKIM keys by. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.domains.dkim.list('example.com', { * includeDnsRecord: true * }) * ``` */ list(domain: string, options?: DomainsDkimListOptions): Promise; /** * Update fields of an existing DKIM key pair for the specified domain and selector, for the current customer. Currently, only the `status` field can be updated. * @param domain - The domain the DKIM key belongs to. * @param options - The options to update the DKIM key. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.domains.dkim.updateStatus('example.com', { * selector: 'mailchannels', * status: 'retired' * }) */ updateStatus(domain: string, options: DomainsDkimUpdateStatusOptions): Promise; /** * Rotate an active DKIM key pair. Mark the original key as `rotated`, and create a new key pair with the required new key selector, reusing the same algorithm and key length. The rotated key remains valid for signing for a 3-day grace period, and is automatically changed to `retired` 2 weeks after rotation. Publish the new key to its DNS TXT record before rotated key expires for signing as emails sent with an unpublished key will fail DKIM validation by receiving providers. After the grace period, only the new key is valid for signing if published. * @param domain - The domain the DKIM key belongs to. * @param selector - The selector of the DKIM key to rotate. * @param options - The options to rotate the DKIM key. * @param options.newKey.selector - The selector for the new key pair. Must be a maximum of 63 characters. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.domains.dkim.rotate('example.com', 'mailchannels', { * newKey: { * selector: 'new-selector' * } * }) * ``` */ rotate(domain: string, selector: string, options: DomainsDkimRotateOptions): Promise; } interface DomainsCheck { /** * Domain used for DKIM signing. */ domain?: string; /** * DKIM private key encoded in Base64. */ privateKey?: string; /** * DKIM selector in the domain DNS records. */ selector?: string; } interface DomainsCheckOptions { /** * Each item may include DKIM `domain`, `selector` and `privateKey`. Up to 10 items are allowed. The absence or presence of these fields affects how DKIM settings are validated: * 1. If `domain`, `selector`, and `privateKey` are all present, verify using the provided domain, selector, and key. * 2. If `domain` and `selector` are present, use the stored private key for the given domain and selector. * 3. If only `domain` is present, use all stored keys for the given domain. * 4. If none are present, use all stored keys for the `domain` provided in the domain field of the request. * 5. If `privateKey` is present, `selector` must be present. * 6. If `selector` is present and `domain` is not, the domain will be taken from the domain field of the request. */ dkim?: DomainsCheck[] | DomainsCheck; /** * Used exclusively for [Domain Lockdown](https://support.mailchannels.com/hc/en-us/articles/16918954360845-Secure-your-domain-name-against-spoofing-with-Domain-Lockdown) verification. If you're not using senderid to associate your domain with your account, you can disregard this field. The corresponding value is included in the `X-MailChannels-SenderId` header of emails sent via MailChannels. */ senderId?: string; } type DomainsCheckVerdict = "passed" | "failed" | "soft failed" | "temporary error" | "permanent error" | "neutral" | "none" | "unknown"; type DomainsCheckResponse = DataResponse<{ dkim: { domain: string; /** * The human readable status of the DKIM key used for verification. */ keyStatus?: DomainsDkimKey["status"] | "provided"; selector: string; /** * A human-readable explanation of DKIM check. */ reason?: string; verdict: Extract; }[]; domainLockdown: { /** * A human-readable explanation of Domain Lockdown check. */ reason?: string; verdict: Extract; }; /** * These results are here to help avoid [SDNF](https://support.mailchannels.com/hc/en-us/articles/203155500-550-5-2-1-SDNF-Sender-Domain-Not-Found) (Sender Domain Not Found) blocks. For messages not to get blocked by SDNF, we require either an MX or A record to exist for the sender domain. */ senderDomain: { a: { /** * A human-readable explanation of A record check. */ reason?: string; verdict: Extract; }; mx: { /** * A human-readable explanation of MX record check. */ reason?: string; verdict: Extract; }; /** * Overall verdict. Passed if either A or MX record check passed. */ verdict: Extract; }; spf: { /** * A human-readable explanation of SPF check. */ reason?: string; /** * The SPF record that was used for the check. */ spfRecord?: string; /** * Error message if the SPF record lookup failed. */ spfRecordError?: string; verdict: DomainsCheckVerdict; }; references?: string[]; }>; declare class Domains { protected mailchannels: MailChannelsClient; readonly dkim: DomainsDkim; constructor(mailchannels: MailChannelsClient); /** * Validates a domain's email authentication setup by retrieving its DKIM, SPF, and Domain Lockdown status. This endpoint checks whether the domain is properly configured for secure email delivery. * @param domain - Domain used for sending emails. If `dkim` settings are not provided, or `dkim` settings are provided with no `domain`, the stored dkim settings for this domain will be used. * @param options - The domain options to check. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.domains.check('example.com', { * dkim: [{ * domain: 'example.com', * privateKey: 'your-private-key', * selector: 'mailchannels' * }], * senderId: 'sender-id' * }) * ``` */ check(domain: string, options?: DomainsCheckOptions): Promise; } type WebhooksListResponse = DataResponse<{ /** * A customer's webhook that events will be sent to */ webhook: string; }[]>; type WebhooksSigningKeyResponse = DataResponse<{ /** * The ID of the key. */ id: string; /** * The public key used to verify webhook signatures. */ key: string; }>; type WebhooksValidateResponse = DataResponse<{ /** * Indicates whether all webhook validations passed. */ allPassed: boolean; /** * Detailed results for each tested webhook, including whether it returned a 2xx status code, along with its response status code and body. */ results: { /** * Indicates whether the webhook responded with a 2xx HTTP status code. */ result: "passed" | "failed"; /** * The webhook that was validated. */ webhook: string; /** * The HTTP response returned by the webhook, including status code and response body. A null value indicates no response was received. Possible reasons include timeouts, connection failures, or other network-related issues. */ response: { /** * Response body from webhook. Returns an error if unprocessable or too large. */ body?: string; /** * HTTP status code returned by the webhook. */ status: number; } | null; }[]; }>; type WebhookEventType = "processed" | "delivered" | "open" | "click" | "hard-bounced" | "soft-bounced" | "dropped" | "complained" | "unsubscribed" | "test"; interface WebhookEventBase { /** * The sender's email address */ email?: string; /** * The MailChannels account ID that generated the webhook. * If the message was sent by a sub-account, this field contains the sub-account handle. */ customerHandle: string; /** * The Unix timestamp (in seconds) when the event occurred; the timezone is always UTC */ timestamp: number; /** * The Message-Id of the message that generated the event */ smtpId?: string; /** * The type of event that occurred */ event: T; /** * A unique identifier generated to track the original HTTP request */ requestId?: string; /** * The campaign identifier for the message that generated the event */ campaignId?: string; /** * The recipients of the message */ recipients?: string[]; } interface WebhookEventProcessed extends WebhookEventBase<"processed"> {} interface WebhookEventDelivered extends WebhookEventBase<"delivered"> {} interface WebhookEventWithTracking { /** * The User-Agent header given when the recipient opened the message */ userAgent?: string; /** * The IP address of the host that made the HTTP request */ ip?: string; } interface WebhookEventOpen extends WebhookEventBase<"open">, WebhookEventWithTracking {} interface WebhookEventClick extends WebhookEventBase<"click">, WebhookEventWithTracking { /** * The URL that was clicked by the recipient */ url?: string; } interface WebhookEventWithStatus { /** * The SMTP status code that caused the bounce */ status?: string; /** * A human-readable explanation of why the message hard-bounced */ reason?: string; } interface WebhookEventHardBounced extends WebhookEventBase<"hard-bounced">, WebhookEventWithStatus {} interface WebhookEventSoftBounced extends WebhookEventBase<"soft-bounced">, WebhookEventWithStatus {} interface WebhookEventDropped extends WebhookEventBase<"dropped">, WebhookEventWithStatus {} interface WebhookEventComplained extends WebhookEventBase<"complained"> {} interface WebhookEventUnsubscribed extends WebhookEventBase<"unsubscribed"> {} interface WebhookEventTest extends Omit, "recipients" | "campaignId"> {} type WebhookEvent = WebhookEventProcessed | WebhookEventDelivered | WebhookEventOpen | WebhookEventClick | WebhookEventHardBounced | WebhookEventSoftBounced | WebhookEventDropped | WebhookEventComplained | WebhookEventUnsubscribed | WebhookEventTest; interface WebhooksVerifyOptions { /** * The raw body of the incoming webhook request as a string. This should be the exact payload received from the webhook, without any modifications or parsing, to ensure accurate signature verification. */ payload: string; /** * The headers of the incoming webhook request as a record of key-value pairs. These headers should include `content-digest`, `signature`, and `signature-input` required for validating the authenticity of the webhook request. */ headers: Record | { "content-digest": string; "signature": string; "signature-input": string; }; /** * The public key used to verify the webhook signature. If not provided, the SDK will attempt to retrieve the appropriate public key based on the `keyId` specified in the `signature-input` header. */ publicKey?: string; /** * Whether to cache signing keys fetched from the API by their `keyId`. Defaults to `true`. * @default true */ cache?: boolean; } type WebhooksVerifyResponse = DataResponse; type WebhooksBatchStatus = "1xx" | "2xx" | "3xx" | "4xx" | "5xx" | "no_response"; type WebhooksBatchResponseStatus = "1xx_response" | "2xx_response" | "3xx_response" | "4xx_response" | "5xx_response" | "no_response"; interface WebhooksBatchesOptions { /** * Inclusive lower bound (UTC) for filtering webhook batches by creation time. Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ` or a `Date` object. */ createdAfter?: string | Date; /** * Exclusive upper bound (UTC) for filtering webhook batches by creation time. Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ` or a `Date` object. */ createdBefore?: string | Date; /** * Filters webhook batches by webhook response status category. If not provided, batches with all categories are returned. */ statuses?: WebhooksBatchStatus[]; /** * Filters webhook batches by the webhook endpoint to which events in the batch were posted. */ webhook?: string; /** * The maximum number of webhook batches to return. Must be between `1` and `500`. * @default 500 */ limit?: number; /** * The number of webhook batches to skip before starting to collect the result set. * @default 0 */ offset?: number; } interface WebhooksBatch { /** * Unique identifier for the webhook batch. */ batchId: number; /** * Timestamp of when the webhook batch was created. */ createdAt: string; /** * Customer handle associated with the webhook batch. */ customerHandle: string; /** * Duration of the webhook batch, measured from the time the request was sent to the webhook endpoint until the response was received. */ duration?: { unit: "milliseconds"; value: number; }; /** * Number of events in the webhook batch. */ eventCount: number; /** * Status of the webhook batch. */ status: WebhooksBatchResponseStatus; /** * HTTP status code returned by the webhook endpoint. */ statusCode: number | null; /** * Webhook endpoint to which events in the batch were posted. */ webhook: string; } type WebhooksBatchesResponse = DataResponse; interface WebhooksResendBatch { /** * Unique identifier for the webhook batch. */ batchId: number; /** * Customer handle associated with the webhook batch. */ customerHandle: string; /** * Webhook URL to which events in the batch were posted. */ webhook: string; /** * Timestamp of when the webhook batch was created. */ createdAt: string; /** * Number of events in the webhook batch. */ eventCount: number; /** * Duration of the webhook batch in milliseconds. `null` indicates that no response was returned from the webhook endpoint. */ duration: number | null; /** * HTTP status code returned by the webhook endpoint. `null` indicates that no response was returned from the webhook endpoint. */ statusCode: number | null; } type WebhooksResendBatchResponse = DataResponse; declare class Webhooks { protected mailchannels: MailChannelsClient; constructor(mailchannels: MailChannelsClient); /** * Enrolls the customer to receive event notifications via webhooks. * @param endpoint - The URL to receive event notifications. Must be no longer than `8000` characters. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.webhooks.create('https://example.com/api/webhooks/mailchannels') * ``` */ create(endpoint: string): Promise; /** * Retrieves all registered webhook endpoints associated with the customer. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.webhooks.list() * ``` */ list(): Promise; /** * Deletes all registered webhook endpoints for the customer. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.webhooks.deleteAll() * ``` */ deleteAll(): Promise; /** * Retrieves the public key used to verify signatures on incoming webhook payloads. * @param id - The ID of the key. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.webhooks.getSigningKey('key-id') * ``` */ getSigningKey(id: string): Promise; /** * Validates whether your enrolled webhook(s) respond with an HTTP `2xx` status code. Sends a test request to each webhook containing your customer handle, a hardcoded event type (`test`), a hardcoded sender email (`test@mailchannels.com`), a timestamp, a request ID (provided or generated), and an SMTP ID. The response includes the HTTP status code and body returned by each webhook. * @param requestId - Optional identifier in the webhook payload. If not provided, a value will be automatically generated. Must not exceed 28 characters. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.webhooks.validate('optional-request-id') * ``` */ validate(requestId?: string): Promise; /** * Verifies the authenticity of incoming webhook requests by validating their signatures using the provided options. * @param options - The options for verifying the webhook. * @example * ```ts * const { data, error } = await Webhooks.verify({ payload: rawBody, headers }) * ``` */ static verify(options: WebhooksVerifyOptions): Promise; /** * Verifies the authenticity of incoming webhook requests by validating their signatures using the provided options. * @param options - The options for verifying the webhook. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.webhooks.verify({ payload: rawBody, headers }) * ``` */ verify(options: WebhooksVerifyOptions): Promise; /** * Retrieves paged webhook batches associated with the customer. The time range specified by `createdAfter` and `createdBefore` must not exceed 31 days. If neither is specified, the default time range is the last 3 days. * @param options - The options for listing webhook batches. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.webhooks.batches() * ``` */ batches(options?: WebhooksBatchesOptions): Promise; /** * Synchronously resends the webhook batch with the provided `batchId` for the customer. The result is returned in the response. * @param batchId - The ID of the batch to resend. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.webhooks.resendBatch(123) * ``` */ resendBatch(batchId: number): Promise; } interface SubAccount { /** * The name of the company associated with the sub-account. */ companyName: string; /** * If the sub-account is enabled. */ enabled: boolean; /** * The handle for the sub-account. */ handle: string; } type SubAccountsCreateResponse = DataResponse; /** @deprecated Use `SubAccount` instead. */ type SubAccountsAccount = SubAccount; interface SubAccountsListOptions { /** * Possible values are `1` to `1000`. * @default 1000 */ limit?: number; /** * The offset for pagination. * @default 0 */ offset?: number; } type SubAccountsListResponse = DataResponse; interface SubAccountsApiKey { /** * The API key ID for the sub-account. */ id: number; /** * API key for the sub-account. */ key: string; } type SubAccountsApiKeysCreateResponse = DataResponse; interface SubAccountsApiKeysListOptions { /** * The maximum number of API keys included in the response. Possible values are `1` to `1000`. * @default 100 */ limit?: number; /** * Offset into the list of API keys to return. * @default 0 */ offset?: number; } type SubAccountsApiKeysListResponse = DataResponse; /** @deprecated Use `SubAccountsApiKeysCreateResponse` instead. */ type SubAccountsCreateApiKeyResponse = SubAccountsApiKeysCreateResponse; /** @deprecated Use `SubAccountsApiKeysListOptions` instead. */ type SubAccountsListApiKeyOptions = SubAccountsApiKeysListOptions; /** @deprecated Use `SubAccountsApiKeysListResponse` instead. */ type SubAccountsListApiKeyResponse = SubAccountsApiKeysListResponse; interface SubAccountsSmtpPassword { /** * Whether the SMTP password is enabled. */ enabled: boolean; /** * The SMTP password ID for the sub-account. */ id: number; /** * SMTP password for the sub-account. */ smtpPassword: string; } type SubAccountsSmtpPasswordsCreateResponse = DataResponse; type SubAccountsSmtpPasswordsListResponse = DataResponse; /** @deprecated Use `SubAccountsSmtpPasswordsCreateResponse` instead. */ type SubAccountsCreateSmtpPasswordResponse = SubAccountsSmtpPasswordsCreateResponse; /** @deprecated Use `SubAccountsSmtpPasswordsListResponse` instead. */ type SubAccountsListSmtpPasswordResponse = SubAccountsSmtpPasswordsListResponse; interface SubAccountsLimit { sends: number; } interface SubAccountsLimitsSetOptions extends SubAccountsLimit {} type SubAccountsLimitsGetResponse = DataResponse; /** @deprecated Use `SubAccountsLimitsGetResponse` instead. */ type SubAccountsLimitResponse = SubAccountsLimitsGetResponse; interface SubAccountsUsage { /** * The end date of the current billing period (ISO 8601 format). * @example "2025-04-11" */ endDate?: string; /** * The start date of the current billing period (ISO 8601 format). * @example "2025-03-12" */ startDate?: string; /** * The total usage for the current billing period. */ total: number; } type SubAccountsUsageResponse = DataResponse; interface MetricsEngagement { /** * A series of metrics aggregations bucketed by time interval (e.g. hour, day). */ buckets: { click: MetricsBucket[]; clickTrackingDelivered: MetricsBucket[]; open: MetricsBucket[]; openTrackingDelivered: MetricsBucket[]; }; click: number; clickTrackingDelivered: number; endTime: string; open: number; openTrackingDelivered: number; startTime: string; } type MetricsEngagementResponse = DataResponse; interface MetricsPerformance { /** * Count of messages bounced during the specified time range. */ bounced: number; /** * A series of metrics aggregations bucketed by time interval (e.g. hour, day). */ buckets: { bounced: MetricsBucket[]; delivered: MetricsBucket[]; processed: MetricsBucket[]; }; /** * Count of messages delivered during the specified time range. */ delivered: number; /** * The end of the time range for retrieving message performance metrics (exclusive). */ endTime: string; /** * Count of messages processed during the specified time range. */ processed: number; /** * The beginning of the time range for retrieving message performance metrics (inclusive). */ startTime: string; } type MetricsPerformanceResponse = DataResponse; interface MetricsRecipientBehaviour { /** * A series of metrics aggregations bucketed by time interval (e.g. hour, day). */ buckets: { unsubscribeDelivered: MetricsBucket[]; unsubscribed: MetricsBucket[]; }; /** * The end of the time range for retrieving recipient behaviour metrics (exclusive). */ endTime: string; /** * The beginning of the time range for retrieving recipient behaviour metrics (inclusive). */ startTime: string; /** * Count of recipients of delivered messages that include at least one of the unsubscribe link or unsubscribe headers. Since the unsubscribe feature requires exactly one recipient per message, this count also represents the total number of delivered messages. */ unsubscribeDelivered: number; /** * Count of unsubscribed events by recipients. */ unsubscribed: number; } type MetricsRecipientBehaviourResponse = DataResponse; interface MetricsVolume { /** * A series of metrics aggregations bucketed by time interval (e.g. hour, day). */ buckets: { delivered: MetricsBucket[]; dropped: MetricsBucket[]; processed: MetricsBucket[]; }; /** * Count of messages delivered during the specified time range. */ delivered: number; /** * Count of messages dropped during the specified time range. */ dropped: number; /** * The end of the time range for retrieving message volume metrics (exclusive). */ endTime: string; /** * Count of messages processed during the specified time range. */ processed: number; /** * The beginning of the time range for retrieving message volume metrics (inclusive). */ startTime: string; } type MetricsVolumeResponse = DataResponse; type MetricsUsageResponse = DataResponse<{ /** * The end date of the current billing period (ISO 8601 format). * @example "2025-04-11" */ endDate?: string; /** * The start date of the current billing period (ISO 8601 format). * @example "2025-03-12" */ startDate?: string; /** * The total usage for the current billing period. */ total: number; }>; type MetricsSendersType = "sub-accounts" | "campaigns"; interface MetricsSendersOptions { /** * The beginning of the time range for retrieving top senders metrics (inclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ` or a `Date` object. Defaults to one month ago if not provided. * @example "2025-11-02T03:13:35.761763554Z" */ startTime?: string | Date; /** * The end of the time range for retrieving top senders metrics (exclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ` or a `Date` object. Defaults to the current time if not provided. * @example "2025-12-02T03:13:35.761763554Z" */ endTime?: string | Date; /** * The maximum number of senders to return. Possible values are 1 to 1000. * @default 10 */ limit?: number; /** * The number of senders to skip before returning results. * @default 0 */ offset?: number; /** * The order in which to sort the results, based on total messages (processed + dropped). * @default "desc" */ sortOrder?: "asc" | "desc"; } interface MetricsSenders { endTime: string; limit: number; offset: number; senders: { bounced: number; delivered: number; dropped: number; /** * Maximum character length: 255 */ name: string; processed: number; }[]; startTime: string; /** * The total number of senders in this category that sent messages in the given time range. */ total: number; } type MetricsSendersResponse = DataResponse; interface MetricsBucket { /** * The number of events or occurrences aggregated within this time period. */ count: number; /** * The starting date and time of the time period this bucket represents. */ periodStart: string; } interface MetricsOptions { /** * The beginning of the time range for retrieving message metrics (inclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ` or a `Date` object. Defaults to one month ago if not provided. * @example "2025-05-26" */ startTime?: string | Date; /** * The end of the time range for retrieving message metrics (exclusive). Formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ` or a `Date` object. Defaults to the current time if not provided. * @example "2025-05-31T15:16:17Z" */ endTime?: string | Date; /** * The ID of the campaign to filter metrics by. If not provided, metrics for all campaigns will be returned. */ campaignId?: string; /** * The interval for aggregating metrics data. * @default "day" */ interval?: "hour" | "day" | "week" | "month"; } type SuppressionsTypes = "transactional" | "non-transactional"; interface SuppressionsCreateOptions { /** * If true, the parent account creates suppression entries for all associated sub-accounts. This field is only applicable to parent accounts. Sub-accounts cannot create entries for other sub-accounts. * @default false */ addToSubAccounts?: boolean; /** * The total number of suppression entries to create, for the parent and/or its sub-accounts, must not exceed `1000`. */ entries: { /** * Must be less than `1024` characters. */ notes?: string; /** * The email address to suppress. Must be a valid email address format and less than `255` characters. */ recipient: string; /** * An array of types of suppression to apply to the recipient. * @default ["non-transactional"] */ types?: SuppressionsTypes[]; }[]; } type SuppressionsSource = "api" | "unsubscribe_link" | "list_unsubscribe" | "hard_bounce" | "spam_complaint" | "all"; interface SuppressionsListOptions { /** * The email address of the suppression entry to search for. If provided, the search will return the suppression entry associated with this recipient. If not provided, the search will return all suppression entries for the account. */ recipient?: string; /** * The source of the suppression entries to filter by. If not provided, suppression entries from all sources will be returned. */ source?: Exclude; /** * The date and/or time before which the suppression entries were created. Format: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ` or a `Date` object. */ createdBefore?: string | Date; /** * The date and/or time after which the suppression entries were created. Format: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ` or a `Date` object. */ createdAfter?: string | Date; /** * The maximum number of suppression entries to return. Must be between `1` and `1000`. * @default 1000 */ limit?: number; /** * The number of suppression entries to skip before returning results. * @default 0 */ offset?: number; } interface SuppressionsListEntry { createdAt: string; notes?: string; /** * The email address that is suppressed. */ recipient: string; sender?: string; source: SuppressionsSource; types: SuppressionsTypes[]; } type SuppressionsListResponse = DataResponse; declare class SubAccountsApiKeys { private mailchannels; constructor(mailchannels: MailChannelsClient); /** * Creates a new API key for the specified sub-account. * @param handle - Handle of the sub-account to create API key for. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.subAccounts.apiKeys.create('validhandle123') * ``` */ create(handle: string): Promise; /** * Retrieves details of all API keys associated with the specified sub-account. For security reasons, the full API key is not returned; only the key ID and a partially redacted version are provided. * @param handle - Handle of the sub-account to retrieve the API key for. * @param options - The options to filter the list of API keys. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.subAccounts.apiKeys.list('validhandle123') * ``` */ list(handle: string, options?: SubAccountsApiKeysListOptions): Promise; /** * Deletes the API key identified by its ID for the specified sub-account. * @param handle - Handle of the sub-account for which the API key should be deleted. * @param id - The ID of the API key to delete. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.subAccounts.apiKeys.delete('validhandle123', 1) * ``` */ delete(handle: string, id: number): Promise; } declare class SubAccountsSmtpPasswords { private mailchannels; constructor(mailchannels: MailChannelsClient); /** * Creates a new SMTP password for the specified sub-account. * @param handle - Handle of the sub-account to create SMTP password for. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.subAccounts.smtpPasswords.create('validhandle123') * ``` */ create(handle: string): Promise; /** * Retrieves details of all SMTP passwords associated with the specified sub-account. For security, the full SMTP password is not returned; only the password ID and a partially redacted version are provided. * @param handle - Handle of the sub-account to retrieve the SMTP password for. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.subAccounts.smtpPasswords.list('validhandle123') * ``` */ list(handle: string): Promise; /** * Deletes the SMTP password identified by its ID for the specified sub-account. * @param handle - Handle of the sub-account for which the SMTP password should be deleted. * @param id - The ID of the SMTP password to delete. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.subAccounts.smtpPasswords.delete('validhandle123', 1) * ``` */ delete(handle: string, id: number): Promise; } declare class SubAccountsLimits { private mailchannels; constructor(mailchannels: MailChannelsClient); /** * Retrieves the limit of a specified sub-account. A value of `-1` indicates that the sub-account inherits the parent account's limit, allowing the sub-account to utilize any remaining capacity within the parent account's allocation. * @param handle - Handle of the sub-account to retrieve the limit for. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.subAccounts.limits.get('validhandle123') * ``` */ get(handle: string): Promise; /** * Sets the limit for the specified sub-account. * @param handle - Handle of the sub-account to set limit for. * @param options - The limits to set for the sub-account. The minimum allowed sends is `0` * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.subAccounts.limits.set('validhandle123', { sends: 1000 }) * ``` */ set(handle: string, options: SubAccountsLimitsSetOptions): Promise; /** * Deletes the limit for the specified sub-account. After a successful deletion, the specified sub-account will be limited to the parent account's limit. * @param handle - Handle of the sub-account to delete limit for. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.subAccounts.limits.delete('validhandle123') * ``` */ delete(handle: string): Promise; } declare class SubAccounts { protected mailchannels: MailChannelsClient; private static readonly COMPANY_PATTERN; private static readonly HANDLE_PATTERN; readonly apiKeys: SubAccountsApiKeys; readonly smtpPasswords: SubAccountsSmtpPasswords; readonly limits: SubAccountsLimits; constructor(mailchannels: MailChannelsClient); /** * Creates a new sub-account under the parent account. Each sub-account must have a unique handle composed solely of lowercase alphanumeric characters. If no handle is provided, a random handle will be generated. Note that Sub-accounts are only available to parent accounts on 100K and higher plans. * @param companyName - The name of the company associated with the sub-account. This name is used for display purposes only and does not affect the functionality of the sub-account. The length must be between 3 and 128 characters. * @param handle - A unique name for the sub-account to be created. The length must be between 3 and 128 characters, and it may contain only lowercase letters and numbers. If not provided, a random handle will be generated. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.subAccounts.create('My Company', 'validhandle123') * ``` */ create(companyName: string, handle?: string): Promise; /** * Retrieves all sub-accounts associated with the parent account. The response is paginated with a default limit of 1000 sub-accounts per page and an offset of 0. * @param options - The options to filter the list of sub-accounts. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.subAccounts.list() * ``` */ list(options?: SubAccountsListOptions): Promise; /** * Deletes the sub-account identified by its handle. * @param handle - Handle of sub-account to be deleted. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.subAccounts.delete('validhandle123') * ``` */ delete(handle: string): Promise; /** * Suspends the sub-account identified by its handle. This action disables the account, preventing it from sending any emails until it is reactivated. * @param handle - Handle of sub-account to be suspended. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.subAccounts.suspend('validhandle123') * ``` */ suspend(handle: string): Promise; /** * Activates a suspended sub-account identified by its handle, restoring its ability to send emails. * @param handle - Handle of sub-account to be activated. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.subAccounts.activate('validhandle123') * ``` */ activate(handle: string): Promise; /** * Retrieves usage statistics for the specified sub-account during the current billing period. * @param handle - Handle of the sub-account to query usage stats for. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.subAccounts.getUsage('validhandle123') * ``` */ getUsage(handle: string): Promise; /** @deprecated Use `apiKeys.create` instead. */ createApiKey(...args: Parameters): Promise; /** @deprecated Use `apiKeys.list` instead. */ listApiKeys(...args: Parameters): Promise; /** @deprecated Use `apiKeys.delete` instead. */ deleteApiKey(...args: Parameters): Promise; /** @deprecated Use `smtpPasswords.create` instead. */ createSmtpPassword(...args: Parameters): Promise; /** @deprecated Use `smtpPasswords.list` instead. */ listSmtpPasswords(...args: Parameters): Promise; /** @deprecated Use `smtpPasswords.delete` instead. */ deleteSmtpPassword(...args: Parameters): Promise; /** @deprecated Use `limits.set` instead. */ setLimit(...args: Parameters): Promise; /** @deprecated Use `limits.get` instead. */ getLimit(...args: Parameters): Promise; /** @deprecated Use `limits.delete` instead. */ deleteLimit(...args: Parameters): Promise; } declare class Metrics { protected mailchannels: MailChannelsClient; constructor(mailchannels: MailChannelsClient); /** * Retrieve engagement metrics for messages sent from your account, including counts of open and click events. Supports optional filters for time range, and campaign ID. * @param options - Options to filter and customize the engagement metrics retrieval. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.metrics.engagement() * ``` */ engagement(options?: MetricsOptions): Promise; /** * Retrieve performance metrics for messages sent from your account, including counts of processed, delivered, hard-bounced events. Supports optional filters for time range, and campaign ID. * @param options - Options to filter and customize the performance metrics retrieval. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.metrics.performance() * ``` */ performance(options?: MetricsOptions): Promise; /** * Retrieve recipient behaviour metrics for messages sent from your account, including counts of unsubscribed events. Supports optional filters for time range, and campaign ID. * @param options - Options to filter and customize the recipient behaviour metrics retrieval. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.metrics.recipientBehaviour() * ``` */ recipientBehaviour(options?: MetricsOptions): Promise; /** * Retrieve volume metrics for messages sent from your account, including counts of processed, delivered and dropped events. Supports optional filters for time range and campaign ID. * @param options - Options to filter and customize the volume metrics retrieval. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.metrics.volume() * ``` */ volume(options?: MetricsOptions): Promise; /** * Retrieves usage statistics during the current billing period. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.metrics.usage() * ``` */ usage(): Promise; /** * Retrieves a list of senders, either sub-accounts or campaigns, with their associated message metrics. Sorted by total # of sent messages (processed + dropped). Supports optional filter for time range, and optional settings for limit, offset, and sort order. Note: senders without any messages in the given time range will not be included in the results. The default time range is from one month ago to now, and the default sort order is descending. * @param type - The type of senders to retrieve metrics for. Can be either `sub-accounts` or `campaigns`. * @param options - Optional filter options for time range, limit, offset, and sort order. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.metrics.senders('campaigns') * ``` */ senders(type: MetricsSendersType, options?: MetricsSendersOptions): Promise; } declare class Suppressions { protected mailchannels: MailChannelsClient; constructor(mailchannels: MailChannelsClient); /** * Creates suppression entries for the specified account. Parent accounts can create suppression entries for all associated sub-accounts. If `types` is not provided, it defaults to `non-transactional`. The operation is atomic, meaning all entries are successfully added or none are added if an error occurs. * @param options - The details of the suppression entries to create. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.suppressions.create({ * // ... * }); */ create(options: SuppressionsCreateOptions): Promise; /** * Deletes suppression entry associated with the account based on the specified recipient and source. * @param recipient - The email address of the suppression entry to delete. * @param source - The source of the suppression entry to be deleted. If source is not provided, it defaults to `api`. If source is set to `all`, all suppression entries related to the specified recipient will be deleted. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { success, error } = await mailchannels.suppressions.delete('name@example.com', 'api'); * ``` */ delete(recipient: string, source?: SuppressionsSource): Promise; /** * Retrieve suppression entries associated with the specified account. Supports filtering by recipient, source and creation date range. The response is paginated, with a default limit of `1000` entries per page and an offset of `0`. * @param options - Options to filter and customize the suppression entries retrieval. * @example * ```ts * const mailchannels = new MailChannels('your-api-key') * const { data, error } = await mailchannels.suppressions.list(); * ``` */ list(options?: SuppressionsListOptions): Promise; } type AttachmentOptions = Omit; declare class Attachment { static fromBytes(data: ArrayBuffer | Uint8Array, options: AttachmentOptions): EmailsSendAttachment; static fromBlob(blob: Blob, options: AttachmentOptions): Promise; } declare class MailChannels extends MailChannelsClient { readonly emails: Emails; readonly domains: Domains; readonly webhooks: Webhooks; readonly subAccounts: SubAccounts; readonly metrics: Metrics; readonly suppressions: Suppressions; constructor(key: string, options?: MailChannelsClientOptions); } export { Attachment, type DataResponse, Domains, type DomainsCheckOptions, type DomainsCheckResponse, type DomainsCheckVerdict, type DomainsDkimCreateOptions, type DomainsDkimCreateResponse, type DomainsDkimKey, type DomainsDkimKeyStatus, type DomainsDkimListOptions, type DomainsDkimListResponse, type DomainsDkimRotateOptions, type DomainsDkimRotateResponse, type DomainsDkimUpdateStatusOptions, Emails, type EmailsQueueResponse, type EmailsSendAsyncResponse, type EmailsSendAttachment, type EmailsSendContent, type EmailsSendDkim, type EmailsSendOptions, type EmailsSendPersonalization, type EmailsSendRecipient, type EmailsSendRecipientInput, type EmailsSendResponse, type EmailsSendTemplate, type EmailsSendTemplateType, type EmailsSendTemplateValue, type EmailsSendTracking, type ErrorResponse, type ErrorType, MailChannels, MailChannelsClient, type MailChannelsClientOptions, Metrics, type MetricsBucket, type MetricsEngagement, type MetricsEngagementResponse, type MetricsOptions, type MetricsPerformance, type MetricsPerformanceResponse, type MetricsRecipientBehaviour, type MetricsRecipientBehaviourResponse, type MetricsSenders, type MetricsSendersOptions, type MetricsSendersResponse, type MetricsSendersType, type MetricsUsageResponse, type MetricsVolume, type MetricsVolumeResponse, type SubAccount, SubAccounts, type SubAccountsAccount, type SubAccountsApiKey, type SubAccountsApiKeysCreateResponse, type SubAccountsApiKeysListOptions, type SubAccountsApiKeysListResponse, type SubAccountsCreateApiKeyResponse, type SubAccountsCreateResponse, type SubAccountsCreateSmtpPasswordResponse, type SubAccountsLimit, type SubAccountsLimitResponse, type SubAccountsLimitsGetResponse, type SubAccountsLimitsSetOptions, type SubAccountsListApiKeyOptions, type SubAccountsListApiKeyResponse, type SubAccountsListOptions, type SubAccountsListResponse, type SubAccountsListSmtpPasswordResponse, type SubAccountsSmtpPassword, type SubAccountsSmtpPasswordsCreateResponse, type SubAccountsSmtpPasswordsListResponse, type SubAccountsUsage, type SubAccountsUsageResponse, type SuccessResponse, Suppressions, type SuppressionsCreateOptions, type SuppressionsListEntry, type SuppressionsListOptions, type SuppressionsListResponse, type SuppressionsSource, type SuppressionsTypes, type WebhookEvent, type WebhookEventClick, type WebhookEventComplained, type WebhookEventDelivered, type WebhookEventDropped, type WebhookEventHardBounced, type WebhookEventOpen, type WebhookEventProcessed, type WebhookEventSoftBounced, type WebhookEventTest, type WebhookEventType, type WebhookEventUnsubscribed, Webhooks, type WebhooksBatch, type WebhooksBatchResponseStatus, type WebhooksBatchStatus, type WebhooksBatchesOptions, type WebhooksBatchesResponse, type WebhooksListResponse, type WebhooksResendBatch, type WebhooksResendBatchResponse, type WebhooksSigningKeyResponse, type WebhooksValidateResponse, type WebhooksVerifyOptions, type WebhooksVerifyResponse };