Email API•1 min read

Send mail with the Piisend REST API

From API key to first POST /emails—curl and Node examples for OTP, reset, and receipt templates, plus links to domains and webhooks docs.

Send mail with the Piisend 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 /api/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
1curl -X POST https://api.piisend.com/api/v1/emails \
2 -H "Authorization: Bearer YOUR_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "to": "user@example.com",
6 "subject": "Verify your account",
7 "html": "<p>Your code is <strong>482913</strong></p>",
8 "text": "Your code is 482913"
9 }'

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
1const res = await fetch('https://api.piisend.com/api/v1/emails', {
2 method: 'POST',
3 headers: {
4 Authorization: `Bearer ${process.env.PIISEND_API_KEY}`,
5 'Content-Type': 'application/json',
6 },
7 body: JSON.stringify({
8 to: 'user@example.com',
9 subject: 'Password reset',
10 html: '<p>Reset here: https://app.example.com/reset</p>',
11 }),
12});
13
14const data = await res.json();
15console.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.