# 使用AppSecret重置第三方平台API调用次数

> 接口应在服务器端调用，不可在前端（小程序、网页、APP等）直接调用，具体可参考[接口调用指南](/doc/oplatform/developers/dev/guide.md)。

接口英文名：clearComponentQuotaByAppSecret

本接口用于清空公众号/小程序/第三方等接口的每日调用接口次数

## 1. 调用方式

### HTTPS 调用

```bash
POST https://api.weixin.qq.com/cgi-bin/component/clear_quota/v2
```

### 云调用

- 本接口不支持云调用。

### 第三方调用

- 本接口仅支持第三方平台使用 [component_access_token](/doc/oplatform/developers/dev/ComponentAccessToken.md) 自己调用。

## 2. 请求参数

### 查询参数 `Query String Parameters`

无

### 请求体 `Request Payload`

```json
[
  {
    "参数名": "appid",
    "类型": "string",
    "必填": "是",
    "说明": "授权用户appid"
  },
  {
    "参数名": "component_appid",
    "类型": "string",
    "必填": "是",
    "说明": "第三方appid"
  },
  {
    "参数名": "appsecret",
    "类型": "string",
    "必填": "是",
    "说明": "第三方appsecret"
  }
]
```

## 3. 返回参数

### 返回体 `Response Payload`

```json
[
  {
    "参数名": "errcode",
    "类型": "number",
    "说明": "错误码"
  },
  {
    "参数名": "errmsg",
    "类型": "string",
    "说明": "错误信息"
  }
]
```

## 4. 注意事项

1、该接口通过appsecret调用，解决了accesss_token耗尽无法调用[重置 API 调用次数](api_clearquota)的情况

2、每个帐号每月使用[重置 API 调用次数](api_clearquota) 与本接口共10次清零操作机会，清零生效一次即用掉一次机会；

3、由于指标计算方法或统计时间差异，实时调用量数据可能会出现误差，一般在1%以内

4、该接口仅支持POST调用

5、该接口可以代公众号/小程序用户重置接口调用次数，appid参数需要是已授权的账号。

## 5. 代码示例

### 5.1 重置第三方账号API调用次数

请求示例

POST  https://api.weixin.qq.com/cgi-bin/component/clear_quota/v2
```json
{
    "component_appid":"wxxxxxxxxxxxxxxxxxx",
    "appsecret":"xxxxxxxxxxxxxxxxxxxxxxxx"
}
```

返回示例

```json
{
  "errcode": 0,
  "errmsg": "ok"
}
```

### 5.2 代公众号/小程序重置API调用次数

请求示例

POST  https://api.weixin.qq.com/cgi-bin/component/clear_quota/v2
```json
{
    "appid":"wxxxxxxxxxxxxxxxxxx",
    "component_appid":"wxxxxxxxxxxxxxxxxxx",
    "appsecret":"xxxxxxxxxxxxxxxxxxxxxxxx"
}
```

返回示例

```json
{
  "errcode": 0,
  "errmsg": "ok"
}
```

## 6. 错误码

以下是本接口的错误码列表，其他错误码可参考 [通用错误码](/doc/oplatform/developers/errCode/README.md)；调用接口遇到报错，可使用官方提供的 [API 诊断工具](https://developers.weixin.qq.com/console/devtools/debug?utm_source=api_errcode) 辅助定位和分析问题。

```json
[
  {
    "错误码": "-1",
    "错误描述": "system error",
    "解决方案": "系统繁忙，此时请开发者稍候再试"
  },
  {
    "错误码": "40013",
    "错误描述": "invalid appid",
    "解决方案": "不合法的 AppID ，请开发者检查 AppID 的正确性，避免异常字符，注意大小写"
  },
  {
    "错误码": "41002",
    "错误描述": "appid missing",
    "解决方案": "缺少 appid 参数"
  },
  {
    "错误码": "41004",
    "错误描述": "appsecret missing",
    "解决方案": "缺少 secret 参数"
  },
  {
    "错误码": "43007",
    "错误描述": "require bizuser authorize",
    "解决方案": "检查授权关系"
  },
  {
    "错误码": "48006",
    "错误描述": "forbid to clear quota because of reaching the limit",
    "解决方案": "api 禁止清零调用次数，因为清零次数达到上限"
  }
]
```

## 7. 适用范围

本接口支持「第三方平台」账号类型调用。其他账号类型如无特殊说明，均不可调用。
