Developer Quickstarts

Code snippets in your preferred language

Integrate RelayPulse in under 5 minutes using our clean REST API or SMTP endpoints.

PHP

PHP & Laravel

use Illuminate\Support\Facades\Http;

$response = Http::withToken('rp_live_your_api_key')
    ->post('https://relaypulse.io/api/v1/emails', [
        'from' => [
            'email' => 'noreply@yourdomain.com',
            'name' => 'Support Desk'
        ],
        'to' => [
            ['email' => 'customer@example.com', 'name' => 'Jane Doe']
        ],
        'subject' => 'Your Order #92817 is Confirmed',
        'html' => '<h1>Thank you Jane!</h1><p>Your package has shipped.</p>',
        'open_tracking' => true,
        'click_tracking' => true,
    ]);

if ($response->successful()) {
    $messageId = $response->json('data.message_id');
    echo "Queued successfully: " . $messageId;
}
JS

Node.js / Express

import axios from 'axios';

async function sendOtp(email, otp) {
  try {
    const response = await axios.post('https://relaypulse.io/api/v1/emails', {
      from: { email: 'auth@myapp.com', name: 'Security' },
      to: [{ email }],
      subject: `Your Security Code: ${otp}`,
      html: `<p>Your OTP code is <strong>${otp}</strong></p>`,
    }, {
      headers: {
        'Authorization': `Bearer ${process.env.RELAYPULSE_API_KEY}`,
        'Content-Type': 'application/json'
      }
    });

    console.log('Dispatched message ID:', response.data.data.message_id);
  } catch (err) {
    console.error('Delivery error:', err.response?.data || err.message);
  }
}
PY

Python 3

import requests

def send_alert(recipient, alert_text):
    payload = {
        "from": {"email": "monitoring@infra.io", "name": "System Monitor"},
        "to": [{"email": recipient}],
        "subject": "[CRITICAL] Server CPU spike detected",
        "html": f"<h3>Alert Triggered</h3><p>{alert_text}</p>"
    }
    
    headers = {
        "Authorization": "Bearer rp_live_your_api_key",
        "Content-Type": "application/json"
    }
    
    res = requests.post("https://relaypulse.io/api/v1/emails", json=payload, headers=headers)
    print("Response:", res.json())