Server API
Your business server calls TiRTC cloud tirtc-server-api (TGV1-HMAC-SHA256 authentication) to issue WHIP peer_id (service_desc) and Bearer token for device-side TiRtcWhipConnect.
tirtc-server-api base URL: https://api-tirtc.tange365.com.
TGV1-HMAC-SHA256 signing
This is the same as the Tange cloud OpenAPI server-side signing scheme. See Server API signing algorithm demo.
Issue WeChat VoIP call credentials: POST /v1/token/wxvoip
Purpose: Based on the current WeChat VoIP session and device media capabilities, request peer_id and token from the Tange platform. Your business server then delivers both to the device in wxa_join_voip_room.
Request
Headers
| Header | Description |
|---|---|
Content-Type | application/json |
Authorization | TGV1 authorization line |
X-Tg-Algorithm | Algorithm name |
X-Tg-Date | Request time (UTC) |
X-Tg-App-Id | Application id, must match credential app_id |
X-Tg-Content-Sha256 | Request body SHA-256 (lowercase hex) |
X-Tg-Signed-Headers | List of header names included in signing |
For these TGV1-related headers, see TGV1-HMAC-SHA256 signing for format and calculation.
Body (JSON)
| Field | Type | Description |
|---|---|---|
wx_session_key | string | Required. session_key from WeChat join_voip_room notification |
wx_room_id | string | Required. room_id from WeChat notification |
wx_session_token | string | Required. server_token from WeChat notification |
wx_app_id | string | Required. Mini Program appId |
device_id | string | Required. Device identifier, must match the device identity in your push message |
wx_model_id | string | Required (configured in the example). WeChat hardware model ID for WeChat VoIP calling |
wx_payload | string | Optional. Caller passthrough payload; treated as empty string when omitted |
calling_timeout_sec | number | Optional. Ring timeout in seconds, default 30 |
no_video | boolean | Optional. true for audio-only |
video_mt | string | Optional compatibility field; sets both uplink and downlink video format: h264 / mjpeg / none. If up_video_mt/down_video_mt are both provided but inconsistent, the request fails |
up_video_mt | string | Video format from device to WeChat Mini Program: h264 / h265 / mjpeg / none; do not use together with video_mt |
down_video_mt | string | Video format from WeChat Mini Program to device: h264 / mjpeg / none; do not use together with video_mt |
screen_width / screen_height | number | Screen width and height when not audio-only |
down_audio_mt | string | Audio encoding from WeChat Mini Program to device: alaw / amr / opus; default alaw when omitted |
audio_rate | number | Required. Supported values: 8000, 16000 |
audio_channels | number | Required. Supported values: 1, 2 |
Your business server usually builds this JSON after receiving WeChat join_voip_room, combining WeChat notification fields with device-reported media capabilities.
Response
On HTTP 200 with business success, the response uses the unified wrapper, for example:
{
"code": 0,
"msg": "ok",
"data": {
"peer_id": "whips://wxvoip?x_wx_session_key=...&x_device_id=...",
"token": "<Bearer token string>"
}
}code !== 0: failure.msgcontains details. Do not deliver invalidpeer_id/tokento the device.data.peer_id: the first argument ofTiRtcWhipConnect(service_desc, ...)(fullwhips://wxvoip?...URL).data.token: the second argument ofTiRtcWhipConnect(..., token, ...).