Emails and OTP > OTP Settings & Testing
Emails and OTP > OTP Settings & TestingKroxt BaaS SDK v1.0.5

OTP Settings & Testing

Deliver secure verification One-Time Password tokens. OTP configurations allow custom length bounds (e.g. 6-digit codes) and expirations (e.g. 5 minutes).

Send OTP:
otp.ts
1
2
3
4
await baas.communication.sendOtp({
  email: "user@example.com",
  purpose: "signup",
});
Verify OTP:
otp.ts
1
2
3
4
5
6
7
8
const res = await baas.communication.verifyOtp({
  email: "user@example.com",
  purpose: "signup",
  code: "123456",
});
if (res.success) {
  console.log("OTP code verified successfully!");
}

TypeScript Type Integration

Verification resolves to a structured payload confirming status details:

types.ts
1
2
3
4
5
6
7
8
9
const verifyRes = await baas.communication.verifyOtp({
  email: "user@example.com",
  purpose: "signup",
  code: "123456",
});

if (verifyRes.success) {
  console.log("Verified successfully:", verifyRes.message);
}