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 nb_live_a1b2c3d4e5f6g7h8i9j0" 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/register

メール+パスワードで新規ユーザー登録

Request Body

email*stringEmail address
password*stringパスワード(8〜128文字)
// Request
POST /api/v1/auth/register
{"email": "user@example.com", "password": "mypassword123"}

// Response 200
{"ok": true, "token": "nb_live_a1b2c3d4e5f6g7h8i9j0", "user_id": "user:550e8400-e29b-41d4", "email": "user@example.com"}

// Error 409
{"error": "Email already registered"}

POST/api/v1/auth/login

メール+パスワードでログイン

Request Body

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

// Response 200
{"ok": true, "token": "nb_live_a1b2c3d4e5f6g7h8i9j0", "user_id": "user:550e8400-e29b-41d4", "email": "user@example.com"}

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

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": "nb_live_a1b2c3d4e5f6g7h8i9j0", "user_id": "user:550e8400-e29b-41d4", "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 nb_live_a1b2c3d4e5f6g7h8i9j0

// Response 200 (authenticated)
{"authenticated": true, "user_id": "user:550e8400-e29b-41d4", "email": "user@example.com", "display_name": "user@example.com"}

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

POST/api/v1/auth/verify

メール認証コード(6桁)を検証

Request Body

email*stringEmail address
code*string6桁の認証コード
session_id?string紐付けるセッションID
// Request
POST /api/v1/auth/verify
{"email": "user@example.com", "code": "123456"}

// Response 200
{"ok": true, "token": "nb_live_a1b2c3d4e5f6g7h8i9j0", "user_id": "user:550e8400-e29b-41d4"}

// Error 400
{"error": "Invalid verification code format"}

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
{
  "response": "東京の現在の天気は晴れ、気温は15℃です。",
  "session_id": "webchat:abc123",
  "agent": "researcher",
  "tools_used": ["weather"],
  "credits_used": 10,
  "credits_remaining": 990,
  "model_used": "anthropic/claude-sonnet-4-5-20250929"
}

POST/api/v1/chat/stream

SSEストリーミングでAIの応答をリアルタイムに受信

Request Body

message*stringユーザーのメッセージ(最大32,000文字)
session_id*stringセッションID (例: webchat:uuid)

Response: text/event-stream

// Each SSE event is a JSON object:
data: {"type":"chunk","content":"東京の"}
data: {"type":"chunk","content":"天気は"}
data: {"type":"chunk","content":"晴れです。"}
data: {"type":"done","content":"","credits_used":10,"credits_remaining":990,"model_used":"anthropic/claude-sonnet-4-5-20250929"}

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-7a8b9c0d1e2f3g4h", "title": "東京の天気", "created_at": "2025-01-01T00:00:00Z", "session_id": "webchat:abc"}]}

POST/api/v1/conversationsAuth Required

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

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}

POST/api/v1/conversations/{id}/shareAuth Required

会話の共有リンクを生成
// Response 200
{"ok": true, "share_url": "https://chatweb.ai/c/aBcDeFgHiJ", "hash": "aBcDeFgHiJ"}

// Already shared
{"ok": true, "share_url": "https://chatweb.ai/c/aBcDeFgHiJ", "hash": "aBcDeFgHiJ", "existing": true}

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

会話の共有リンクを無効化
// Response 200
{"ok": true}

GET/api/v1/shared/{hash}Public

共有された会話のメッセージを取得(認証不要)
// Response 200
{
  "title": "東京の天気",
  "messages": [
    {"role": "user", "content": "東京の天気は?"},
    {"role": "assistant", "content": "東京の現在の天気は晴れです。"}
  ],
  "shared_at": "2026-02-09T12:00:00Z"
}

// Error 404 (revoked or not found)
{"error": "Shared conversation not found"}

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:550e8400-e29b-41d4",
  "plan": "starter",
  "credits_remaining": 24500,
  "credits_total": 25000,
  "stripe_customer_id": "cus_NffrFeUfNV2Hib",
  "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_cs_test_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6"}

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"}

POST/api/v1/coupon/redeem

クーポンを適用してクレジットを付与+プランをアップグレード

Request Body

code*stringクーポンコード
session_id?stringSession ID
// Response 200
{"ok": true, "credits_added": 5000, "plan": "starter", "message": "Coupon redeemed! 5000 credits added."}

// Error 400
{"error": "Coupon is no longer active"}

Speech

POST/api/v1/speech/synthesize

テキストから音声を合成(OpenAI TTS)。MP3バイナリを返す。

Request Body

text*string音声にするテキスト(1〜4096文字)
voice?string音声モデル名(デフォルト: nova)
speed?number再生速度(デフォルト: 1.0)
session_id?stringSession ID

レスポンス: audio/mpeg バイナリ

// Request
POST /api/v1/speech/synthesize
{"text": "こんにちは、世界!", "voice": "nova", "speed": 1.0}

// Response: MP3 binary (Content-Type: audio/mpeg)

API Keys

GET/api/v1/apikeysAuth Required

APIキー一覧を取得
// Response 200
{"keys": [{"id": "key_9x8y7z6a5b4c3d2e", "name": "default", "prefix": "nb_live_a1b2c3d4...", "created_at": "2026-01-01T00:00:00Z"}]}

POST/api/v1/apikeysAuth Required

新しいAPIキーを作成

Request Body

name?stringキー名(デフォルト: default)
// Response 200
{"ok": true, "api_key": "nb_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "key_id": "key_9x8y7z6a5b4c3d2e", "name": "default"}

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

APIキーを削除
// Response 200
{"ok": true}

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"}

Playground Results

POST/api/v1/results

Playgroundの実行結果を保存して共有URLを取得
// Request
POST /api/v1/results
{"method": "POST", "url": "/api/v1/chat", "request_body": "...", "status": 200, "response_body": "...", "elapsed_ms": 150}

// Response 200
{"ok": true, "id": "aBcDeFgHiJ"}

GET/api/v1/results/{id}

保存された実行結果を取得
// Response 200
{"method": "POST", "url": "/api/v1/chat", "request_body": "...", "status": 200, "response_body": "...", "elapsed_ms": 150}

MCP (Model Context Protocol)

POST/mcp

AI agentがchatweb.aiをツールとして使うためのMCPエンドポイント(JSON-RPC 2.0)

Available Tools

chattoolAIにメッセージを送信して応答を取得
ttstoolテキストから音声を合成
providerstool利用可能なAIプロバイダーを一覧
statustoolサービス状態とレイテンシを確認
// Initialize
POST /mcp
{"jsonrpc": "2.0", "id": 1, "method": "initialize"}

// List tools
POST /mcp
{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}

// Call chat tool
POST /mcp
{
  "jsonrpc": "2.0", "id": 3,
  "method": "tools/call",
  "params": {
    "name": "chat",
    "arguments": {"message": "Hello!"}
  }
}

// Response
{
  "jsonrpc": "2.0", "id": 3,
  "result": {
    "content": [{"type": "text", "text": "Hello! How can I help you?"}]
  }
}

Sync

chatweb.aiはマルチデバイス・マルチチャネルで会話を同期します。

Auto-Sync Intervals

Plan Auto-sync Interval Manual Sync Cron Limit
Free 5 min Yes 1
Starter 1 min Yes 5
Pro 1 min Yes 20
Enterprise 1 min Yes 20

GET/api/v1/sync/conversationsAuth Required

会話リストを同期トークン付きで取得。
GET /api/v1/sync/conversations?since=2026-01-01T00:00:00Z
Authorization: Bearer nb_live_a1b2c3d4e5f6g7h8i9j0

// Response
{ "conversations": [...], "sync_token": "..." }

POST/api/v1/sync/pushAuth Required

クライアントの会話をサーバーにプッシュ同期。
POST /api/v1/sync/push
Authorization: Bearer nb_live_a1b2c3d4e5f6g7h8i9j0
Content-Type: application/json

{
  "conversations": [{
    "client_id": "local-123",
    "title": "My chat",
    "messages": [{"role":"user","content":"Hello"}]
  }]
}

// Response
{ "synced": [{"client_id":"local-123","server_id":"abc"}] }

Scheduled Tasks (Cron)

定期的にAIにメッセージを送信するスケジュールタスクを管理します。

GET/api/v1/cronAuth Required

ユーザーの定期タスク一覧を取得。
GET /api/v1/cron
Authorization: Bearer nb_live_a1b2c3d4e5f6g7h8i9j0

// Response
{
  "jobs": [{
    "id": "abc12345",
    "name": "Morning briefing",
    "message": "今日の天気と予定を教えて",
    "schedule": "every:30",
    "schedule_display": "30min",
    "channel": "",
    "enabled": true,
    "created_at": "2026-02-10T00:00:00Z"
  }]
}

POST/api/v1/cronAuth Required

定期タスクを作成。
POST /api/v1/cron
Authorization: Bearer nb_live_a1b2c3d4e5f6g7h8i9j0
Content-Type: application/json

// Interval (every N minutes)
{ "name": "Weather check", "message": "天気を教えて",
  "schedule": { "every_minutes": 30 }, "channel": "line" }

// Cron expression
{ "name": "Morning report", "message": "今日のニュースまとめ",
  "schedule": { "cron": "0 9 * * *" } }

// One-time
{ "name": "Reminder", "message": "会議の準備",
  "schedule": { "at": "2026-02-10 09:00" } }

// Response
{ "ok": true, "id": "abc12345" }

PUT/api/v1/cron/{id}Auth Required

定期タスクを更新。
PUT /api/v1/cron/abc12345
Authorization: Bearer nb_live_a1b2c3d4e5f6g7h8i9j0
Content-Type: application/json

{ "enabled": false }

// Response
{ "ok": true }

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

定期タスクを削除。
DELETE /api/v1/cron/abc12345
Authorization: Bearer nb_live_a1b2c3d4e5f6g7h8i9j0

// Response
{ "ok": true }

Webhooks

POST/webhooks/lineNo prefix

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

POST/webhooks/telegramNo prefix

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

GETPOST/webhooks/facebookNo prefix

Facebook Messenger Webhookエンドポイント。GETはverify、POSTはメッセージ受信。

POST/webhooks/teamsNo prefix

Microsoft Teams Bot Framework Webhookエンドポイント。

POST/webhooks/google_chatNo prefix

Google Chat Webhookエンドポイント。同期JSON応答。

POST/webhooks/zaloNo prefix

Zalo OA Webhookエンドポイント。

POST/webhooks/feishuNo prefix

Feishu/Lark Webhookエンドポイント。URL検証チャレンジ対応。

POST/webhooks/whatsappNo prefix

WhatsApp Cloud API Webhookエンドポイント。

POST/webhooks/stripeNo prefix

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

Rate Limits

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