Skip to content

Phone sign-in for apps

Sign users in with a phone number. A one-time code — 6 digits unless the project chose otherwise — is sent to confirm the number.

A project is set up in one of two ways, and your app should handle both.

Password project (the original) Passwordless project
Registering signup with a password request-code — no password anywhere
Signing in login with the password request-code, then verify
Where the token comes from login verify
password / forgot-password / reset-password used rejected (400)

Call config once at startup and let the answer decide which screens you draw. Do not hardcode it per customer: the same app binary is expected to work for a partner who later switches, and switching is a setting in the dashboard.

The rest of this page documents the password flow first, because it is the older one. The passwordless flow is in its own section and is short — it reuses verify, the codes, the rate limits and the errors unchanged.

Every call goes to https://openapi.rogo.com.vn/api/v1.

Every endpoint is /authen/phone/.... The phone part is required.

https://openapi.rogo.com.vn/api/v1/authen/phone/signup
^^^^^^ ^^^^^^^^^^^^
version always "authen/phone"
  • ✅ /api/v1/authen/phone/signup
  • ❌ /api/v1/authen/signup is a different, older API for email accounts. Not this one.

/api/v2.0/authen/phone/... also works and behaves identically, if v2.0 is what your other calls already use. Pick one and stay on it.

POST <base>/authen/phone/<action>
x-appkey: <your app key>
x-appsecret: <your app secret>
Content-Type: application/json

No bearer token. The app key identifies your project, so you never send a project id.

config is the one GET, and takes no body. Same two headers.

Always send E.164, with the country code and a leading +.

  • ✅ +84975907414
  • ❌ 0975907414 (no country code)
  • ❌ 84975907414 (no leading +)

Spacing is tolerated (+84 97 590 7414); the + and country code are not optional. Any country code is accepted, so this works for non-Vietnamese numbers too. Where we know a country’s rules we also check the length, so a mistyped Vietnamese number is caught here instead of failing later at the gateway.

If your UI collects a local 0… Vietnamese number, convert before calling:

const e164 = "+84" + input.replace(/[^0-9]/g, "").replace(/^0/, "")
Action Body Success
config (GET) — which flow this project uses, see example 0
signup phone, password, username + channel (optional) {"success":true} and a code is sent
request-code phone, channel + username (optional) {"success":true} and a code is sent — passwordless only
verify phone, code {"success":true}, plus a token on a passwordless project
resend phone {"success":true} and a new code
login phone, password token, see example 4 — password projects only
forgot-password phone {"success":true} and a code — password projects only
reset-password phone, code, newPassword {"success":true} — password projects only

All are ready to paste. Replace YOUR_APP_KEY and YOUR_APP_SECRET.

Call this once at startup, before drawing any auth screen.

Terminal window
curl -H "x-appkey: YOUR_APP_KEY" \
-H "x-appsecret: YOUR_APP_SECRET" \
"https://openapi.rogo.com.vn/api/v1/authen/phone/config"
{
"enabled": true,
"passwordless": false,
"channels": ["sms"],
"canChooseChannel": false,
"fallback": false,
"codeLength": 6,
"codeTtlSec": 300,
"cooldownSec": 30
}
field what to do with it
enabled false means this project does not offer phone login at all — hide it; every other call returns 400
passwordless false → password flow (examples 1–6). true → passwordless flow; show no password field anywhere
channels the channels this project sends codes on, in the project’s order. ["zalo","sms"] means Zalo is tried first
canChooseChannel true → show a “send my code by…” picker listing channels, and send the pick as channel. false → no picker, and don’t send channel
fallback true → a code that fails on one channel goes out on the next. Use it to set expectations, e.g. “if Zalo doesn’t arrive, we’ll send an SMS”
codeLength how many digit boxes to draw on the code screen
codeTtlSec how long the code is valid, if you show an expiry
cooldownSec how long to keep “resend” disabled after a code is sent

Treat an empty channels as “we cannot send a code right now”: show a message and tell us, rather than letting the user sign up into a code screen that will never fill.

These three numbers are set per project and can change, so draw from them rather than hardcoding 6 boxes or a 30-second timer.

This is cheap to call and safe to cache for the app session. Re-read it on a cold start, not per screen.

Creates the account and sends a code.

Terminal window
curl -X POST \
-H "x-appkey: YOUR_APP_KEY" \
-H "x-appsecret: YOUR_APP_SECRET" \
-H "Content-Type: application/json" \
--data-raw '{"phone":"+84975907414","password":"YourPassword1"}' \
"https://openapi.rogo.com.vn/api/v1/authen/phone/signup"
{ "success": true }

Errors specific to signup (all HTTP 400, plus the common + rate-limit errors):

errorCode message Meaning
2111 Phone number is already registered already a verified account, send them to login
2124 OTP login is not configured for this project. Set a provider in the dashboard. this project has no code-sending channel set up (a setup issue on our side), contact us

The code the user received. This is what activates the account.

Terminal window
curl -X POST \
-H "x-appkey: YOUR_APP_KEY" \
-H "x-appsecret: YOUR_APP_SECRET" \
-H "Content-Type: application/json" \
--data-raw '{"phone":"+84975907414","code":"482913"}' \
"https://openapi.rogo.com.vn/api/v1/authen/phone/verify"
{ "success": true }

Errors specific to verify (all HTTP 400):

errorCode message Meaning
2110 Account not found no account for that number
2120 Invalid code wrong code, let them retry
2121 Code has expired or was not requested code expired, already used, or the wrong tries this project allows used it up, offer resend

If the code did not arrive. Wait cooldownSec (from config) after the previous one.

Terminal window
curl -X POST \
-H "x-appkey: YOUR_APP_KEY" \
-H "x-appsecret: YOUR_APP_SECRET" \
-H "Content-Type: application/json" \
--data-raw '{"phone":"+84975907414"}' \
"https://openapi.rogo.com.vn/api/v1/authen/phone/resend"
{ "success": true }

Errors specific to resend (all HTTP 400):

errorCode message Meaning
2110 Account not found no account for that number
2113 Phone number is already verified already verified — nothing to resend, send them to login
2124 OTP login is not configured for this project. Set a provider in the dashboard. this project has no code-sending channel set up (a setup issue on our side), contact us

Otherwise only the common and rate-limit errors apply.

Only works after verify.

Terminal window
curl -X POST \
-H "x-appkey: YOUR_APP_KEY" \
-H "x-appsecret: YOUR_APP_SECRET" \
-H "Content-Type: application/json" \
--data-raw '{"phone":"+84975907414","password":"YourPassword1"}' \
"https://openapi.rogo.com.vn/api/v1/authen/phone/login"
{
"access_token": "eyJhbGciOi...",
"token_type": "Bearer",
"refresh_token": "AMf-vBxXuo...",
"expires_in": 3600
}

Send access_token as Authorization: Bearer <token> on other APIs. It lasts 1 hour; use refresh_token to get a new one through the normal Firebase refresh flow.

Errors specific to login (all HTTP 400):

errorCode message Meaning
2112 Phone number has not been verified account exists but never verified, send them to the code screen
2102 Invalid phone number or password wrong password, or no such account (kept the same on purpose so it can’t reveal which numbers exist)

Sends a code to a registered number.

Terminal window
curl -X POST \
-H "x-appkey: YOUR_APP_KEY" \
-H "x-appsecret: YOUR_APP_SECRET" \
-H "Content-Type: application/json" \
--data-raw '{"phone":"+84975907414"}' \
"https://openapi.rogo.com.vn/api/v1/authen/phone/forgot-password"
{ "success": true }

Errors specific to forgot-password: none. It always returns {"success":true}, even for a number with no account. This is deliberate, so it can’t be used to discover which numbers are registered. Only the common and rate-limit errors apply.

With the code from step 5. The old password stops working immediately.

Terminal window
curl -X POST \
-H "x-appkey: YOUR_APP_KEY" \
-H "x-appsecret: YOUR_APP_SECRET" \
-H "Content-Type: application/json" \
--data-raw '{"phone":"+84975907414","code":"482913","newPassword":"NewPassword1"}' \
"https://openapi.rogo.com.vn/api/v1/authen/phone/reset-password"
{ "success": true }

Errors specific to reset-password (all HTTP 400):

errorCode message Meaning
2120 Invalid code wrong code
2121 Code has expired or was not requested code expired or already used, send them back to forgot-password
null Invalid request no account for that number (kept vague on purpose, so no distinguishing code either)

New user: signup → user types the code → verify → login. Login fails with “Phone number has not been verified” until verify succeeds.

Forgot password: forgot-password → user types the code → reset-password → login.

Both are for password projects. If config said passwordless: true, read on.

When config returns passwordless: true, there is no password anywhere: possession of the code is the credential. Everything is two calls.

request-code → user types the code → verify → you have a token

The same two calls register a new user and sign in an existing one. There is no separate “sign up”. Ask for the phone number, send the code, done — your UI needs one screen, not two, and no “do you have an account?” question. (We also cannot tell you whether the number was already registered; the response is identical either way, on purpose, so the endpoint can’t be used to discover who has an account.)

Terminal window
curl -X POST \
-H "x-appkey: YOUR_APP_KEY" \
-H "x-appsecret: YOUR_APP_SECRET" \
-H "Content-Type: application/json" \
--data-raw '{"phone":"+84975907414","channel":"zalo"}' \
"https://openapi.rogo.com.vn/api/v1/authen/phone/request-code"
{ "success": true }
field
phone required, E.164 as always
channel optional. Only when config.canChooseChannel is true: the channel the user picked, one of config.channels. Omit it to follow the project’s order. Where the project offers no choice, a channel you send is ignored.
username optional display name, applied only if this call creates the account. Ignored for a returning user.

To resend, call request-code again — not resend. The same cooldown (cooldownSec) applies, and the user may pick a different channel the second time when canChooseChannel is true — a good thing to offer if the first never arrived.

Errors specific to request-code (all HTTP 400, plus the common + rate-limit errors):

errorCode message Meaning
400 This project signs in with a password. Use signup to register and login to sign in. you called this on a password project — re-read config
2124 This project cannot send a code by zalo. Available: sms you sent a channel this project does not offer, on a project that lets users pick — use one from config.channels
2124 OTP login is not configured for this project. Set a provider in the dashboard. no channel is configured at all (a setup issue on our side), contact us
400 Phone authentication is not enabled for this project phone login is switched off for this project

8. Verify — and this is also the sign-in

Section titled “8. Verify — and this is also the sign-in”

Same endpoint and same body as example 2. On a passwordless project it additionally returns the credential:

{
"success": true,
"access_token": "eyJhbGciOi...",
"token_type": "Bearer",
"refresh_token": "AMf-vBxXuo...",
"expires_in": 3600,
"customToken": "eyJhbGciOi..."
}

Use access_token. It is identical in shape and meaning to what login returns in example 4, so if your app already handles that response you are done — the token goes out as Authorization: Bearer <token>, lasts 1 hour, and refresh_token renews it the same way.

customToken is there for apps that would rather hand it to Firebase’s signInWithCustomToken and let the Firebase SDK own session refresh. Both represent the same session; take one.

Treat access_token as optional. In rare cases we can mint the credential but not exchange it, and then only customToken comes back. So:

const r = await verify(phone, code)
const token = r.access_token ?? (await signInWithCustomToken(r.customToken))

If neither is present, the call failed and you will have an error body instead.

What is rejected on a passwordless project

Section titled “What is rejected on a passwordless project”
Call errorCode Why
login 400 there is no password to check
forgot-password 400 there is no password to reset
reset-password 400 same
signup works, but don’t request-code is the entry point; signup refuses a number that is already registered, and here that is the normal case

Codes are single use. The other limits are set per project by the partner, within bounds we enforce; the defaults are what a project gets until it changes them.

Limit Default In config?
Digits in a code 6 codeLength
How long a code is valid 5 minutes codeTtlSec
Wait before another code for the same number 30 seconds cooldownSec
Codes per number per hour 5 no
Wrong attempts before the code is cancelled 5 no

Draw the code screen from config. The limits that are not in it are enforced server-side, and you only meet them as errors: 2123 when a cap is reached, and 2121 once too many wrong attempts cancel the code (ask the user to request a new one).

The limits are per phone number, not per channel. Asking for a code by Zalo and then immediately by SMS is two requests against the same cooldown and the same hourly cap. Switching channel is a fine thing to offer after a failed delivery, but it does not reset the clock, so keep the countdown running across the switch.

Every error is JSON with the same five fields:

{
"message": "Invalid code",
"errorCode": 2120,
"error": "Bad Request",
"path": "/api/v1/authen/phone/verify",
"timestamp": "2026-07-24T08:07:05.205Z"
}
field notes
message text to show the user, or an array of strings when the request body fails validation (see below)
errorCode a stable number identifying the error, on every error. Prefer matching on this; it never changes even if we reword message. An error with no code of its own has its HTTP status’s (400, 401, 403, 404, 409, 429, or 600 for our faults), so body validation is 400. Full list: errors.md.
error short error name; it varies (Bad Request, BadRequestException, HttpException, Forbidden), so don’t rely on it
path the endpoint that failed
timestamp ISO-8601

Reading the code without parsing JSON. On every error response we also send the same number in an X-Error-Code response header (e.g. X-Error-Code: 2120). A constrained device can read that one header and skip parsing the body entirely. It is on every error response and on no success response. The body carries the same errorCode; the two always match.

The errors below come from any of the six endpoints. Errors specific to one endpoint are listed under that endpoint in Examples.

HTTP errorCode message Meaning
403 2100 Forbidden resource x-appkey / x-appsecret header missing
401 2101 Request from unauthorized SDK source app key or secret wrong
400 400 ["password must be longer than or equal to 6 characters"] (array) a body field failed validation. Checked before anything else, and the only case where message is an array. Show the first item.
400 2103 Phone number must include the country code, e.g. +84975907414 phone not in +84… form
400 2103 Wrong length for a Vietnam number: expected 9 digits after +84, got 10 usually +84 prefixed onto a local 0… without dropping the 0
400 400 Phone authentication is not enabled for this project phone login is switched off for this project — config tells you before you get here
400 400 varies you used the wrong flow for this project: a password call on a passwordless project, or request-code on a password one. Nothing is wrong with what you sent — re-read config and use the other flow.

Rate limits (signup, request-code, resend, forgot-password: the code-sending calls)

Section titled “Rate limits (signup, request-code, resend, forgot-password: the code-sending calls)”
HTTP errorCode message What to do
429 2122 Please wait 17s before requesting another code the number is the seconds still left, not the configured cooldown: disable resend and count down from it
429 2123 Too many OTP requests. Please try again later. a quota ran out: this number’s hourly or daily cap, the project’s daily cap, or too many requests from one network in a short time. Ask the user to try later.

Both carry retryAfterSec in the body — the seconds until the request would be accepted:

{ "message": "Please wait 17s before requesting another code", "code": 2122, "retryAfterSec": 17 }

Count down from that field rather than from a timer the app starts itself: a user who force-quits and reopens the app gets the real remaining wait instead of a fresh 60 seconds. On 2123 the value can be up to a day, so show it as a time to come back rather than a live countdown. Which quota ran out is deliberately not said.

These are our side, not the caller’s. Show a generic “please try again” and, if they persist, tell us.

HTTP errorCode message What to do
503 2125 OTP service temporarily unavailable our OTP store is momentarily unreachable — retry after a short wait
400 400 Could not create the account / Could not update the account / Could not reset the password an internal step failed unexpectedly; safe to retry, report it if it keeps happening

forgot-password always returns success, even for a number that was never registered. This is deliberate so nobody can use it to find out which numbers have accounts. Never treat the response as proof that the number exists.

Signing up again before verifying replaces the password. If someone signs up, never enters the code, then signs up again with a different password, the second password is the one that counts. Use this for a “start over” button. Once the number is verified, signup returns “Phone number is already registered” and the password can only be changed through forgot-password.

{"success":true} means we accepted the request, not that the code was sent or delivered. The code goes out in the background. If the project’s provider is unreachable or rejects the message, signup / request-code / resend / forgot-password still return {"success":true}. There is no error for a send failure, by design. So never treat success as proof the message went out. Show a “code sent” screen, let the user retry after the cooldown (cooldownSec), and if codes never arrive at all, that is a setup or provider problem, so check the project’s code delivery rather than retrying.

We do check the things we can check before accepting: a project with no configured channel, or a channel this project does not offer, is rejected up front with 2124 rather than being accepted into a send that could never happen.

A code can arrive later, and on a different channel than the one first tried. When config.fallback is true and the first channel’s gateway refuses the message, the same code goes out on the next channel. That happens after request-code has already answered, so allow for an SMS turning up some seconds after a Zalo attempt failed. The code is the same, so either message works. Fallback only sees failures the gateway reports while we send; a message a gateway accepted and then could not deliver is not retried elsewhere.