
# 查询模板
#### 功能介绍
根据客户提供的过滤条件查询智能信息模板列表。
#### URI
GET /v1/aim/templates
表1Query参数 
| 参数             | 是否必选 | 参数类型             | 描述                                                                                                                     |
|:---|:---|:---|:---|
| tpl_id         | 否    | String           | 智能信息模板ID。 最小长度：**0** 最大长度：**36**                                                                                       |
| tpl_name       | 否    | String           | 智能信息模板名称。 最小长度：**0** 最大长度：**100**                                                                                      |
| tpl_type       | 否    | String           | 模板分类。 - public：查公共模板 - private：查个人模板 说明： 不传查全部模板。                                                                      |
| factory_type   | 否    | Array of strings | 厂商类型。 - HUAWEI：华为 - XIAOMI：小米 - OPPO：OPPO - MEIZU：魅族 - VIVO：VIVO - SAMSUNG：三星 数组长度：**0 - 6**                           |
| has_param      | 否    | Boolean          | 模板是否携带参数。 - true：是 - false：否                                                                                           |
| begin_time     | 否    | String           | 模板创建开始时间。样例：2019-10-12T07:20:50Z。 说明： begin_time和end_time必须全部为空或全部不为空，并且begin_time不能大于end_time。 最小长度：**0** 最大长度：**30** |
| end_time       | 否    | String           | 模板创建结束时间。样例：2019-10-12T07:20:50Z。 说明： begin_time和end_time必须全部为空或全部不为空，并且begin_time不能大于end_time。 最小长度：**0** 最大长度：**30** |
| is_only_status | 否    | Boolean          | 响应里只返回状态信息，不返回pages和params。 - false：默认值，返回全量信息 - true：只返回状态信息                                                          |
| offset         | 否    | Integer          | 偏移量，表示从此偏移量开始查询，offset大于等于0。 最小值：**0** 最大值：**1000000** 缺省值：**0**                                                       |
| limit          | 否    | Integer          | 每页显示的条目数量。 最小值：**1** 最大值：**100** 缺省值：**20**                                                                            |
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                       |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 用户Token。通过调用IAM服务获取用户Token接口获取（响应消息头中X-Subject-Token的值）。 |
   
#### 响应参数
**状态码： 200**
表3响应Body参数 
| 参数        | 参数类型                                                                    | 描述    |
|:---|:---|:---|
| templates | Array of [AIMTemplate] objects | 模板列表。 |
| page_info | [Page] object                         | 分页信息。 |
   
 表4AIMTemplate 
| 参数            | 参数类型                                                                                | 描述                                      |
|:---|:---|:---|
| tpl_id        | String                                                                              | 智能信息模板ID。 说明： 智能信息平台生成的模板ID，由9位数字组成。    |
| tpl_name      | String                                                                              | 智能信息模板名称。                               |
| scene         | String                                                                              | 场景类型。                                   |
| tpl_state     | Integer                                                                             | 模板状态。 - 0：禁用 - 1：启用                     |
| disable_desc  | String                                                                              | 禁用原因。                                   |
| disable_time  | String                                                                              | 禁用时间。样例：1970-01-01T00:00 :00Z。          |
| audit_state   | Integer                                                                             | 审核状态。 - 0：未提交 - 1：审核中 - 2：审核通过 - 3：审核失败 |
| audit_desc    | String                                                                              | 审批信息。                                   |
| description   | String                                                                              | 短信示例。 说明： 对应创建个人模板API中的入参sms_example。   |
| creation_time | String                                                                              | 创建时间。样例为：1970-01-01T00:00:00Z。          |
| update_time   | String                                                                              | 更新时间。样例为：1970-01-01T00:00:00Z。          |
| pages         | String                                                                              | 模板页面HTML，JSON格式。                        |
| params        | Array of [AIMTemplateParams] objects | 模板动态参数列表。                               |
| factory_info  | Array of [FactoryInfo] objects             | 支持厂商列表。                                 |
| match_type    | Integer                                                                             | 模板类型。 - 1：短链解析模板 - 2：文本识别模板 - 4：一体化模板   |
| card_id       | String                                                                              | 布局类型。                                   |
| sub_type      | Integer                                                                             | 版式子类型。                                  |
| preview_url   | String                                                                              | 模板二维码预览地址。                              |
   
 表5AIMTemplateParams 
| 参数              | 参数类型    | 描述                                  |
|:---|:---|:---|
| type            | String  | 参数类型。 - string：文本 - integer：数字      |
| name            | String  | 参数名称。                               |
| has_length      | Boolean | 动态参数是否长度限制。 - false：不可设置 - true：可设置 |
| fix_length      | Integer | 固定长度。                               |
| length_restrict | Boolean | 长度限制。                               |
| min_length      | Integer | 最小长度。                               |
| max_length      | Integer | 最大长度。                               |
   
 表6FactoryInfo 
| 参数           | 参数类型    | 描述                          |
|:---|:---|:---|
| factory_type | String  | 厂商名称。                       |
| state        | Integer | 厂商状态。 - 0：禁用 - 1：启用 - 2：未启用 |
| version      | String  | 厂商版本。                       |
| tpl_id       | String  | 智能信息模板ID。                   |
   
 表7Page 
| 参数     | 参数类型    | 描述                           |
|:---|:---|:---|
| offset | Integer | 偏移量，表示从此偏移量开始查询，offset大于等于0。 |
| limit  | Integer | 每页显示的条目数量。                   |
| total  | Integer | 总条数。                         |
   
**状态码： 400**
表8响应Body参数 
| 参数            | 参数类型    | 描述                                       |
|:---|:---|:---|
| error_code    | String  | 结果状态码。                                   |
| error_msg     | String  | 结果详情。                                    |
| error_message | AnyType | 结果详情。 说明： 该字段在以后可能会废弃，建议使用error_msg字段对接。 |
   
**状态码： 500**
表9响应Body参数 
| 参数            | 参数类型    | 描述                                       |
|:---|:---|:---|
| error_code    | String  | 结果状态码。                                   |
| error_msg     | String  | 结果详情。                                    |
| error_message | AnyType | 结果详情。 说明： 该字段在以后可能会废弃，建议使用error_msg字段对接。 |
   
#### 请求示例
- 查询所有模板
  ```
  https://koomessage.myhuaweicloud.cn/v1/aim/templates
  ```
- 根据模板ID查询模板，模板ID为"600000001"。
  ```
  https://koomessage.myhuaweicloud.cn/v1/aim/templates?tpl_id=600000001
  ```
#### 响应示例
**状态码： 200**
返回信息。
```
{
  "templates" : [ {
    "tpl_id" : "600000001",
    "tpl_name" : "测试-中行签到",
    "scene" : "测试模板",
    "tpl_state" : 1,
    "disable_desc" : "",
    "disable_time" : "1970-01-01T00:00:00Z",
    "audit_state" : 2,
    "audit_desc" : "审核通过",
    "description" : "您有一条新消息，测试。",
    "creation_time" : "2022-05-23T17:49:00Z",
    "update_time" : "2022-05-23T19:29:14Z",
    "pages" : "[{\"typeIndex\":0,\"cardId\":\"com.hbm.redpacket\",\"style\":{\"width\":\"342px\",\"opacity\":1,\"height\":\"456px\"},\"label\":\"主页1\",\"tag\":\"page1\",\"content\":[{\"visible\":true,\"src\":\"https://aim6.oss-cn-beijing.aliyuncs.com/editor_file/redpacketBg.png\",\"h\":456,\"isBgimg\":true,\"type\":\"image\",\"skipReplaceSrc\":true,\"size\":0,\"borderRadius\":0,\"w\":342,\"x\":0,\"y\":0,\"notValid\":true,\"angle\":0,\"style\":{\"padding\":0,\"borderRadius\":0,\"borderWidth\":0,\"borderStyle\":\"none\"},\"z\":0,\"tag\":\"tg0.34403423289983026\",\"locked\":true,\"event\":{\"packageNames\":\"\",\"subject\":\"\",\"navType\":2,\"latitude\":\"\",\"description\":\"\",\"floorType\":0,\"txtButton\":\"\",\"body\":\"\",\"content\":\"\",\"target\":\"\",\"merchantName\":\"\",\"browserFloorUrl\":\"\",\"mode\":0,\"floorUrl\":\"\",\"copyType\":1,\"action\":\"\",\"longitude\":\"\"}},{\"serviceType\":0,\"visible\":false,\"src\":\"https://aim6.oss-cn-beijing.aliyuncs.com/editor_file/defaultImg/defaultImg2.jpg\",\"h\":23,\"type\":\"serviceNumber\",\"serviceName\":\"请选择服务号\",\"skipReplaceSrc\":true,\"borderRadius\":0,\"w\":342,\"x\":0,\"y\":348,\"angle\":0,\"style\":{\"padding\":0,\"borderRadius\":0,\"color\":\"#fff\",\"textAlign\":\"center\",\"borderWidth\":0,\"borderStyle\":\"none\"},\"z\":0,\"tag\":\"tg0.6574206986442455\",\"locked\":true,\"serviceID\":\"\"},{\"visible\":true,\"proportion\":[1,1],\"src\":\"https://aim6.oss-cn-beijing.aliyuncs.com/tpl_file/Montnets/E01/S01/Template/603264561/20220523174859881fILNZn.jpg\",\"bg\":{\"proportion\":[9,5],\"src\":\"https://aim6.oss-cn-beijing.aliyuncs.com/tpl_file/Montnets/E01/S01/Template/610579108/20220523174900022c8XeYT.jpg\",\"w\":342,\"h\":190},\"h\":70,\"type\":\"image\",\"oppobg\":{\"proportion\":[3,4],\"src\":\"https://aim6.oss-cn-beijing.aliyuncs.com/editor_file/redpacketBg-oppo.jpg\",\"w\":342,\"h\":456},\"passItem\":false,\"size\":91289,\"borderRadius\":0,\"w\":70,\"x\":136,\"width\":1024,\"y\":44,\"angle\":0,\"style\":{\"padding\":0,\"borderRadius\":\"70px\",\"borderWidth\":0,\"borderStyle\":\"none\"},\"z\":0,\"tag\":\"tg0.45509392249988934\",\"srcParam\":\"\",\"locked\":true,\"event\":{\"packageNames\":\"\",\"subject\":\"\",\"latitude\":\"\",\"navType\":2,\"floorType\":0,\"description\":\"\",\"txtButton\":\"\",\"body\":\"\",\"content\":\"\",\"browserFloorUrl\":\"\",\"merchantName\":\"\",\"target\":\"https://mbs.boc.cn/v/JzEZb\",\"mode\":0,\"floorUrl\":\"\",\"copyType\":1,\"action\":\"OPEN_BROWSER\",\"longitude\":\"\"},\"isBg\":0,\"height\":1024},{\"visible\":true,\"h\":23,\"title\":\"true\",\"type\":\"text\",\"textMaxlength\":36,\"passItem\":false,\"textOPPOLength\":24,\"w\":342,\"x\":0,\"y\":128,\"angle\":0,\"z\":2,\"style\":{\"backgroundColor\":\"transparent\",\"fontFamily\":\"微软雅黑\",\"color\":\"#ffffff\",\"textAlign\":\"center\",\"letterSpacing\":0,\"fontSize\":\"14px\",\"textDecoration\":\"none\",\"lineHeight\":1.5,\"boxSizing\":\"border-box\",\"fontStyle\":\"normal\",\"opacity\":1,\"fontWeight\":\"700\"},\"tag\":\"tg0.42763825585357296\",\"text\":\"中行送您最高20元话费券\",\"placeholder\":\"编辑名称，最多显示18个字\",\"locked\":true,\"event\":{}},{\"visible\":true,\"h\":40,\"type\":\"text\",\"textMaxlength\":22,\"passItem\":false,\"w\":342,\"x\":0,\"y\":196,\"angle\":0,\"z\":2,\"style\":{\"backgroundColor\":\"transparent\",\"fontFamily\":\"微软雅黑\",\"color\":\"#ffffff\",\"textAlign\":\"center\",\"letterSpacing\":0,\"fontSize\":\"24px\",\"textDecoration\":\"none\",\"lineHeight\":1.5,\"boxSizing\":\"border-box\",\"fontStyle\":\"normal\",\"opacity\":1,\"fontWeight\":\"700\"},\"divTextAreaTitle\":\"true\",\"tag\":\"tg0.04688490460114725\",\"text\":\"话费+签到双重福利红包\",\"placeholder\":\"编辑文本，最多11个字\",\"locked\":true,\"event\":{}},{\"visible\":true,\"h\":69,\"type\":\"text\",\"textMaxlength\":108,\"passItem\":false,\"textOPPOLength\":76,\"w\":280,\"x\":31,\"y\":236,\"angle\":0,\"z\":2,\"style\":{\"backgroundColor\":\"transparent\",\"fontFamily\":\"微软雅黑\",\"color\":\"#ffffff\",\"textAlign\":\"center\",\"letterSpacing\":0,\"fontSize\":\"14px\",\"textDecoration\":\"none\",\"lineHeight\":1.5,\"boxSizing\":\"border-box\",\"fontStyle\":\"normal\",\"opacity\":1,\"fontWeight\":\"700\"},\"divTextAreaContent\":\"true\",\"tag\":\"tg0.7916708792687688\",\"text\":\"登录手机银行首页-搜索-热门活动参加签到活动赢最高20元话费券！-测试\",\"placeholder\":\"编辑文本，最多显示54个字。编辑文本，最多显示54个字。编辑文本，最多显示54个字。\",\"locked\":true,\"event\":{}},{\"visible\":true,\"pageTitle\":\"\",\"h\":40,\"type\":\"button\",\"target\":\"\",\"passItem\":false,\"w\":202,\"x\":70,\"y\":381,\"angle\":0,\"action\":\"OPEN_APP\",\"z\":3,\"style\":{\"padding\":0,\"backgroundColor\":\"#ff9800\",\"color\":\"#ffffff\",\"textAlign\":\"center\",\"letterSpacing\":0,\"textDecoration\":\"none\",\"boxSizing\":\"border-box\",\"fontStyle\":\"normal\",\"fontFamily\":\"微软雅黑\",\"borderRadius\":\"32px\",\"borderWidth\":0,\"fontSize\":\"16px\",\"opacity\":1,\"borderStyle\":\"none\",\"fontWeight\":\"normal\"},\"tag\":\"tg0.6309152129863151\",\"text\":\"立即领取\",\"locked\":true,\"thirdService\":\"\",\"event\":{\"packageNames\":\"\",\"subject\":\"\",\"navType\":2,\"latitude\":\"\",\"description\":\"\",\"floorType\":0,\"txtButton\":\"\",\"body\":\"\",\"content\":\"\",\"target\":\"https://mbs.boc.cn/v/JzEZb\",\"merchantName\":\"\",\"browserFloorUrl\":\"\",\"mode\":0,\"floorUrl\":\"\",\"copyType\":1,\"action\":\"OPEN_BROWSER\",\"longitude\":\"\"},\"maxLength\":9}]}]",
    "params" : [ ],
    "factory_info" : [ {
      "factory_type" : "HuaWei",
      "state" : 1,
      "version" : null
    }, {
      "factory_type" : "XiaoMi",
      "state" : 1,
      "version" : null
    }, {
      "factory_type" : "OPPO",
      "state" : 1,
      "version" : null
    } ]
  } ],
  "page_info" : {
    "offset" : 0,
    "limit" : 1,
    "total" : 10
  }
}
```
#### 状态码
| 状态码 | 描述    |
|:---|:---|
| 200 | 返回信息。 |
| 400 | 非法参数。 |
| 500 | 内部错误。 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-koomessage/ErrorCode.html)。
