PSend

Developers

Flutter

Generate Dart snippets with the http package. Demo keys stay in localStorage — production keys stay on your server.

Setup

  1. Add http: ^1.2.0 to pubspec.yaml.
  2. Create a test key in the PSend dashboard.
  3. Call https://api.runpsend.com/v1/emails via your backend in production.

Test harness

Sample Dart

import 'dart:convert';
import 'package:http/http.dart' as http;

Future<Map<String, dynamic>> sendEmail({
  required String apiKey,
  required String from,
  required String to,
  required String subject,
  required String html,
}) async {
  final res = await http.post(
    Uri.parse('https://api.runpsend.com/v1/emails'),
    headers: {
      'Authorization': 'Bearer $apiKey',
      'Content-Type': 'application/json',
    },
    body: jsonEncode({
      'from': from,
      'to': to,
      'subject': subject,
      'html': html,
    }),
  );

  if (res.statusCode == 402) {
    throw StateError('Wallet empty — top up in PSend dashboard');
  }

  return jsonDecode(res.body) as Map<String, dynamic>;
}

Webhook listener tip

Handle webhook events on a server. Flutter apps should poll your API or use push notifications after your backend processes email.delivered / email.bounced.

Security

Never embed live keys in Flutter apps. Proxy sends through your authenticated backend. This harness is for demos only — keys never leave localStorage in the browser.