Email API1 min read

How to Send Transactional Emails with Piisend's REST API

Learn how to quickly integrate Piisend's REST API to send essential transactional emails like OTPs, password resets, and receipts, ensuring reliable delivery and easy setup for developers.

How to Send Transactional Emails with Piisend's REST API

Section 1

What are Transactional Emails?

Transactional emails are automated, one-to-one messages triggered by a user's action, such as password resets, order confirmations, or account verifications. Unlike marketing emails, they are crucial for user experience and often legally required. Piisend provides a robust API designed for developers to reliably send these critical communications.

Section 2

Setting Up Your Piisend Account and API Key

Sign up at piisend.com, open the dashboard, and create an API key under API Keys. Store it in an environment variable — never commit keys to git. Use separate keys for development and production.

Section 3

Sending an Email with cURL

Piisend's REST API accepts a JSON payload at POST /v1/emails. Include your API key in the Authorization header and provide at least one of html or text plus a recipient and subject.

bash
curl -X POST https://api.piisend.com/v1/emails \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "subject": "Verify your account",
    "html": "<p>Your code is <strong>482913</strong></p>",
    "text": "Your code is 482913"
  }'

Section 4

Sending from Node.js

The same payload works from any HTTP client. Here is a minimal fetch example you can drop into an Express route or server action.

javascript
const res = await fetch('https://api.piisend.com/v1/emails', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PIISEND_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    to: 'user@example.com',
    subject: 'Password reset',
    html: '<p>Reset here: https://app.example.com/reset</p>',
  }),
});

const data = await res.json();
console.log('Message ID:', data.id);

Section 5

Tracking Delivery and Webhooks

After sending, inspect delivery status in the dashboard logs or subscribe to webhooks for bounce, delivery, and engagement events. Configure webhook URLs in the dashboard and verify signatures before trusting payloads in production.

Start sending

Ship transactional email in minutes

Create an API key, verify a domain, and send your first message with Piisend.