Skip to content

Verify ​

Verify sends one-time codes by SMS or email and checks what the person types. MsGine generates the code, sends it, expires it and limits the attempts, so your app never stores a code.

Send a code and check it ​

ts
const verification = await msgine.verify.start({ to: '+256701234567', channel: 'sms', appName: 'Acme' });

const result = await msgine.verify.check(verification.id, codeTheUserTyped);
if (result.valid) signIn();
python
verification = msgine.verify.start(to="+256701234567", channel="sms", app_name="Acme")

result = msgine.verify.check(verification["id"], code_the_user_typed)
if result["valid"]:
    sign_in()
go
verification, err := client.Verify.Start(ctx, msgine.StartVerificationParams{
	To:      "+256701234567",
	Channel: "sms",
	AppName: "Acme",
})

result, err := client.Verify.Check(ctx, verification.ID, codeTheUserTyped)
if err == nil && result.Valid {
	signIn()
}

The person receives: 482913 is your Acme verification code. It expires in 10 minutes. Do not share it.

If your app does not keep the verification id, check by recipient instead: verify.checkRecipient(to, code) (Python check_recipient, Go CheckRecipient) checks the latest verification for that number or address.

Options ​

OptionDefault
channelrequiredsms or email
appNamerequiredYour app's name in the message, up to 30 characters
codeLength64 to 8 digits
expiresIn600Seconds the code is valid, 60 to 1800
fromMsGineSMS: your approved sender ID. Email: an address on your verified domain
androidAppHashnoneYour app's SMS Retriever hash, so Android apps read the code automatically

Rules ​

  • Five attempts. A wrong code returns valid: false and attemptsLeft. After the fifth wrong code the verification is failed.
  • One code at a time. Starting again for a number that has a pending verification sends the same code again instead of a new one. resend does the same; each verification can be sent three times, at least 30 seconds apart.
  • Accepted once. After approval, checking again returns verification_closed.
  • Limits against abuse. At most 5 codes per number every 10 minutes, and SMS codes go to Ugandan numbers. A request over a limit returns verify_rate_limited with a Retry-After header.
  • The code stays private. It never appears in API responses, webhooks or your message history, where it is shown as ******.

Statuses ​

StatusMeaning
pendingSent, waiting for the right code
approvedThe right code was entered
failedFive wrong codes
expiredThe time ran out
canceledYou cancelled it with verify.cancel

Subscribe a webhook to verification.approved or verification.failed to react on your server.

Price ​

Each code sent is charged at its channel's price (SMS UGX 30, email from your bundle), plus UGX 20 when a code is approved. Above 100,000 approved verifications in a month the fee is UGX 10. A typical SMS verification costs UGX 50.

Testing ​

Sandbox keys send nothing and charge nothing, and accept a code of zeros (000000 for six digits), so you can test your sign-in flow end to end.

Released under the MIT License.