مرجع API · Auth & profile
Request login code
post
/auth/request-code| احراز هویت | بدون احراز هویت (عمومی) |
|---|---|
| سطح دسترسی | مهمان · کاربر رایگان · کاربر حرفهای · مشاور · مدیر کل Public — no token |
| محدودیت نرخ | 30/1min |
Sends the 6-digit login code. With email: by email. With phone (and no email): by SMS (otp type) or, with channel: "voice", by a voice call. Remembers locale and ref for the verify step (30 min). Fires signup_started for new accounts.
بدنه درخواست
| فیلد | نوع | توضیح |
|---|---|---|
email* | string<email> | valid email, max 190; normalized to lower case |
locale | string | null ("fa", "en", null) | fa | en (panel language for a new account; default = Accept-Language) |
ref | string | null | referral code of the inviter (S6 link ?ref=), max 32 |
نمونهjson
{
"email": "{{userEmail}}",
"locale": "{{lang}}",
"ref": null
}
پاسخها
200 — RequestCodeResponse
Phone response: {"sent":true,"expires_in":600,"resend_in":45,"existing_account":true,"channel":"sms","phone":"+989120000077","voice_available":false,"dev_code":"495814"}. dev_code is present only when RAWI_DEV_EXPOSE_OTP=true and the app is not in production.
json
{
"sent": true,
"expires_in": 600,
"resend_in": 45,
"existing_account": true,
"channel": "email",
"dev_code": "901976"
}
422 — email invalid; phone invalid number or phone login switched off; channel voice not available («دریافت کد با تماس صوتی فعلاً ممکن نیست.»)
| فیلد | نوع |
|---|---|
message* | string |
errors* | object |
json
{
"message": "",
"errors": {
"email": [
"ایمیل معتبر نیست."
]
}
}
429 — Resend cooldown (45 s) or more than 5 codes/min for this address: {"message":"…","resend_in":32}; or route throttle 30 req/min/IP (Too Many Attempts.)
| فیلد | نوع | توضیح |
|---|---|---|
message* | string | |
resend_in | integer | Seconds until a new login code may be requested (login-code cooldown only). |
json
{
"message": "Too Many Attempts.",
"resend_in": 0
}
503 — IPPanel rejected the SMS/voice send: errors.phone «فرستادن پیامک ممکن نشد…»; the code is retired so the user can ask again at once
| فیلد | نوع |
|---|---|
message* | string |
json
{
"message": ""
}
نمونهٔ curl
bash
curl -X POST 'http://127.0.0.1:8010/api/auth/request-code' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"email": "{{userEmail}}",
"locale": "{{lang}}",
"ref": null
}'