chatweb.ai API Documentation

REST API for AI chat, sessions, billing, and integrations.

Base URL

https://api.chatweb.ai

All API endpoints use the prefix /api/v1/. Requests and responses are JSON unless otherwise noted.

curl https://api.chatweb.ai/api/v1/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello!", "session_id": "webchat:abc123"}'

Authentication

Most endpoints use a session ID passed via the x-session-id header or in the request body. Authenticated endpoints (conversations, billing) require a Bearer token in the Authorization header.

# Session-based (most endpoints)
curl -H "x-session-id: webchat:abc123" https://api.chatweb.ai/api/v1/usage

# Token-based (authenticated endpoints)
curl -H "Authorization: Bearer YOUR_TOKEN" https://api.chatweb.ai/api/v1/conversations

Errors

Errors return a JSON object with an error field.

// 400 Bad Request
{"error": "Invalid email format"}

// 401 Unauthorized
{"error": "Invalid email or password"}

// 404 Not Found
{"error": "Session not found"}

// 429 Too Many Requests
{"error": "Rate limit exceeded"}

// 500 Internal Server Error
{"error": "DynamoDB not configured"}

Auth

POST/api/v1/auth/email

メールアドレスでログイン・自動登録(パスワード不要)

Request Body

email*stringEmail address
session_id?string紐付けるセッションID
// Request
POST /api/v1/auth/email
{"email": "user@example.com", "session_id": "webchat:abc123"}

// Response 200
{"ok": true, "token": "uuid-token", "user_id": "user:uuid", "email": "user@example.com"}

GET/auth/googleNo prefix

Google OAuth認証画面へリダイレクト

Query Parameters

sid?string紐付けるセッションID
// Redirect flow
GET /auth/google?sid=webchat:abc123
→ 302 https://accounts.google.com/o/oauth2/v2/auth?...
→ Callback: /?token=UUID (after Google consent)

GET/api/v1/auth/meAuth Required

ログイン中のユーザー情報を取得
// Request
GET /api/v1/auth/me
Authorization: Bearer YOUR_TOKEN

// Response 200 (authenticated)
{"authenticated": true, "user_id": "user:uuid", "email": "user@example.com", "display_name": "user@example.com"}

// Response 200 (not authenticated)
{"authenticated": false}

Chat

POST/api/v1/chat

AIにメッセージを送信。ツール呼び出し・エージェント選択を含む応答を返す。

Request Body

message*stringユーザーのメッセージ
session_id*stringセッションID (例: webchat:uuid)
// Request
POST /api/v1/chat
{"message": "東京の天気は?", "session_id": "webchat:abc123"}

// Response 200
{
  "reply": "東京の現在の天気は晴れ、気温は15℃です。",
  "agent": "researcher",
  "tools_used": ["weather"],
  "session_id": "webchat:abc123",
  "message_count": 5,
  "credits_used": 10,
  "credits_remaining": 990
}

Sessions

GET/api/v1/sessions

セッション一覧を取得

Headers

x-session-id*stringSession ID
// Response 200
{"sessions": [{"id": "webchat:abc", "message_count": 12, "last_active": "2025-01-01T00:00:00Z"}]}

GET/api/v1/sessions/{id}

セッション詳細を取得(メッセージ履歴含む)
// Response 200
{"session_id": "webchat:abc", "messages": [{"role": "user", "content": "Hello"}, {"role": "assistant", "content": "Hi!"}]}

DELETE/api/v1/sessions/{id}

セッションを削除
// Response 200
{"ok": true}

Conversations

GET/api/v1/conversationsAuth Required

ログインユーザーの会話一覧を取得
// Response 200
{"conversations": [{"id": "conv-uuid", "title": "東京の天気", "created_at": "2025-01-01T00:00:00Z", "session_id": "webchat:abc"}]}

POST/api/v1/conversationsAuth Required

新しい会話を作成
// Response 200
{"ok": true, "conversation_id": "conv-uuid", "session_id": "webchat:new-uuid"}

GET/api/v1/conversations/{id}/messagesAuth Required

会話のメッセージ一覧を取得
// Response 200
{"messages": [{"role": "user", "content": "Hello", "timestamp": "2025-01-01T00:00:00Z"}], "session_id": "webchat:abc"}

DELETE/api/v1/conversations/{id}Auth Required

会話を削除
// Response 200
{"ok": true}

Settings

GET/api/v1/settings/{id}

ユーザー設定を取得
// Response 200
{
  "model": "anthropic/claude-sonnet-4-5-20250929",
  "temperature": 0.7,
  "language": "ja",
  "tools_enabled": ["web_search", "weather", "calculator"],
  "custom_api_key": null,
  "log_enabled": true
}

POST/api/v1/settings/{id}

ユーザー設定を更新

Request Body

model?stringe.g. "openai/gpt-4o"
temperature?number0.0 — 2.0
language?stringja, en, zh, ko, es, fr, de
tools_enabled?string[]有効にするツール名の配列
custom_api_key?string自分のAPIキー
log_enabled?boolean会話ログ保存(有料プランのみ)
// Request
POST /api/v1/settings/webchat:abc123
{"model": "openai/gpt-4o", "temperature": 0.5}

// Response 200
{"ok": true}

Account & Usage

GET/api/v1/account/{id}

アカウント情報を取得(プラン、クレジット残高、Stripe情報)
// Response 200
{
  "user_id": "user:uuid",
  "plan": "starter",
  "credits_remaining": 24500,
  "credits_total": 25000,
  "stripe_customer_id": "cus_xxx",
  "period_end": "2025-02-01T00:00:00Z"
}

GET/api/v1/usage

使用量サマリーを取得

Headers

x-session-id*stringSession ID
// Response 200
{"credits_used": 500, "credits_remaining": 500, "plan": "free", "message_count": 42}

Billing

POST/api/v1/billing/checkout

Stripe Checkoutセッションを作成

Request Body

price_id*stringStripe price ID
session_id*stringSession ID
// Response 200
{"url": "https://checkout.stripe.com/c/pay_xxx"}

GET/api/v1/billing/portal

Stripe Customer Portalへのリダイレクト

Query Parameters

session_id*stringSession ID
// Response 302 → Stripe Customer Portal

POST/api/v1/coupon/validate

クーポンコードを検証・適用

Request Body

code*stringクーポンコード
session_id*stringSession ID
// Response 200 (valid)
{"valid": true, "credits": 5000, "message": "5000 credits added!"}

// Response 200 (invalid)
{"valid": false, "error": "Invalid or expired coupon"}

Misc

GET/api/v1/providers

利用可能なLLMプロバイダー・モデル一覧
// Response 200
{"providers": [{"name": "openai", "models": ["gpt-4o", "gpt-4o-mini"]}, {"name": "anthropic", "models": ["claude-sonnet-4-5-20250929"]}]}

GET/api/v1/agents

利用可能なAIエージェント一覧
// Response 200
{"agents": [{"name": "assistant", "description": "General purpose"}, {"name": "researcher", "description": "Web search & fact-checking"}]}

GET/api/v1/integrations

利用可能なツール・インテグレーション一覧
// Response 200
{"tools": [{"name": "web_search", "enabled": true}, {"name": "weather", "enabled": true}]}

GET/api/v1/devices

接続中のCLIデバイス一覧

Headers

x-session-id*stringSession ID
// Response 200
{"devices": [{"hostname": "macbook-pro", "os": "macos", "arch": "arm64", "memory_total": 16000, "memory_used": 8000, "uptime_secs": 3600}]}

GET/healthNo prefix

ヘルスチェック
// Response 200
{"status": "ok"}

Webhooks

POST/webhooks/lineNo prefix

LINE Messaging APIのWebhookエンドポイント。HMAC-SHA256で署名検証。

POST/webhooks/telegramNo prefix

Telegram Bot APIのWebhookエンドポイント。

POST/webhooks/stripeNo prefix

Stripe Webhookエンドポイント。checkout.session.completed等を処理。

Rate Limits

プランに応じてレート制限が適用されます。
Free10 同時リクエスト / 1,000 クレジット/月
Starter ($9/mo)100 同時リクエスト / 25,000 クレジット/月
Pro ($29/mo)1,000 同時リクエスト / 300,000 クレジット/月