TypeScript SDK for plop.email

The official TypeScript SDK with built-in polling, typed responses, and zero runtime dependencies. One line to wait for emails.

TypeScript SDK Documentation

Features

Built-in Polling

Use waitFor() to poll for emails with configurable timeout and interval. No manual retry loops.

Typed Responses

Full TypeScript types for all API responses. Autocomplete for message fields, filters, and options.

Zero Dependencies

No runtime dependencies. Uses native fetch under the hood. Works in Node.js, Bun, and Deno.

Webhook Verification

Built-in webhook signature verification with verifyWebhookSignature() for secure integrations.

Setup

# Install the SDK
npm install @plop-email/sdk

# Set your API key
export PLOP_API_KEY=your_api_key

Wait for an Email

Initialize the client and wait for an email to arrive. One line replaces manual polling loops.

Wait for an Emailtypescript
import { Plop } from '@plop-email/sdk';

const plop = new Plop({ apiKey: process.env.PLOP_API_KEY });

// Wait for the latest email (polls automatically)
const message = await plop.waitFor({
  mailbox: 'qa',
  tag: 'signup',
  timeout: 10_000,
});

// Typed response — full autocomplete
console.log(message.subject);
console.log(message.textContent);

// Extract OTP from email body
const otp = message.textContent?.match(/\b\d{6}\b/)?.[0];

List, Filter & Verify Webhooks

List messages with filters and verify incoming webhook signatures.

List, Filter & Verify Webhookstypescript
import { Plop, verifyWebhookSignature } from '@plop-email/sdk';

const plop = new Plop({ apiKey: process.env.PLOP_API_KEY });

// List messages with filters
const messages = await plop.messages.list({
  mailbox: 'qa',
  tag: 'password-reset',
  limit: 5,
});

for (const msg of messages.data) {
  console.log(`${msg.subject}${msg.from}`);
}

// Verify webhook signature
const isValid = verifyWebhookSignature({
  payload: requestBody,
  signature: headers['x-plop-signature'],
  secret: process.env.PLOP_WEBHOOK_SECRET!,
});

Tips

  • Use waitFor() instead of manual polling loops — it handles retries and timeout
  • Set PLOP_API_KEY as an environment variable to avoid hardcoding secrets
  • Use the tag parameter to isolate emails per test for parallel execution
  • The SDK works with any test framework — Playwright, Cypress, Jest, Vitest
  • Use plop.messages.stream() for real-time SSE notifications instead of polling
  • Manage webhooks programmatically with plop.webhooks.create(), .delete(), .toggle()

Start testing with TypeScript SDK

Add email verification to your TypeScript SDK tests in minutes.