コンテンツにスキップ

Self-serve dashboard

顧客 self-serve ダッシュボード: https://jpcite.com/dashboard.html。 API key を使って、利用量、請求、上限設定、通知設定を確認できます。

Endpoint 用途
GET /v1/me/dashboard 30 日 usage summary (calls, ¥ 額, peak day, cap state)
GET /v1/me/usage_by_tool tool 別 top 10 (call 数 / ¥ 額)
GET /v1/me/billing_history Stripe invoice list (5 分 cache)
GET /v1/me/tool_recommendation?intent=<query> intent → 候補 tool ランキング

認証

すべて API key 必須:

X-API-Key: jc_…

匿名は 401 dashboard requires an authenticated API key/v1/programs/search 等の data 経路は引き続き匿名 3 req/日 で動く (pricing.md)。

Dashboard summary

curl -s "https://jpcite.com/v1/me/dashboard?days=30" \
  -H "X-API-Key: $JPCITE_API_KEY" | jq
{
  "tier": "paid",
  "days": 30,
  "series": [{"date": "2026-03-26", "calls": 0}, ...],
  "today_calls": 24,
  "last_7_calls": 142,
  "last_30_calls": 612,
  "last_30_amount_yen": 1836,
  "peak_day": {"date": "2026-04-12", "calls": 52},
  "monthly_cap_yen": 10000,
  "month_to_date_calls": 612,
  "month_to_date_amount_yen": 1836,
  "cap_remaining_yen": 8164,
  "unit_price_yen": 3
}
  • series は zero-calls 日も埋めて 30 日 chart を gap-fill 不要に
  • last_30_amount_yen = last_30_calls * 3 (税別)
  • cap_remaining_yen は cap 未設定時 null
  • month_to_date_calls は metered + success のみ (cap 判定と同じ集計)

Tool 別

curl -s "https://jpcite.com/v1/me/usage_by_tool?days=30&limit=10" \
  -H "X-API-Key: $JPCITE_API_KEY"

amount_yen は metered + success サブセット (4xx/5xx は課金しない)。avg_latency_ms は今後 surface 予定 (null を返す)。

請求履歴

curl -s "https://jpcite.com/v1/me/billing_history" \
  -H "X-API-Key: $JPCITE_API_KEY"

Stripe invoice 直近 24 件、5 分 in-process cache。Stripe 未設定環境では {"invoices": [], "customer_id": "cus_…"}。CSV / JSON download も UI 側にあり。

Tool 推奨

curl -s "https://jpcite.com/v1/me/tool_recommendation?intent=設備投資の補助金&limit=5" \
  -H "X-API-Key: $JPCITE_API_KEY"
{
  "intent": "設備投資の補助金",
  "tools": [
    {
      "endpoint": "/v1/programs/search",
      "name": "programs.search",
      "why": "補助金 / 助成金 / 給付金 / 認定制度の網羅検索 (一致: 補助)",
      "confidence": 0.6
    }
  ],
  "fallback_used": false
}

純 keyword スコア、LLM 呼出なし、deterministic。keyword 一致がなければ fallback_used: true で catalog tail を confidence 0.2 で返す。

Cap 管理

# ¥10,000 月次 cap 設定
curl -X POST "https://jpcite.com/v1/me/cap" \
  -H "X-API-Key: $JPCITE_API_KEY" -H "Content-Type: application/json" \
  -d '{"monthly_cap_yen": 10000}'

# Cap 解除
curl -X POST "https://jpcite.com/v1/me/cap" \
  -H "X-API-Key: $JPCITE_API_KEY" -H "Content-Type: application/json" \
  -d '{"monthly_cap_yen": null}'

Month-to-date metered spend が cap に達すると以降の data 経路は 503 (cap_reached: true) を返し、当月の請求期間が切り替わるか cap を上げる/解除するまで停止。

制度改正アラート

ダッシュボードは /v1/me/alerts/* のラッパー UI (#dash2-alerts) を持つ。仕様詳細は alerts_guide.md、ここは UI 側挙動のみ。

Endpoint UI 操作
GET /v1/me/alerts/subscriptions 初期化時に呼び subscription 一覧を描画
POST /v1/me/alerts/subscribe フォーム submit、結果 banner
DELETE /v1/me/alerts/subscriptions/{id} 行削除 (window.confirm 経由で deactivate)

フォーム

  • filter_type: tool / law_id / program_id / industry_jsic / all (free-text 禁止)
  • filter_value: filter_type='all' 以外で必須。law_345AC0000000050 のような 1 次キー
  • min_severity: critical / important / info (default important)
  • webhook_url: optional、HTTPS のみ。client 側 pre-validate:
  • https:// で始まる、2048 文字以内
  • ローカルネットワーク向けの IP literal は登録不可
  • 配信時にも安全な宛先か再確認
  • email: optional。webhook_url または email のどちらか必須

削除

削除 は確認ダイアログ後に DELETE を送ります。削除後に再開する場合は新規登録してください。404 は UI 側で「既に削除されています」と表示します。

#dash2-alerts-banner (role="status"aria-live="polite")。成功は 4 秒後自動消滅、失敗は次操作まで残る (純 vanilla JS、CSP 準拠)。