Skip to content

Server APIs

A trusted backend calls TiRTC server capabilities through the cloud tirtc-server-api. Every request must originate from a trusted backend that holds the application credentials. Do not call these APIs from a client application or device firmware.

Base URL:

text
https://api-tirtc.tange365.com

TGV1-HMAC-SHA256 authentication

Requests use TGV1-HMAC-SHA256. Follow the server API signing instructions to generate Authorization, X-Tg-Algorithm, X-Tg-Date, X-Tg-App-Id, X-Tg-Content-Sha256, and X-Tg-Signed-Headers. Keep SecretKeyId on the trusted backend; never send it in a request or store it in client or device code.

HeaderDescription
AuthorizationTGV1 authorization line
X-Tg-AlgorithmSigning algorithm name
X-Tg-DateUTC request time
X-Tg-App-IdApplication ID; must match the credential app_id
X-Tg-Content-Sha256Lowercase hexadecimal SHA-256 of the request body; use an empty body for GET requests
X-Tg-Signed-HeadersNames of the headers included in the signature

API list

CapabilityAPIPurpose
Low-power sleep wakeupGET /v1/device/connectivityQuery the current connection information of a device
Low-power sleep wakeupPOST /v1/device/wakeup-requestSubmit a wakeup request to a device

Low-power sleep wakeup

These APIs complement the device-side low-power integration. Before submitting a wakeup request, the controller must obtain sleep parameters from the TiRTC SDK, and the low-power module must use them to log in to at least one sleep server and maintain heartbeats. See Low-Power Sleep Wakeup for the complete device flow.

A normal client connection triggers wakeup automatically. Submit a backend wakeup request only when an alarm, doorbell, or another business event needs to start the controller.

Query observed connectivity

This API queries the current connection information of a device, including the latest controller signaling and sleep-connection events observed by TiRTC. It does not directly determine whether the device is alive, has completed wakeup, or is in a particular business state.

Request

http
GET /v1/device/connectivity?device_id={device_id}
ParameterRequiredDescription
device_idYesTiRTC business device ID; 1–255 bytes of valid UTF-8; URL-encode it when passing it as a query parameter

Response

The API uses a common response envelope:

FieldTypeDescription
codenumberBusiness status code; 0 means success and a non-zero value means a business error
messagestringBusiness status message
dataobjectDevice connectivity data on success; omit the field when there is no data

Both successful and failed business results use HTTP 200 OK. Check code in the response body instead of relying only on the HTTP status.

On success, data reports two independent device-side connection paths:

json
{
  "code": 0,
  "message": "ok",
  "data": {
    "device_id": "example-device-id",
    "signal": {
      "is_online": true,
      "last_login_at": 1787000000,
      "last_heartbeat_at": 1787000030,
      "last_offline_at": 1786999000
    },
    "sleep": {
      "last_login_at": 1786998000,
      "last_heartbeat_at": 1786998060,
      "last_offline_at": 1786999100
    }
  }
}
ObjectDevice-side meaningFields
signalThe signaling connection established while the controller is running the TiRTC SDKis_online indicates whether the platform currently observes the controller connection as online; timestamps describe its latest login, heartbeat, and offline events
sleepThe TCP keepalive connection between the low-power module and a sleep server while the controller sleepsTimestamps describe the latest sleep-connection events; this object does not currently include is_online

last_login_at, last_heartbeat_at, and last_offline_at are Unix-second timestamps, or null when no corresponding event has been observed. These objects observe separate connections and are not mutually exclusive device modes. Use a device-online notification or another business signal to determine final wakeup state.

Errors

Business errors also return HTTP 200 OK, for example:

json
{
  "code": 40003,
  "message": "invalid parameter"
}
codeDescription
40003Invalid parameter, such as a missing device_id, a length outside 1–255 bytes, or invalid UTF-8
40301The application credential does not have permission
40302The device does not match the application
40304The device has expired
40403The device does not exist
50000An internal server error occurred
50301The connectivity service is unavailable
50401The query timed out

When the connectivity service is unavailable or the query times out, TiRTC returns the corresponding business error instead of interpreting missing data as the device being offline.

Submit a wakeup request

Use this API to submit a wakeup request to a device for a business event. The target device must already be logged in to a sleep server as described in the device integration flow.

Request

http
POST /v1/device/wakeup-request
Content-Type: application/json

The optional X-Request-ID header specifies a request identifier containing 1–128 printable ASCII characters. If omitted, the server generates one; if it is invalid, the server returns 40003 and generates a new request_id. The effective identifier is returned as the top-level request_id in the response body and matches the X-Tg-Request-Id response header.

json
{
  "device_id": "example-device-id",
  "custom_data": "0x1234"
}
FieldRequiredDescription
device_idYesTiRTC business device ID; 1–255 bytes of valid UTF-8
custom_dataNoTwo bytes of custom wakeup data; must be a string in the form 0x followed by four hexadecimal characters, for example 0x1234; a non-string value returns 40003 with the stable message custom_data must be a string; send it only when the target device can parse custom data

If the module can only match a fixed packet, omit custom_data so TiRTC sends 98 3b 16 f8 f3 9c 00 00. See Wakeup packet for device-side packet handling.

Response

The response uses a common structure. request_id, code, and message are top-level fields; on success the API returns data as defined and omits data when there is no data.

FieldTypeDescription
codenumberBusiness status code; 0 means success and a non-zero value means a business error
messagestringBusiness status message
request_idstringEffective request identifier; uses a valid X-Request-ID or a server-generated value when the header is omitted; matches the X-Tg-Request-Id response header
dataobjectWakeup request information on success; omit the field when there is no data

A successful submission returns HTTP 202 Accepted:

json
{
  "code": 0,
  "message": "ok",
  "request_id": "req-001",
  "data": {
    "device_id": "example-device-id",
    "status": "accepted",
    "accepted_at": "2026-08-23T10:00:00.126+08:00"
  }
}

This only means a sleep connection was found and the TCP write did not fail immediately. It does not prove delivery, controller startup, signal login, or final wakeup success.

Errors

Business errors use the same code, message, and request_id structure:

json
{
  "code": 40412,
  "message": "device not connected",
  "request_id": "req-001"
}
codeDescription
40003Invalid parameter, such as a missing field, an excessive length, an invalid format, or a non-string custom_data
40301The application credential does not have permission
40302The device does not match the application
40304The device has expired
40403The device does not exist
40412The device is not connected
40902The wakeup protocol is not supported
42901Request overload
50000An internal server error occurred
50204Wakeup delivery failed
50301The wakeup service is unavailable
50402The delivery result is unknown

For 50402, do not assume whether the wakeup data was delivered. Correlate logs with request_id, use a device-online signal to determine the final result, and keep business actions idempotent when retrying.

TiRTC