@ptkl/sdk - v1.3.4
    Preparing search index...

    SDK client for the Protokol Mail integration.

    Provides methods to send emails, list email logs, resend failed emails, and manage attachments through the Protokol Mail API.

    import { Mail } from "@ptkl/sdk/beta"

    const mail = new Mail()

    // Send an email
    const result = await mail.send({
    to: ["user@example.com"],
    subject: "Hello",
    body: "<h1>Welcome!</h1>"
    })

    console.log(result.message_id)

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • Optionaloptions: { env?: string; host?: string; token?: string }

      Returns default

    Properties

    client: AxiosInstance
    env: null | string = null
    host: null | string = null
    token: null | string = null

    Methods

    • Download an attachment's binary content.

      Parameters

      • messageId: string

        The UUID of the email message

      • attachmentId: string

        The UUID of the attachment

      Returns Promise<ArrayBuffer>

      The raw binary data as an ArrayBuffer

      const content = await mail.downloadAttachment(
      "550e8400-e29b-41d4-a716-446655440000",
      "660e8400-e29b-41d4-a716-446655440000"
      )
    • Get a single email by its message ID.

      Parameters

      • messageId: string

        The UUID of the email message

      Returns Promise<MailLog>

      The full email log entry

      const email = await mail.get("550e8400-e29b-41d4-a716-446655440000")
      console.log(email.status, email.subject)
    • List emails for the current project with optional filtering and pagination.

      Parameters

      • Optionalparams: ListEmailsParams

        Optional query parameters for filtering and pagination

      Returns Promise<EmailListResponse>

      Paginated list of email log entries

      // List all emails
      const emails = await mail.list()

      // List failed emails, page 2
      const failed = await mail.list({ status: "failed", page: 2, limit: 10 })
    • List attachment metadata for a specific email.

      Parameters

      • messageId: string

        The UUID of the email message

      Returns Promise<AttachmentMeta[]>

      Array of attachment metadata entries

      const attachments = await mail.listAttachments("550e8400-e29b-41d4-a716-446655440000")
      attachments.forEach(att => console.log(att.file_name, att.file_size))
    • Resend a previously failed email. Resets the retry counter and re-queues the email for delivery.

      Parameters

      • messageId: string

        The UUID of the email to resend

      Returns Promise<SendEmailResponse>

      Confirmation with the message ID

      await mail.resend("550e8400-e29b-41d4-a716-446655440000")
      
    • Send an email. The email is queued for async delivery.

      Supports both JSON body (with base64-encoded attachments) and multipart/form-data (with file uploads).

      Parameters

      Returns Promise<SendEmailResponse>

      The queued email's message ID and status

      const result = await mail.send({
      to: ["recipient@example.com"],
      cc: ["cc@example.com"],
      subject: "Invoice #123",
      body: "<p>Please find your invoice attached.</p>",
      reply_to: "billing@company.com",
      sender_name: "Billing Department",
      attachments: [{
      file_name: "invoice.pdf",
      mime_type: "application/pdf",
      content: "base64encodedcontent...",
      size: 12345
      }]
      })
    • Parameters

      • client: AxiosInstance

      Returns default