Rawi

مرجع 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_suggestions per (brand, run, question, engine, locale): the first call returns 201, a repeat returns the stored row with 200 and cached: 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*pathintegera question in gaps of GET /reports/gaps (Postman {{questionId}})
run_idqueryintegersame as R2; default run when absent (free: only the default run)
enginequerystringchatgpt | gemini | claude; absent/all = the first engine where this question is a gap

پاسخ‌ها

201 — AiSuggestionResponse

فیلدنوعتوضیح
suggestionobject
suggestion.idintegerUnique ID.
suggestion.question_idintegerID of the question.
suggestion.run_idintegerID of the scan.
suggestion.enginestringAI assistant key, e.g. chatgpt, gemini or claude.
suggestion.localestringLanguage: fa or en.
suggestion.summarystring
suggestion.stepsobject[]
suggestion.steps[].titlestring
suggestion.steps[].detailstring
suggestion.steps[].source_domainstring
suggestion.sources_to_targetstring[]
suggestion.generated_bystring
suggestion.created_atstringWhen it was created (ISO 8601).
cachedboolean
usageobject
usage.usedinteger
usage.limitinteger
usage.remaininginteger
usage.resets_atstring
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
codestring
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

فیلدنوع
messagestring
requires_confirmation*boolean
reasonstring
questions_countinteger
changesobject[]
changes[].fieldstring
changes[].fromany
changes[].toany
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_inintegerSeconds 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"

امتحان در کنسول