Quick Start

Send your first email with Transactional in under 5 minutes.

Quick Start

This guide will walk you through sending your first email with Transactional.

Prerequisites

Before you begin, make sure you have:

  • A Transactional account (sign up here)
  • Your API key from the dashboard
  • The SDK installed in your project

Step 1: Initialize the Client

import { Transactional } from 'transactional-sdk';
 
const client = new Transactional(process.env.TRANSACTIONAL_API_KEY);

Step 2: Send an Email

const response = await client.emails.send({
  from: 'hello@yourdomain.com',
  to: 'recipient@example.com',
  subject: 'Hello from Transactional!',
  html: '<h1>Hello World</h1><p>This is my first email!</p>',
});
 
console.log('Email sent:', response.id);

Step 3: Check the Response

The send method returns a response object with the email ID and status:

{
  id: 'msg_abc123',
  status: 'sent',
  timestamp: '2024-01-01T12:00:00Z',
}

Using Templates

You can also send emails using pre-built templates:

await client.emails.send({
  from: 'hello@yourdomain.com',
  to: 'recipient@example.com',
  template: 'welcome-email',
  data: {
    name: 'John',
    company: 'Acme Inc',
  },
});

Next Steps