APP_KEY="demo"
APP_SECRET="YOUR_APP_SECRET"
BASE_URL="https://im.example.com"
NONCE="$(openssl rand -hex 16)"
TIMESTAMP="$(date +%s%3N)"
SIGNATURE="$(printf '%s' "$APP_SECRET$NONCE$TIMESTAMP" | openssl sha1 | awk '{print $2}')"
curl -sS -X POST "$BASE_URL/im/v2/message/trace/get" \
-H "Content-Type: application/json" \
-H "App-Key: $APP_KEY" \
-H "Nonce: $NONCE" \
-H "Timestamp: $TIMESTAMP" \
-H "Signature: $SIGNATURE" \
-d '{"messageId":"msg_10001"}'
import { createHash, randomBytes } from 'node:crypto';
const APP_KEY = 'demo';
const APP_SECRET = 'YOUR_APP_SECRET';
const BASE_URL = 'https://im.example.com';
const PATH = '/im/v2/message/trace/get';
const nonce = randomBytes(16).toString('hex');
const timestamp = String(Date.now());
const signature = createHash('sha1')
.update(APP_SECRET + nonce + timestamp)
.digest('hex');
const res = await fetch(BASE_URL + PATH, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'App-Key': APP_KEY,
Nonce: nonce,
Timestamp: timestamp,
Signature: signature,
},
body: JSON.stringify({"messageId":"msg_10001"}),
});
const result = await res.json();
if (result.code !== 0) throw new Error(result.code + ': ' + result.msg);
console.log(result.data);
{
"code": 0,
"data": {
"messageId": "msg_10001",
"conversationType": 1,
"targetId": "user2",
"senderId": "user1",
"seq": 1024,
"status": "success",
"ackAt": 1750000000000,
"deliveredSessions": 0,
"offlineQueued": false,
"routed": false,
"callbackDeliveries": [
{
"deliveryId": "dlv_3001",
"appkey": "demo",
"eventType": "message.routed",
"eventId": "evt_5b1c",
"url": "https://your-app.example.com/webhook/im",
"status": "success",
"attempts": 1,
"responseCode": 200,
"lastAttemptAt": 1750000000000
}
]
},
"requestId": "req_7f3a9c"
}