
# 订阅
#### 场景描述
第三方业务客户端调用该接口向呼叫中心CTI平台发起订阅任务注册请求，以便第三方业务可以接收到呼叫中心CTI平台向业务客户端上报的事件通知。
![](https://support.huaweicloud.com/api-ccfs-cec/public_sys-resources/note_3.0-zh-cn.png)
- 需要在WAS上的订阅服务器管理中，配置上CC-Gateway的地址。
- 单次调用成功，即"retcode"为 "0"后，可调用握手接口保持订阅状态。
 
#### 接口方法
该接口仅支持POST方法，不支持GET、PUT和DELETE等方法。
#### 接口URI
https://IP:Port/agentgateway/resource/config/subscribe/register
#### 日志中的方法名
register
#### 请求消息
- 消息头
  表1消息头参数说明 
  | 序号 | 名称           | 参数类型   | 是否必选 | 说明                                                                                                                             |
  |:---|:---|:---|:---|:---|
  | 1  | Content-Type | string | True | 消息主体编码方式，缺省值：application/json;charset=UTF-8                                                                                    |
  | 2  | Guid         | string | True | Guid的取值为[C5 智能辅助类接口鉴权方式](https://support.huaweicloud.com/api-ccfs-cec/cec_07_1009.html#ZH-CN_TOPIC_0000002489461260)接口返回的guid。 |
     
  
- 消息体
  表2消息体参数说明 
  | 序号 | 名称                 | 参数类型    | 是否必选  | 说明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
  |:---|:---|:---|:---|:---|
  | 1  | subscribeType      | string  | True  | 订阅类型。 1：识别。 其他保留。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
  | 2  | serviceToken       | string  | False | 鉴权token，第三方业务负责生成，例如：3320EA\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*36ED638 最大长度256字符。 在后续调用[握手(扩展)](https://support.huaweicloud.com/api-ccfs-cec/cec_07_1113.html#ZH-CN_TOPIC_0000002489461312)和[识别结果通知](https://support.huaweicloud.com/api-ccfs-cec/cec_07_1114.html#ZH-CN_TOPIC_0000002521741085)接口时，需要传递该参数。                                                                                                                                                                                                         |
  | 3  | serviceCallBackUri | string  | True  | 事件通知回调地址。 最大长度200字符。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
  | 4  | nlpFlag            | boolean | True  | 是否使用语义智能分析，取值范围： - true：使用语义智能分析，需要联系运维人员在CC-Gateway的basic.properties文件中配置CC-Gateway回调地址  - false：不使用语义智能分析   |
  | 5  | flowAccessCode     | string  | False | 智能IVR机器人接入码，新增机器人时返回的接入码。仅当nlpFlag设置为true时需要配置。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
     
  
 
#### 响应消息
表3消息体参数说明 
| 序号 | 名称      | 参数类型   | 说明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|:---|:---|:---|:---|
| 1  | message | string | 返回消息                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| 2  | retcode | string | 操作的结果原因码。 取值类型为整数。 - 0：成功  - 非0：失败，具体见"[错误码定义](https://support.huaweicloud.com/api-ccfs-cec/cec_07_1119.html#ZH-CN_TOPIC_0000002521621095)"章节   |
| 3  | result  | object | 返回结果。该对象参数说明请参见[表4]。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
   
 表4result对象 
| 序号  | 名称       | 参数类型   | 说明                                        |
|:---|:---|:---|:---|
| 3.1 | serverId | string | 业务客户端向CTI平台发起订阅注册请求且成功注册后，CTI平台返回的订阅任务编号。 |
   
#### 报文样例
- 消息头
  ```
  Content-Type:application/json;charset=UTF-8
  Guid：xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.AgentGateway1
  ```
  
- 请求参数
  ```
  {
      "subscribeType": "1",
      "serviceToken": "3320EA1E***********8E336ED638",
      "serviceCallBackUri": "https://10.10.10.1:8080/rest/cc-ai/nlrresult",
      "nlpFlag": "true",
      "flowAccessCode": "801166010768953344"
  }
  ```
  
- 响应参数
  ```
  {
      "result": {
          "serverId": "20140414172508-001-00101"
      },
      "message": "success",
      "retcode": "0"
  }
  ```
  
 
