API リファレンス
voicast の
基本#
- URL:
https://api.voicast.jp/v1 - 認証:
Authorization: Bearer vk_live_…かvk_test_…。キーの 環境 (本番か テスト) の 中だけを 読み 書きします - 形式: JSON。
時刻は Unix ミリ秒、 ID は 接頭辞付きの 文字列 ( agt_・ten_・call_・sess_・con_) - エラー:
{ error, message, details?, request_id }。種類はエラーと 制限 - 呼び出しの
ID : すべての応答に x-request-id( req_…)が 付きます。 エラーの 本文の request_idと同じです。 問い合わせの ときに 伝えてください - 回数の
上限 : API キーごとに1 分 600 回。 応答の x-ratelimit-limit・x-ratelimit-remaining・x-ratelimit-reset(枠の 終わり、 Unix 秒) で 残りが 分かり、 超えると 429 と Retry-After(秒)
API キーは
エンドポイント#
音声の
| 方式 | URL | 内容 |
|---|---|---|
| WebSocket | wss://voice.voicast.jp/ws |
電話 |
| POST | https://voice.voicast.jp/v1/webrtc/offer |
Web・アプリ |
| PATCH | https://voice.voicast.jp/v1/webrtc/offer |
ICE の |
MCPhttps://api.voicast.jp/mcp)
会話の設定の作成#
POST /v1/agents| 入力 | 型 | 内容 |
|---|---|---|
name |
string | 名前 |
config |
AgentConfig | 会話の |
返り: 201 Agentconfig 付き、version: 1)invalid_configdetails に
type Agent = { id: string; name: string; version: number; config?: AgentConfig; created_at: number; updated_at: number };
type AgentConfig = {
greeting: string; // 最初のあいさつ(300 文字まで)
persona: string; // 役割と話し方(1,000 文字まで)
fields: { key: string; label: string; required?: boolean; type?: 'text' | 'phone' }[]; // 1〜20 個
handoff_when: string[]; // 人に引き継ぐ条件(20 個まで)
closing: string; // 聞き取りが終わったときの締め(300 文字まで)
closing_answered?: string; // よくある質問で用が済んだときの締め
faq?: { q: string; a: string }[]; // 50 個まで
domain?: string; // 業種(音声認識の手がかり)
vocabulary?: string[]; // 用語(音声認識の手がかり、200 個まで)
voice?: string; // 声の名前(既定 Aoede)
speaking_rate?: number; // 話す速さ(既定 1.15)
tools?: AgentTool[]; // 通話中の道具(10 個まで)
connectors?: ConnectorEntry[]; // 連携(10 個まで)
};
type AgentTool = {
name: string; description: string; url: string; confirm?: boolean;
parameters?: { properties: Record<string, { type: 'string' | 'number' | 'integer' | 'boolean'; description?: string; enum?: string[] }>; required?: string[] };
};
type ConnectorEntry =
| { connector: string; actions: string[]; confirm?: string[] } // プリセット
| { connection: string; actions: string[]; confirm?: string[] }; // 決まった連携(con_…)会話の設定の一覧#
GET /v1/agents返り: { data: Agent[] }config なし)
会話の設定の取得#
GET /v1/agents/{id}?version=versionAgentconfig 付き)
会話の設定の変更#
PUT /v1/agents/{id}| 入力 | 型 | 内容 |
|---|---|---|
name |
string | 任意。 |
config |
AgentConfig | 全体を |
返り: Agent
会話の設定の版の一覧#
GET /v1/agents/{id}/versions返り: { data: [{ version, created_at }] }
会話の設定の削除#
DELETE /v1/agents/{id}返り: 204。in_use。
テナントの作成#
POST /v1/tenants| 入力 | 型 | 内容 |
|---|---|---|
external_id |
string | サービスの. _ : - の |
name |
string | 任意。 |
agent_id |
string | 任意。 |
返り: 201 Tenant とsecretvts_…。external_id がconflict。
type Tenant = { id: string; external_id: string; name: string; agent_id: string | null; status: 'active' | 'disabled'; created_at: number };テナントの一覧#
GET /v1/tenants返り: { data: Tenant[] }。
テナントの取得#
GET /v1/tenants/{id}返り: Tenant
テナントの変更#
PATCH /v1/tenants/{id}| 入力 | 型 | 内容 |
|---|---|---|
name |
string | 任意 |
agent_id |
string | null | 任意。null で |
status |
active・disabled |
任意。disabled で |
返り: Tenant。
接続の鍵の作り直し#
POST /v1/tenants/{id}/secret返り: { secret, previous_secret_expires_at }。
テナントの削除#
DELETE /v1/tenants/{id}返り: 204。external_id で
通話の一覧#
GET /v1/calls?tenant_id=&cursor=&limit=| クエリ | 内容 |
|---|---|
tenant_id |
任意。 |
cursor |
任意。next_cursor を |
limit |
任意。 |
before |
任意。started_at よりcursor をcursor と |
返り: { data: Call[], has_more, next_cursor }has_more がtrue のnext_cursor をcursor にhas_more がfalse ならnext_cursor はnull)
type Call = {
id: string; tenant_id: string; agent: { id: string; version: number };
provider_call_id: string | null; // Twilio の CallSid、Web・アプリはセッションの ID
from: string | null; // かけてきた番号(電話で from を渡したとき)
started_at: number; ended_at: number | null; duration_ms: number | null;
outcome: 'completed' | 'answered' | 'handoff' | 'hangup' | 'error' | null; reason: string | null;
fields: Record<string, string> | null;
summary: string | null; category: string | null; has_transcript: boolean;
channel: 'phone' | 'web'; output: 'audio' | 'text';
billed_yen: number | null; // この通話の利用料(税別の円、小数 3 桁まで)。通話中は null
};billed_yen は、
通話の取得#
GET /v1/calls/{id}返り: Call。
サービスの側の ID で通話を引く#
GET /v1/calls/by-provider/{providerCallId}Twilio のCallSidCA…)sess_…)<Connect> のaction でCall。
文字起こし#
GET /v1/calls/{id}/transcript返り: { call_id, turns: [{ role: 'assistant' | 'user', text }] }。
セッションの作成#
POST /v1/sessions| 入力 | 型 | 内容 |
|---|---|---|
tenant_id |
string | テナントの |
agent_id |
string | 任意。 |
output |
audio・text |
任意。audio |
返り: 201 { id, tenant_id, agent_id, output, client_token, expires_at, webrtc_url, ice_servers }。client_tokenvct_…)ice_servers[{ urls, username?, credential? }])RTCPeerConnection のiceServers にclient_token・webrtc_url・ice_servers だけを
エラー: 402balance_depleted・payment_overdue・spending_cap_reached)tenant_disabled、no_agent・invalid_request。
利用の内訳#
GET /v1/usage?from=&to=&group_by=| クエリ | 内容 |
|---|---|
from・to |
日付YYYY-MM-DD、to はto は |
group_by |
任意。tenant・day・channel |
返り:
type Usage = {
environment: 'live' | 'test'; from: number; to: number;
group_by: 'tenant' | 'day' | 'channel' | null; unit_price_yen: number;
total: { calls: number; seconds: number; minutes: number; amount_yen: number };
data: (({ tenant: { id: string; external_id: string; name: string } } | { day: string } | { channel: 'phone' | 'web' })
& { calls: number; seconds: number; minutes: number; amount_yen: number })[]; // group_by が無ければ []
note: string;
};数えるのはamount_yen は
Webhook の設定画面のリンク#
POST /v1/webhooks/portal| 入力 | 型 | 内容 |
|---|---|---|
frame_origin |
string | 任意。 |
locale |
ja・en |
任意。ja) |
返り: 201 { url, expires_at }unavailable。
請求の状態#
GET /v1/billingAPI キーの
type Billing = {
organization_id: string; month: string; // 今月(日本時間、YYYY-MM)
contract: { payment_method: 'card' | 'invoice'; per_minute_yen: number; invoice_days_until_due: number };
has_card: boolean; // オートチャージに使うカードを保存したか
usage: { calls: number; seconds: number; minutes: number }; // 今月の通話(本番とテストの合計)
estimate_yen: number; // チャージ式は今月に引いた額、請求書払いは見込み
balance: { yen: number; milli_yen: number; depleted: boolean; next_expiry: { yen: number; at: number } | null } | null; // チャージ式だけ
auto_recharge: { enabled: boolean; threshold_yen: number; amount_yen: number; monthly_cap_yen: number | null;
recharged_this_month_yen: number; failures: number; max_failures: number } | null; // チャージ式だけ
topup: { min_yen: number; max_yen: number; quick_yen: number[]; credit_months: number };
spending_cap_yen: number | null; cap_reached: boolean;
payment: { failed_at: number; grace_ends_at: number; suspended: boolean } | null; // 請求書払いの支払いの遅れ
tax: 'excluded'; tax_rate: number;
// ほかに price・stripe_enabled・subscription_status・threshold
};チャージ#
POST /v1/billing/topups| 入力 | 型 | 内容 |
|---|---|---|
amount_yen |
integer | チャージの |
返り: 201 { url, amount_yen, tax_yen }。url はinvoice_billing。
道具の署名の鍵#
GET /v1/tools/secret返り: { secret, previous_secret_expires_at }。secretwhsec_…)previous_secret_expires_at はnull)
道具の署名の鍵の作り直し#
POST /v1/tools/secret/rotate返り: { secret, previous_secret_expires_at }。
連携先の一覧#
GET /v1/connectors返り: { data: Connector[] }。
type Connector = {
id: string; name: string; description: string;
category: 'scheduling' | 'crm' | 'notify' | 'custom'; auth: 'oauth2' | 'api_key' | 'webhook_url';
available: boolean; // この voicast で使える
needs_setup: boolean; // つないだあとに設定が要る
notify: boolean; // 通話のあとに通知する
env_only: boolean; // 環境の連携だけ(埋め込みの連携の画面に出ない)
inputs: { name: string; type: 'text' | 'password' | 'url' | 'number' }[];
actions: { name: string; tool: string; description: string; confirm: boolean }[]; // tool は AI に見せる名前
};連携の一覧#
GET /v1/connections?tenant_id=tenant_id を?tenant_id=){ data: Connection[] }。
type Connection = {
id: string; connector: string; tenant_id: string | null;
label: string; // 相手のアカウント名(clinic@example.com・ワークスペース #チャンネル など)
status: 'active' | 'needs_setup' | 'needs_reauth';
config: object; created_by: string | null; created_at: number; updated_at: number;
};連携の作成(API キー・URL)#
POST /v1/connections| 入力 | 型 | 内容 |
|---|---|---|
connector |
teams・shannon_booking・http |
API キーか |
secret |
string | API キー・Webhook の |
input |
object | 任意。shannon_booking は{ base_url }、http は{ base_url, header } |
tenant_id |
string | 任意。shannon_booking・http はinvalid_request |
返り: 201 Connection。verify_failed。
連携の取得#
GET /v1/connections/{id}返り: Connection。
連携の設定#
PATCH /v1/connections/{id}| 入力 | 型 | 内容 |
|---|---|---|
config |
object | 連携先ごとの |
返り: Connection。needs_setup)active にinvalid_config。
連携の設定の選択肢#
GET /v1/connections/{id}/options連携先に
| 連携先 | クエリ | 返り |
|---|---|---|
| Google カレンダー・Microsoft 365 | { calendars: [{ id, name, primary }] } |
|
| Google スプレッドシート | spreadsheet・sheet |
{ spreadsheets, sheets, headers } |
| kintone | app |
{ apps, fields: [{ code, label }] } |
| Chatwork | { rooms } |
|
| LINE WORKS | { users } |
|
| MCP サーバー | { tools } |
連携がneeds_reauth。
連携の解除#
DELETE /v1/connections/{id}返り: 204。
テナントの連携の一覧#
GET /v1/tenants/{id}/connections返り: { data: Connection[] }。
連携の画面のリンク#
POST /v1/tenants/{id}/connect-links| 入力 | 型 | 内容 |
|---|---|---|
connectors |
string[] | 任意。google_calendar・m365_calendar・google_sheets・kintone・hubspot・slack・chatwork・lineworks・teams) |
frame_origin |
string | 任意。 |
返り: 201 { url, expires_at }
電話(Twilio Media Streams)#
wss://voice.voicast.jp/wsTwilio の<Connect><Stream> の<Parameter> で
| Parameter | 内容 |
|---|---|
tenant |
テナントの |
secret |
テナントのvts_…) |
agent |
任意。 |
from |
任意。 |
鍵が
WebRTC の offer#
POST https://voice.voicast.jp/v1/webrtc/offer| 入力 | 型 | 内容 |
|---|---|---|
sdp・type |
string | WebRTC の |
token |
string | セッションのclient_tokenrequestData.token でも |
pc_id・restart_pc |
string・boolean | つなぎ直しのtoken は |
返り: { sdp, type, pc_id }。POST /v1/sessions と
つないだら、client-ready をping の
ICE の候補#
PATCH https://voice.voicast.jp/v1/webrtc/offer| 入力 | 型 | 内容 |
|---|---|---|
pc_id |
string | offer のpc_id |
candidates |
array | [{ candidate, sdp_mid, sdp_mline_index }] |
返り: { ok: true }。pc_id は