Verify
Prove someone has a phone number or a mailbox with a one-time code.
coss.verify sends a one-time code to a phone number (SMS) or an email address and checks the
code the person typed. coss.com makes the code, sends it, keeps only a keyed hash of it, counts
the attempts and expires it; your backend makes two calls. SMS codes go from coss.com's own
numbers unless you choose one of yours, so there is nothing to register first.
// 1. The user typed their number: send them a code.
const { : } = await ..({ : "+14155550123", : });
// 2. They typed the code they got: check it.
const { : } = await ..({ : "+14155550123", : "482913" });
if (?.) {
// The number is theirs.
}Only valid: true proves the person has the phone or mailbox. Check on your backend, never in the
browser, and treat the API key as you would any secret.
How a verification goes
- Start it with
to: a number in E.164 form (+14155550123) gets an SMS, an email address an email (or passchannel). Pass the end user'sip, and youruser_idif you have one: the fraud guard uses them. - It is checked before anything is sent. A verification the fraud guard blocks is stored as
blockedwith itsreasons, the call fails withverification_blocked, and nothing is sent or billed. - The code goes out — 6 digits by default — and the verification is
pendinguntil it expires (10 minutes by default). - Check the code. By
to(the destination's latest verification) or byverification_id. The right code makes itapproved(verification.approved); a wrong one spends an attempt, and the fifth wrong one fails it (verification.failed). Checking an approved verification again with its code stays valid until it expires, without being billed again.
Starting again for the same destination while a verification is pending sends a new code
(the earlier one stops working, and the expiry restarts), up to 5 times; cancel one with
coss.verify.cancel(id). Code length, lifetime, attempts, senders and the countries SMS codes
may go to are the environment's Verify settings in the dashboard.
Pricing
You pay per approved verification, plus the channel: an SMS from coss.com's numbers is billed
at the SMS price of its country (verify.sms), one from your own number as any SMS, and email
costs nothing extra. Verifications that are blocked, fail or expire cost only the messages
actually sent. See pricing.
What's in it
On This Page