Verify API
Send a code and check it from your server, behind your own UI.
Use this when you want your own code-entry form. Two calls, both from your
server with the API key. The curl examples read the key from
$VERIFYME_API_KEY.
Send
const { token, exp } = await verifyme.send({
target: "+85512345678",
provider: "sms", // email | whatsapp | telegram | voice | sms:<slug> | auto
length: 6, // 4–8, default 4
timeout: 300, // seconds, 10–300, default 60
})| Field | Notes |
|---|---|
target | E.164 phone (+855…) or email address |
provider | Channel or pinned profile — see Concepts |
template_id | A saved template, by id or slug (sign-in); otherwise the channel default, then a built-in message |
template | Inline text with {{code}} — overrides saved templates |
locale | Message language, e.g. es, pt-BR. Omitted, a phone number's country picks it |
method | code (default) or link — see Magic links |
code | Deliver your own code instead — see Integrations |
send_only | With code: deliver without tracking; the verification closes as sent |
client | { ip, user_agent } of the end user you send for — see Firewall |
The token is a credential. Keep it on the server (session, cache, DB row) —
never in the browser, a URL or a log.
Check
const { success } = await verifyme.check({ token, code })success: false for a wrong, spent or expired code. Anything else — bad key,
firewall, rate limit, outage — throws a VerifymeError.
Five wrong attempts burn the token; the user needs a new code. Every failure returns the same message, so nothing leaks about why.
Status
GET /api/v1/verify/:token (verifyme.status(token)) returns
{ status, target, created_at } without spending an attempt.
curl https://verifyme.cubis.tech/api/v1/verify/$TOKEN \
-H "x-api-key: $VERIFYME_API_KEY"Languages
Every built-in message exists in 20+ languages. Pass locale, or leave it
out and a phone number's country picks one (+55… gets Brazilian
Portuguese, +855… Khmer). Saved templates can have a language too: the
closest match wins (pt-BR, then pt, then the template with no language).
await verifyme.send({ target: "+34600000000", locale: "es" })
// "Tu código de verificación es 482915. Caduca en 1 min."Magic links
method: "link" sends a sign-in link instead of a code. The link opens
link_url with verifyme_token and verifyme_code added to its query; that
page passes them to check(). link_url must be https on one of your allowed
origins (Console → Widget), so a link can never point anywhere else.
await verifyme.send({
target: "ada@example.com",
provider: "email",
method: "link",
link_url: "https://app.example.com/auth/callback",
})
// On /auth/callback, server-side:
const { success } = await verifyme.check({
token: url.searchParams.get("verifyme_token")!,
code: url.searchParams.get("verifyme_code")!,
})A saved template carries a link with {{link}}; one without it falls back to
the built-in link message.
Voice
provider: "voice" calls the number and reads the code twice, digit by digit,
in the message's language — the fallback where SMS does not arrive. Add a
Twilio Voice profile under Providers → Voice.
When a send is refused
A 403 means the firewall stopped the send — one of your
rules, or AI detection. A 429 with Retry-After is a rate or send limit.
Either way nothing was delivered and nothing is charged; the response's
trace_id finds the matching row in Console → Audit logs. For example,
with AI detection enforcing, a number no operator issues:
curl -i -X POST https://verifyme.cubis.tech/api/v1/verify \
-H "x-api-key: $VERIFYME_API_KEY" -H "content-type: application/json" \
-d '{"target":"+85511111111"}'
# HTTP/2 403
# {"status":403,"detail":"This request was blocked by security rules.","trace_id":"…"}A complete flow
app.post("/phone/start", async (req, res) => {
const { token } = await verifyme.send({ target: req.body.phone, provider: "sms" })
req.session.verify = { token, phone: req.body.phone }
res.sendStatus(204)
})
app.post("/phone/confirm", async (req, res) => {
const pending = req.session.verify
if (!pending) return res.sendStatus(400)
const { success } = await verifyme.check({ token: pending.token, code: req.body.code })
if (!success) return res.status(400).json({ error: "Wrong or expired code" })
delete req.session.verify
await users.markPhoneVerified(req.user.id, pending.phone)
res.sendStatus(204)
})Message templates
Create wording per channel in Console → Templates (SMS, email with subject
and HTML, Telegram) and mark one default. Variables: {{code}} (required),
{{app_name}}, {{minutes}}.