Sign in

API and library

Send email and verification codes from your own site or app. Call the API from your server; never put the key in a browser or mobile app.

1. Get a key

In the web app open Account > API, create a key and choose the sender address. The key is shown once. The sender domain must be verified.

2. Add the library

yoyomail.js (Node 18+, Deno, Bun) · YoyoMail.php (PHP 7.4+)

3. Send a verification code

JavaScript

import { YoyoMail } from './yoyomail.js';
const mail = new YoyoMail(process.env.YOYOMAIL_KEY, { baseUrl: 'https://mail.yoyohq.net' });

// During sign-up or sign-in
const { id } = await mail.sendCode('musteri@example.com', { brand: 'Acme', lang: 'en' });
// keep id in the session; when the user types the code
const { valid, reason } = await mail.checkCode(id, '123456');

PHP

require 'YoyoMail.php';
$mail = new YoyoMail(getenv('YOYOMAIL_KEY'), 'https://mail.yoyohq.net');

$r = $mail->sendCode('musteri@example.com', ['brand' => 'Acme']);
$_SESSION['code_id'] = $r['id'];
// ...
$ok = $mail->checkCode($_SESSION['code_id'], $_POST['code'])['valid'];

curl

curl https://mail.yoyohq.net/api/v1/verify/send \
  -H "Authorization: Bearer ym_..." -H "Content-Type: application/json" \
  -d '{"to":"musteri@example.com","brand":"Acme"}'

curl https://mail.yoyohq.net/api/v1/verify/check \
  -H "Authorization: Bearer ym_..." -H "Content-Type: application/json" \
  -d '{"id":"vc_...","code":"123456"}'

4. Send your own message

await mail.send({
  to: 'musteri@example.com',
  subject: 'Your order has shipped',
  text: 'Your tracking number: 123',
  html: '<p>Your tracking number: <b>123</b></p>',
  fromName: 'Acme',
});

Endpoints

All use Authorization: Bearer ym_... and JSON bodies.

POST /api/v1/verify/sendto, brand, lang (tr|en), digits (4-8), ttl (seconds, 60-3600) → { id, to, expiresAt }
POST /api/v1/verify/checkid, code → { valid, reason, attemptsLeft }
POST /api/v1/sendto, subject, text, html, cc, bcc, fromName → { id, delivered, queued, rejected }
GET /api/v1/me→ { from, account, plan, sentToday, dailyLimit }

Rules and limits