Free email OTP login for your website
Send a 6-digit code to a user's email, verify it, and get a signed token your server can trust. No phone numbers, no SMS bills, no passwords.
Developer dashboard
Log in with your email. We send you a code, so there is no password to remember. New emails are signed up automatically.
Logged in as
Your apps
Create an app
Docs: start to finish
1. How it works
- The user types their email on your site. Your site calls
/v1/otp/send. - We email: "Your account verification code for YourPlatform is 123456." The code is valid for 5 minutes and works once.
- The user types the code. Your site calls
/v1/otp/verify. If it is right, you get a signed token. - Your server checks the token and logs the user in. Never trust the browser alone.
2. Get your keys
Log in above and create an app. You get three values:
- App ID: identifies your app, and is the token's audience.
- Public key (
pk_...): safe to put in browser code. It only works from the origins you listed. - Secret key (
sk_...): server only. Never put it in a website, an app or a repo. Shown once. If it leaks, use "New secret key".
3. Send a code
POST {{HOST}}/v1/otp/send
X-Public-Key: pk_... (browser) or Authorization: Bearer sk_... (server)
Content-Type: application/json
{ "email": "user@example.com" }
200 { "request_id": "uuid", "expires_in": 300, "resend_after": 60 }
To send again, call the same endpoint (or /v1/otp/resend). The older code stops working.
4. Verify the code
POST {{HOST}}/v1/otp/verify
{ "request_id": "uuid-from-send", "email": "user@example.com", "code": "123456" }
200 { "verified": true, "email": "user@example.com", "token": "eyJ...", "expires_in": 600 }
5. Check the token on your server
The token is a JWT signed with ES256. Check it with our public keys, no extra call to us needed. Check issuer, audience (your App ID) and expiry.
// npm i jose
import { createRemoteJWKSet, jwtVerify } from 'jose';
const jwks = createRemoteJWKSet(new URL('{{HOST}}/.well-known/jwks.json'));
export async function emailFromToken(token) {
const { payload } = await jwtVerify(token, jwks, {
issuer: 'otp-codes-service',
audience: 'YOUR_APP_ID' // the App ID from your dashboard
});
return payload.sub; // the verified email
}
6. Full browser example
const API = '{{HOST}}/v1/otp', PK = 'pk_your_public_key';
const call = (p, b) => fetch(API + p, { method: 'POST',
headers: { 'content-type': 'application/json', 'x-public-key': PK }, body: JSON.stringify(b) }).then(r => r.json());
const { request_id } = await call('/send', { email });
// ...user types the code...
const r = await call('/verify', { request_id, email, code });
if (r.token) await fetch('/my-backend/login', { method: 'POST', body: JSON.stringify({ token: r.token }) });
7. Server-side example (curl)
curl -X POST {{HOST}}/v1/otp/send \
-H "Authorization: Bearer sk_your_secret_key" -H "content-type: application/json" \
-d '{"email":"user@example.com"}'
8. Errors
| Status / code | Meaning |
|---|---|
| 400 invalid_email, invalid_input | Bad request body. |
| 400 invalid_code | Wrong, expired or already used code. |
| 401 unauthorized | Missing or unknown key. |
| 403 origin_not_allowed | The public key was used from a website not in your list. |
| 429 cooldown | Wait 60 seconds between codes for the same email. |
| 429 rate_email / rate_ip / rate_app | Hourly limit per email (5) or per IP (30), or your daily app limit (100) was reached. |
| 429 too_many_attempts | 5 wrong tries. Request a new code. |
| 502 email_failed | The email could not be sent. Try again. |
9. Limits and security
- Free plan: 100 codes per app per day. Codes are 6 digits, valid 5 minutes, 5 attempts, single use.
- Codes and emails are never stored in readable form, only as hashes.
- Browser keys can be copied by anyone who views your page source. That is why they are limited to your origins and rate limited. Keep real logic on your server with the secret key.
- Always verify the token on your server before logging someone in.
- Emails are sent from a shared sender, so they can land in spam. Tell users to check there.