مرجع API · Scans & reports
AI suggestion for a missed question
post
/reports/gaps/{questionId}/suggestion| احراز هویت | توکن مشتری (Bearer) |
|---|---|
| سطح دسترسی | کاربر رایگان · کاربر حرفهای Customer token (Bearer) — free and paid users |
| محدودیت نرخ | 20/1min |
Advice for one gap (question × engine × run) in the panel language (Accept-Language fa|en): a summary, 3–5 numbered steps and the cited sources to get into. Built from the gap answer text, the brands it named, the sources it cited with their types, and the brand / product / target-customer context, through the advisor task route (same connection as answer_analyzer; mock connection = deterministic suggestion from the data). See docs/AI-JARVIS.md §5.
- Cached in
ai_suggestionsper (brand, run, question, engine, locale): the first call returns 201, a repeat returns the stored row with 200 andcached: true(not counted). - Limit before any paid call: plan
ai_suggestions_per_month(free 3, paid 30) new suggestions per calendar month; failed attempts do not count. - Model output is untrusted: the server parses JSON robustly, strips HTML, bounds every string and keeps only valid domains. Clients must render it as text.
- One Idempotency-Key per request is sent to Jarvis and stored on the row.
پارامترها
| نام | محل | نوع | توضیح |
|---|---|---|---|
questionId* | path | integer | a question in gaps of GET /reports/gaps (Postman {{questionId}}) |
run_id | query | integer | same as R2; default run when absent (free: only the default run) |
engine | query | string | chatgpt | gemini | claude; absent/all = the first engine where this question is a gap |
پاسخها
201 — AiSuggestionResponse
| فیلد | نوع | توضیح |
|---|---|---|
suggestion | object | |
suggestion.id | integer | Unique ID. |
suggestion.question_id | integer | ID of the question. |
suggestion.run_id | integer | ID of the scan. |
suggestion.engine | string | AI assistant key, e.g. chatgpt, gemini or claude. |
suggestion.locale | string | Language: fa or en. |
suggestion.summary | string | |
suggestion.steps | object[] | |
suggestion.steps[].title | string | |
suggestion.steps[].detail | string | |
suggestion.steps[].source_domain | string | |
suggestion.sources_to_target | string[] | |
suggestion.generated_by | string | |
suggestion.created_at | string | When it was created (ISO 8601). |
cached | boolean | |
usage | object | |
usage.used | integer | |
usage.limit | integer | |
usage.remaining | integer | |
usage.resets_at | string |
json
{
"suggestion": {
"id": 1,
"question_id": 350,
"run_id": 38,
"engine": "chatgpt",
"locale": "fa",
"summary": "ChatGPT در پاسخ به این پرسش از نیکحساب، ترازنو و دفتریار نام برد و از آوند نه. منبعهایی که نقل کرد: hesab-review.example، nikhesab.example و fanavari-news.example. …",
"steps": [
{
"title": "در hesab-review.example دیده شوید",
"detail": "ChatGPT برای این پرسش از hesab-review.example (سایت نقد و مقایسه) نقل کرد. …",
"source_domain": "hesab-review.example"
},
{
"title": "صفحهای که مستقیم به این پرسش جواب بدهد",
"detail": "در avand.example صفحهای با عنوانی نزدیک به «…» بسازید …",
"source_domain": "avand.example"
},
{
"title": "نظر مشتریان را در سایتهای نقد جمع کنید",
"detail": "از مشتریان راضی بخواهید …",
"source_domain": null
}
],
"sources_to_target": [
"hesab-review.example",
"fanavari-news.example"
],
"generated_by": "mock",
"created_at": "2026-11-25T11:16:30+00:00"
},
"cached": false,
"usage": {
"used": 1,
"limit": 3,
"remaining": 2,
"resets_at": "2026-12-21T20:30:00Z"
}
}
401 — Missing/invalid token: {"message":"…","code":"unauthenticated"} (message in the request language)
| فیلد | نوع |
|---|---|
message* | string |
code | string |
json
{
"message": "Please sign in to continue; your session has ended or is not valid.",
"code": "unauthenticated"
}
403 — {"code":"plan_limit","remaining":0,"used":3,"limit":3,"resets_at":"…","plan":"free","paid_limit":30,"message":"…"} monthly allowance used up (resets_at = first day of the next Persian month, Asia/Tehran; the UI shows the upgrade link only when plan is free); also plan_limit for an older run / locked engine (as on R2)
| فیلد | نوع |
|---|---|
message* | string |
code* | string ("plan_limit", "forbidden") |
json
{
"message": "این امکان در طرح راوی حرفهای است.",
"code": "plan_limit"
}
404 — {"code":"not_a_gap"} the question is not a gap in this run and engine; no brand / unknown run
| فیلد | نوع |
|---|---|
message* | string |
json
{
"message": ""
}
409 — {"code":"in_progress"} the same suggestion is being made right now
| فیلد | نوع |
|---|---|
message | string |
requires_confirmation* | boolean |
reason | string |
questions_count | integer |
changes | object[] |
changes[].field | string |
changes[].from | any |
changes[].to | any |
json
{
"message": "",
"requires_confirmation": true,
"reason": "",
"questions_count": 0,
"changes": [
{
"field": "",
"from": null,
"to": null
}
]
}
422 — invalid run_id / engine
| فیلد | نوع |
|---|---|
message* | string |
errors* | object |
json
{
"message": "",
"errors": {
"email": [
"ایمیل معتبر نیست."
]
}
}
429 — more than 20 requests a minute
| فیلد | نوع | توضیح |
|---|---|---|
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
}
502 — {"code":"ai_unavailable","message":"سرویس هوش مصنوعی الان در دسترس نیست…"} the AI call failed or returned unusable output (not counted)
| فیلد | نوع |
|---|---|
message* | string |
json
{
"message": ""
}
نمونهٔ curl
bash
curl -X POST 'http://127.0.0.1:8010/api/reports/gaps/{questionId}/suggestion' \
-H 'Accept: application/json' \
-H "Authorization: Bearer $RAWI_USER_TOKEN"