Sign in with one WhatsApp message
Wamen is hosted sign-in for your web app. Your user sends one prefilled message, and your backend gets a signed identity token. No passwords, no email, no app registration.
- Your appThe user taps your sign-in button.
- WamenThe page names yourapp.com and opens WhatsApp.
- One messageThe user sends the prefilled message.
- Wamen sees itThe page continues on its own.
- Signed inYour server verifies the token.
A simulation of one sign-in. The Wamen steps use the real page's wording; its QR and fallbacks are left out.
Install Wamen
Type your app's hostname. Every snippet below uses your exact origin, ready to copy into your editor or your coding agent.
AI prompt
Integrate Wamen passwordless sign-in into this application.
This application's public origin is https://yourapp.com.
Authoritative context:
- Read https://wamen.link/llms.txt first.
- Read https://wamen.link/llms-full.txt for the complete current contract.
- Use issuer https://wamen.link exactly.
- Do not invent Wamen APIs, parameters, scopes, claims, packages, or session endpoints.
Current release constraints:
- @wamenjs/auth@0.1.1 and @wamenjs/server@0.2.0 are published on npm.
- Use @wamenjs/auth for bundled browser applications or the hosted module at https://wamen.link/wamen.js for server-rendered and no-build applications.
- Use @wamenjs/server for backend identity verification. The direct jose verifier at https://wamen.link/docs/server-verification remains the framework-independent reference.
- Wamen is authorization-code-and-PKCE-shaped, but it does not claim full OAuth or OpenID Connect compliance.
- Supported scopes are openid and optional phone. Phone requires fresh consent for every login.
Required implementation:
1. Inspect the existing framework, routing, session, cookie, and test conventions before editing.
2. Add a same-origin callback URL. Public callbacks must use HTTPS; HTTP is allowed only for localhost or loopback.
3. Reuse the application's package and framework conventions. For a bundled browser app, install @wamenjs/auth. For a server-rendered or no-build app, register the wamen:authentication-complete listener before loading wamen.js.
4. Stop automatic callback navigation while the app session is created. With @wamenjs/auth, call handleCallback({ navigate: false, persist: false }); with the hosted module, call event.preventDefault() synchronously. Send only identity.idToken to the app backend, await the response, clear the browser identity in a finally block when using the hosted module, then navigate to the validated returnTo only after the backend session succeeds.
5. On the backend, install @wamenjs/server and verify the token with createWamenVerifier({ issuer, audience }). Treat ES256, kid, issuer, exact audience, subject format, iat, exp, a lifetime of at most 600 seconds, jti, amr=["whatsapp"], and the optional phone pair as enforced package invariants. Accept each token once: record identity.jwtId until identity.expiresAt and reject a repeated jwtId.
6. Derive the audience as origin: plus the normalized application origin, including a non-default port when present.
7. Find or create the app user by the verified pairwise subject. Never use a browser-decoded claim or phone number as the stable identity key.
8. Create the application's own opaque session and set a Secure, HttpOnly, SameSite=Lax cookie. Do not use the Wamen identity token as a durable app session.
9. Keep returnTo same-origin. Do not add open redirects.
10. Add behavior tests for successful sign-in, wrong state, backend rejection, wrong issuer or audience, expired token, optional phone, logout, and cookie attributes.
Do not:
- trust JWT claims in browser code;
- log tokens, authorization codes, phone numbers, message bodies, or raw callback URLs;
- request phone unless the product needs it and explains why;
- add access tokens, refresh tokens, remembered Wamen sessions, email, name, or profile claims;
- claim official Meta or WhatsApp affiliation.
Finish by running the project's formatter, type checker, targeted tests, and a browser smoke test of the complete callback-to-session path. Report exact files changed and verification evidence.
Paste into Claude Code, Cursor or Codex in your app's repository. The agent reads llms.txt and builds the secure flow.
Script
<script type="module"
src="https://wamen.link/wamen.js"></script>
<a data-wamen-authorize
href="https://wamen.link/authorize">
Continue with WhatsApp
</a>
Two tags for server-rendered or no-build pages. Verify the token on your backend before you create a session.
npm
npm install @wamenjs/auth @wamenjs/server
// browser
import { createWamenAuth } from "@wamenjs/auth";
const auth = createWamenAuth({
redirectUri: "https://yourapp.com/callback",
});
await auth.signIn();
// server
import { createWamenVerifier } from "@wamenjs/server";
const verifier = createWamenVerifier({
issuer: "https://wamen.link",
audience: "origin:https://yourapp.com",
});
For bundled apps: @wamenjs/auth in the browser, @wamenjs/server on your backend.
What your users see
Every screen names your hostname, and Wamen never replies in the chat. These are the real authorization pages for a request from yourapp.com, rendered with a sample request.
How one sign-in runs
-
First, your page redirects to Wamen.
Requestpending
foryourapp.com
PKCES256
expiresin 3 min
-
Then your user sends the message.
Requestreceived
foryourapp.com
textexact match
replynone
-
Next, your callback gets a code.
Codeissued
value
wcode_…useonce
expiresin 60 s
-
Last, your server checks the token.
Tokenverified
algES256
sub
wam_…expiresin 10 min
Two tags in, one token out
Your page
<script type="module"
src="https://wamen.link/wamen.js"></script>
<a data-wamen-authorize
href="https://wamen.link/authorize">
Continue with WhatsApp
</a>
Your backend
import { createWamenVerifier } from "@wamenjs/server";
const verifier = createWamenVerifier({
issuer: "https://wamen.link",
audience: "origin:https://yourapp.com",
});
const identity = await verifier.verify(idToken);
// identity.subject is your user key
identity
{
issuer: "https://wamen.link",
audience: "origin:https://yourapp.com",
subject: "wam_h8uBU6-Wv3PVJ9L60GEl82sqEPQQbbWSnksOkmIEDAE", // sample value
issuedAt: 1792540800,
expiresAt: 1792541400,
jwtId: "7f0c2e8a-51d4-4c1b-9a63-0e5b2d7f9c14",
authenticationMethods: ["whatsapp"]
}
The hosted script creates PKCE and state, handles the callback, and exposes window.Wamen. The secure quickstart shows the session endpoint in full.
What the token carries
| Claim | scope openid | scope openid phone |
|---|---|---|
iss |
https://wamen.link | https://wamen.link |
aud |
origin:https://yourapp.com | origin:https://yourapp.com |
sub |
wam_ plus 43 characters | The same subject |
exp |
10 minutes after iat | 10 minutes after iat |
amr |
||
phone_number |
Not present | E.164 number, verified |
| Stored by Wamen afterwards | A keyed hash of the account | The same hash, no phone number |
Reject a reused jti until it expires. Discovery lives at /.well-known/wamen-configuration and keys at /.well-known/jwks.json.
What it costs
Nothing, while Wamen is a free public work in progress. There is no account to open and no card to enter. Each sign-in costs your user one WhatsApp message.
$0
- One WhatsApp number, so sign-in stops when it disconnects
- No SLA and no uptime promise
- Sign-in starts are rate limited per IP and per app
- @wamenjs/auth@0.1.1 and @wamenjs/server@0.2.0 on npm
Before you trust it
Do I register my app or get an API key?
No. Your app is identified by the exact origin of its callback URL. The token audience is origin: plus that origin, so a token for one app is rejected by another.
What does my backend receive?
An ES256 identity token that lives 10 minutes, with issuer, audience, a pairwise wam_ subject, issue and expiry times, a token ID and amr set to whatsapp. Phone claims appear only when you ask for them. Verify it with @wamenjs/server or any JOSE library against the published JWKS.
Can two apps link the same person?
No. The subject is derived from the person and your exact origin, so every app sees a different wam_ value for the same WhatsApp account.
When do I get the phone number?
Only when you request the phone scope. The user sees the request on the authorization page and grants it by sending a fresh message on that login. Wamen deletes the number once your code is used.
What if the user edits or never sends the message?
Wamen accepts only the exact text it prefilled. An edited message is ignored, and the request expires after 3 minutes. Your page never receives an identity it did not ask for.
What happens when WhatsApp is disconnected?
Sign-in fails closed and the authorization page says so. Wamen runs on one WhatsApp number with no SLA, so check the status page and keep another way into accounts that matter.
Who owns the session and the user record?
Your app does. Wamen proves control of a WhatsApp account once. You map the subject to your user, then create your own HttpOnly session.
How does a user delete their Wamen identity?
From the deletion page, by sending a fresh WhatsApp proof. Future sign-ins then receive new subjects, and data inside your app stays yours to handle.