Query SMS Records

Last edited on 2026-04-08

This API should be called on the server side and cannot be called directly on the client side (Mini Program, web page, APP, etc.). For details, please refer to API Call Guide.

API English Name: describeSmsRecords

This API is used to query SMS records within the last 2 months.

1. Call Method

HTTPS Call

POST https://api.weixin.qq.com/tcb/describesmsrecords?access_token=ACCESS_TOKEN

Cloud Call

  • Call Method: cloudbase.describeSmsRecords

  • Input and output parameters are the same as HTTPS call. For call method, please refer to Cloud Call documentation.

Third-party Call

  • This API supports third-party platforms on behalf of Merchant call.

  • The permission set ID of this API is: 49

  • After the service provider obtains one of the permission set authorizations, it can use authorizer_access_token to call on behalf of Merchant, for details please refer to Third-party Call documentation.

2. Request Parameters

Query Parameters Query String Parameters

ParameterTypeRequiredDescription
access_tokenstringYesAPI call credential, you can use authorizer_access_token

Request Body Request Payload

ParameterTypeRequiredDescription
EnvIdstringYesEnvironment ID
StartDatestringYesStart date, e.g., 2021-01-01
EndDatestringYesEnd date, e.g., 2021-01-07
MobilestringYesPhone number
QueryIdstringYesQuery ID
PageNumbernumberYesPage number (starting from 1)
PageSizenumberYesNumber of entries per page

3. Response Parameters

Response Body Response Payload

ParameterTypeDescription
SmsRecordsobjarrayList of sending records
TotalCountnumberTotal number of records
RequestIdstringUnique Request ID, returned for each request. Provide this RequestId when troubleshooting.
errcodenumberError code
errmsgstringError message

Res.SmsRecords(Array) Object Payload

List of sending records

ParameterTypeDescription
MobilestringMobile phone number
ContentstringSMS content
ContentSizenumberSMS content length
FeenumberBillable message count
CreateTimestringSending time
ReceivedTime stringUser receipt time
Statusstringsent (Success), error (Failure)
RemarksstringRemarks

4. Notes

No special notes for this API

5. Code Example

5.1 HTTPS Call

Request Example

{
  "PostData": {
    "StartDate": "2021-03-01",
    "EndDate": "2021-03-23",
    "EnvId": "xxx",
    "QueryId": "xxx",
    "PageNumber": 1,
    "PageSize": 20
  }
}

Response Example

{
 "SmsRecords": [
 {
 "Content": "【XXX】XXX, visit Mini Program https://xxx/xxx Reply T to unsubscribe",
 "ContentSize": 51,
 "CreateTime": "2021-03-22 17:18:37",
 "Fee": 1,
 "Mobile": "+86xxxxxxxxxxx",
 "ReceivedTime": "2021-03-22 17:18:43",
 "Remarks": "SMS received successfully by the user",
 "Status": "sent"
}
],
 "TotalCount": 1,
 "RequestId": "bf34127a-35bd-48a2-86bb-ae583d2ff9ff"
}

5.2 Cloud Function Call

Request Example

const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi({ convertCase: false }).cloudbase.describeSmsRecords({
        "PostData": {
          "StartDate": '2021-03-01',
          "EndDate": '2021-03-23',
          "EnvId": 'xxx',
          "QueryId": 'xxx',
          "PageNumber": 1,
          "PageSize": 20
        }
      })
    return result
  } catch (err) {
    return err
  }
}

Response Example

{
 "Response": {
 "SmsRecords": [
 {
 "Content": "【XXX】XXX, visit Mini Program https://xxx/xxx Reply T to unsubscribe",
 "ContentSize": 51,
 "CreateTime": "2021-03-22 17:18:37",
 "Fee": 1,
 "Mobile": "+86xxxxxxxxxxx",
 "ReceivedTime": "2021-03-22 17:18:43",
 "Remarks": "SMS received successfully by the user",
 "Status": "sent"
}
],
 "TotalCount": 1,
 "RequestId": "bf34127a-35bd-48a2-86bb-ae583d2ff9ff"
},
 "errMsg": "openapi.cloudbase.describeSmsRecords:ok"
}

6. Error Codes

The following is the error code list of this API, other error codes can refer to Common Error Codes; When encountering errors in calling the API, you can use the official API Diagnostic Tool to assist in locating and analyzing problems.

Error CodeError DescriptionSolution
-1system errorThe system is busy. Please wait a moment and try again.
85088no qbase privilegeCloud Development has not been enabled for this APP.

7. Applicable Scope

API callable status for different account types:
Mini ProgramMini Game
✔ ✔
  • ✔:This account type can call this API。
  • Other account types not explicitly declared cannot call this API unless otherwise specified.