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
| Parameter | Type | Required | Description |
|---|---|---|---|
| access_token | string | Yes | API call credential, you can use authorizer_access_token |
Request Body Request Payload
| Parameter | Type | Required | Description |
|---|---|---|---|
| EnvId | string | Yes | Environment ID |
| StartDate | string | Yes | Start date, e.g., 2021-01-01 |
| EndDate | string | Yes | End date, e.g., 2021-01-07 |
| Mobile | string | Yes | Phone number |
| QueryId | string | Yes | Query ID |
| PageNumber | number | Yes | Page number (starting from 1) |
| PageSize | number | Yes | Number of entries per page |
3. Response Parameters
Response Body Response Payload
| Parameter | Type | Description |
|---|---|---|
| SmsRecords | objarray | List of sending records |
| TotalCount | number | Total number of records |
| RequestId | string | Unique Request ID, returned for each request. Provide this RequestId when troubleshooting. |
| errcode | number | Error code |
| errmsg | string | Error message |
Res.SmsRecords(Array) Object Payload
List of sending records
| Parameter | Type | Description |
|---|---|---|
| Mobile | string | Mobile phone number |
| Content | string | SMS content |
| ContentSize | number | SMS content length |
| Fee | number | Billable message count |
| CreateTime | string | Sending time |
| ReceivedTime | string | User receipt time |
| Status | string | sent (Success), error (Failure) |
| Remarks | string | Remarks |
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 Code | Error Description | Solution |
|---|---|---|
| -1 | system error | The system is busy. Please wait a moment and try again. |
| 85088 | no qbase privilege | Cloud Development has not been enabled for this APP. |
7. Applicable Scope
| Mini Program | Mini Game |
|---|---|
| ✔ | ✔ |
- ✔:This account type can call this API。
- Other account types not explicitly declared cannot call this API unless otherwise specified.