OTP

פתח ב-Claudeפתח ב-ChatGPT.md

אימות קוד

http
POST https://smsprovider-web.vercel.app/api/v1/otp/verify

בודק את הקוד שהמשתמש הקליד. כל קריאה נספרת כניסיון; אחרי max_tries ניסיונות שגויים הקוד נפסל.

אימות: Authorization: Bearer bm_live_… · Scope נדרש: otp

גוף הבקשה

שדהסוגחובההערות
tostringכןlen 5–20
codestringכןpattern ^\d{4,10}$
app_idstringלאpattern ^[A-Za-z0-9_-]{1,32}$

תשובה

200 — OtpVerifyResult

json
{
  "verified": true,
  "tries_left": 2,
  "session_id": "c3a1b2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
}

שגיאות

סטטוסקוד
400validation_error
404not_found
401unauthorized
403insufficient_scope
429rate_limited
500internal_error

דוגמאות

curl

bash
curl -X POST "https://smsprovider-web.vercel.app/api/v1/otp/verify" \
  -H "Authorization: Bearer $BATLER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"0501234567","code":"482913","app_id":"login"}'

Node.js

ts
import { BatlerSMS } from "@batler/sms";

const sms = new BatlerSMS({ apiKey: process.env.BATLER_API_KEY! });
const body = {
  "to": "0501234567",
  "code": "482913",
  "app_id": "login"
};
const result = await sms.otp.verify(body);

PHP

php
<?php
$ch = curl_init("https://smsprovider-web.vercel.app/api/v1/otp/verify");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("BATLER_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode(["to" => "0501234567", "code" => "482913", "app_id" => "login"], JSON_UNESCAPED_UNICODE),
]);
$result = json_decode(curl_exec($ch), true);

Python

python
import os, uuid, requests

resp = requests.request(
    "POST", "https://smsprovider-web.vercel.app/api/v1/otp/verify",
    headers={"Authorization": f"Bearer {os.environ['BATLER_API_KEY']}"},
    json={"to": "0501234567", "code": "482913", "app_id": "login"},
    timeout=30,
)
resp.raise_for_status()
result = resp.json()

C#

csharp
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new("Bearer", Environment.GetEnvironmentVariable("BATLER_API_KEY"));
var req = new HttpRequestMessage(HttpMethod.Post, "https://smsprovider-web.vercel.app/api/v1/otp/verify");
req.Content = new StringContent("{\"to\":\"0501234567\",\"code\":\"482913\",\"app_id\":\"login\"}", System.Text.Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
☰