Skip to content

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

HeaderDescription
Content-Typeapplication/json
AuthorizationTGV1 authorization line
X-Tg-AlgorithmAlgorithm name
X-Tg-DateRequest time (UTC)
X-Tg-App-IdApplication id, must match credential app_id
X-Tg-Content-Sha256Request body SHA-256 (lowercase hex)
X-Tg-Signed-HeadersList of header names included in signing

For these TGV1-related headers, see TGV1-HMAC-SHA256 signing for format and calculation.

Body (JSON)

FieldTypeDescription
wx_session_keystringRequired. session_key from WeChat join_voip_room notification
wx_room_idstringRequired. room_id from WeChat notification
wx_session_tokenstringRequired. server_token from WeChat notification
wx_app_idstringRequired. Mini Program appId
device_idstringRequired. Device identifier, must match the device identity in your push message
wx_model_idstringRequired (configured in the example). WeChat hardware model ID for WeChat VoIP calling
wx_payloadstringOptional. Caller passthrough payload; treated as empty string when omitted
calling_timeout_secnumberOptional. Ring timeout in seconds, default 30
no_videobooleanOptional. true for audio-only
video_mtstringOptional 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_mtstringVideo format from device to WeChat Mini Program: h264 / h265 / mjpeg / none; do not use together with video_mt
down_video_mtstringVideo format from WeChat Mini Program to device: h264 / mjpeg / none; do not use together with video_mt
screen_width / screen_heightnumberScreen width and height when not audio-only
down_audio_mtstringAudio encoding from WeChat Mini Program to device: alaw / amr / opus; default alaw when omitted
audio_ratenumberRequired. Supported values: 8000, 16000
audio_channelsnumberRequired. 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:

json
{
  "code": 0,
  "msg": "ok",
  "data": {
    "peer_id": "whips://wxvoip?x_wx_session_key=...&x_device_id=...",
    "token": "<Bearer token string>"
  }
}
  • code !== 0: failure. msg contains details. Do not deliver invalid peer_id / token to the device.
  • data.peer_id: the first argument of TiRtcWhipConnect(service_desc, ...) (full whips://wxvoip?... URL).
  • data.token: the second argument of TiRtcWhipConnect(..., token, ...).

WeChat VoIP calling