InterfaceSDK v0.2.1

EmailTemplateMethods

Email surface methods for a specific template.

import type { EmailTemplateMethods } from '@usepapier/client/base';

Declaration #

surfaces.tsTypeScript
export interface EmailTemplateMethods<TPayload = any> {
    send: (args: {
        to: string | string[];
        subject?: string;
        template?: string;
        data: TPayload;
    }) => Promise<{
        success: true;
        adapter: string;
        id?: string;
    }>;
    sendBulk: (items: {
        to: string;
        data: TPayload;
        subject?: string;
    }[], opts?: {
        concurrency?: number;
        stopOnError?: boolean;
    }) => Promise<({
        index: number;
        success: true;
        adapter: string;
        id?: string;
    } | {
        index: number;
        success: false;
        error: string;
    })[]>;
    renderHTML: (args: {
        data: TPayload;
    }) => Promise<string>;
    build: (args: {
        to: string | string[];
        subject?: string;
        template?: string;
        data: TPayload;
    }) => Promise<BuiltEmailPayload<TPayload>>;
}

Source: packages/client/src/core/surfaces.ts:50

Members 4

Send a single email using this template.

send: (args: {
    to: string | string[];
    subject?: string;
    template?: string;
    data: TPayload;
}) => Promise<{
    success: true;
    adapter: string;
    id?: string;
}>;

Parameters

args
{ to: string | string[]; subject?: string; template?: string; data: TPayload; }

packages/client/src/core/surfaces.ts:52

Send bulk emails.

sendBulk: (items: {
    to: string;
    data: TPayload;
    subject?: string;
}[], opts?: {
    concurrency?: number;
    stopOnError?: boolean;
}) => Promise<({
    index: number;
    success: true;
    adapter: string;
    id?: string;
} | {
    index: number;
    success: false;
    error: string;
})[]>;

Parameters

items
{ to: string; data: TPayload; subject?: string; }[]
optsOptional
{ concurrency?: number; stopOnError?: boolean }

packages/client/src/core/surfaces.ts:60

Server-side render HTML for this template.

renderHTML: (args: {
    data: TPayload;
}) => Promise<string>;

Parameters

args
{ data: TPayload }

packages/client/src/core/surfaces.ts:75

Build and validate a payload for later sending (outbox pattern). The returned payload can be stored and sent later using papier.send().

build: (args: {
    to: string | string[];
    subject?: string;
    template?: string;
    data: TPayload;
}) => Promise<BuiltEmailPayload<TPayload>>;

Parameters

args
{ to: string | string[]; subject?: string; template?: string; data: TPayload; }

packages/client/src/core/surfaces.ts:81

Generated from TypeScript source.d65ea8f71fbf