Quickstart
Premier OTP en moins de 5 minutes.
1
Crée ton app
Crée un compte, puis une app. Tu obtiens immédiatement ta paire de clés :
API Key
jak_live_...Publique, dans les headers
App Secret
sk_live_...Privée, pour signer les requêtes
Le appSecret n'est affiché qu'une seule fois. Stocke-le immédiatement.
2
Envoie un OTP
Remplace APP_KEY et APP_SECRET par tes clés :
terminal
# Envoyer un OTP
APP_KEY="jak_live_..."
APP_SECRET="sk_live_..."
PHONE="+22375673336"
TS=$(date+%s)
BODY='{"phone":"'$PHONE'"}'
SIG=$(node-e"const c=require('crypto');const s=c.createHmac('sha256','$APP_SECRET').update('POST/v1/otp/send'+'$TS'+'$BODY').digest('hex');console.log(s)")
curl-XPOSThttps://api.otp.julakai.com/v1/otp/send\
-H"Content-Type: application/json"\
-H"X-Julak-Key: $APP_KEY"\
-H"X-Julak-Timestamp: $TS"\
-H"X-Julak-Signature: $SIG"\
-d"$BODY"response.json
{
"requestId": "otp_...",
"expiresInSeconds": 300
}3
Vérifie le code
L'utilisateur saisit le code reçu par SMS :
terminal
# Vérifier le code
TS=$(date+%s)
BODY='{"phone":"+22375673336","code":"1234"}'
SIG=$(node-e"const c=require('crypto');const s=c.createHmac('sha256','$APP_SECRET').update('POST/v1/otp/verify'+'$TS'+'$BODY').digest('hex');console.log(s)")
curl-XPOSThttps://api.otp.julakai.com/v1/otp/verify\
-H"Content-Type: application/json"\
-H"X-Julak-Key: $APP_KEY"\
-H"X-Julak-Timestamp: $TS"\
-H"X-Julak-Signature: $SIG"\
-d"$BODY"response.json
{
"verified": true,
"verificationToken": "eyJhbG..."
}JavaScript & Dart
Même logique, en Node.js ou Flutter :
const crypto = require("crypto");
const APP_KEY = "jak_live_...";
const APP_SECRET = "sk_live_...";
const API_URL = "https://api.otp.julakai.com";
async function sendOtp(phone) {
const ts = Math.floor(Date.now() / 1000).toString();
const body = JSON.stringify({ phone });
const sig = crypto.createHmac("sha256", APP_SECRET)
.update("POST/v1/otp/send" + ts + body).digest("hex");
const res = await fetch(API_URL + "/v1/otp/send", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Julak-Key": APP_KEY,
"X-Julak-Timestamp": ts,
"X-Julak-Signature": sig,
},
body,
});
return res.json();
}
async function verifyOtp(phone, code) {
const ts = Math.floor(Date.now() / 1000).toString();
const body = JSON.stringify({ phone, code });
const sig = crypto.createHmac("sha256", APP_SECRET)
.update("POST/v1/otp/verify" + ts + body).digest("hex");
const res = await fetch(API_URL + "/v1/otp/verify", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Julak-Key": APP_KEY,
"X-Julak-Timestamp": ts,
"X-Julak-Signature": sig,
},
body,
});
return res.json();
}C'est terminé
Ton application peut maintenant envoyer et vérifier des codes OTP. Voir la référence API →