# 创建订阅 设置并配置数据收集器后,创建订阅以将您的主机托管数据传输到该数据收集器。 > **注意** > > 您只能在贵组织中使用一种通信渠道类型。例如,如果您使用AWS物联网核心渠道创建订阅,则无法使用其他渠道类型创建其他订阅。 > > 单个订阅仅允许一个频道。 ## 先决条件[​](#先决条件 "直接链接至先决条件") * 在调用订阅管理API之前,请参阅[与收集器集成](https://docs.equinix.com/zh-Hans/smart-view/sv-api/integrating-with-collector.md),为您的数据设置和配置目标。 * 提交您的用户凭据,客户端ID和客户端机密以进行OAuth2验证。有关如何向Equinix API验证请求的更多信息,请参阅[API验证](https://docs.equinix.com/zh-Hans/equinix-api/api-authentication.md)。 ## AWS IoT Core[​](#aws-iot-core "直接链接至AWS IoT Core") 要创建订阅以将数据发送至Amazon IoT Core,请向端点发送`POST`请求[`/smartview/v2/streaming/subscriptions`](https://docs.equinix.com/zh-Hans/api-catalog/smartviewv2/streaming-subscription-api/createsubscription.md)。在请求正文中,在中指定`channelType`AS`AWS_IOT_CORE`及其URL`awsIotCoreChannelConfiguration`。 指定应在对象中接收哪些数据`messageType`。 cURL 请求示例: ``` curl -X  POST 'https://api.equinix.com/smartview/v2/streaming/subscriptions' -H 'content-type: application/json' -H 'authorization: Bearer ' -d '{     "messageType": {         "asset": [],         "environmental": [             {                 "accountNumber": "116710",                 "ibx": [                     "LD9"                 ],                 "level": [                     "CAGE"                 ]             }         ],         "power": [],         "meteredPower": [],         "systemAlert": [],         "customAlert": []     },     "channel": {         "channelType": "AWS_IOT_CORE",         "awsIotCoreChannelConfiguration": {             "url": "https://.amazonaws.com"         }     } }'  ``` 可用选项的完整列表`messageType`,请参阅《[API参考手册》](https://docs.equinix.com/zh-Hans/api-catalog/smartviewv2/streaming-subscription-api/createsubscription.md)。 ## Webhook[​](#webhook "直接链接至Webhook") 要创建将数据发送至webhook的订阅,请向端点发送`POST`请求[`/smartview/v2/streaming/subscriptions`](https://docs.equinix.com/zh-Hans/api-catalog/smartviewv2/streaming-subscription-api/createsubscription.md)。在请求正文中,在中指定`channelType`AS`WEBHOOK`及其配置`webhookChannelConfiguration`。 指定应在对象中接收哪些数据`messageType`。 cURL 请求示例: ``` curl -X  POST 'https://api.equinix.com/smartview/v2/streaming/subscriptions' -H 'content-type: application/json' -H 'authorization: Bearer ' -d '{     "messageType": {         "asset": [],         "environmental": [             {                 "accountNumber": "116710",                 "ibx": [                     "LD9"                 ],                 "level": [                     "CAGE"                 ]             }         ],         "power": [],         "meteredPower": [],         "systemAlert": [],         "customAlert": []     },     "channel": {         "channelType": "WEBHOOK",         "webhookChannelConfiguration": { "sslCertificate": "ZkFzZLY1IGRpY31kZXI=...", "url": "https://.com", "numberOfRetries": 1, "numberOfConcurrentCalls": 20, "batchSize": 5 },     } }'  ``` webhook配置选项和可用选项列表`messageType`,请参阅[API参考手册](https://docs.equinix.com/zh-Hans/api-catalog/smartviewv2/streaming-subscription-api/createsubscription.md)。 ## Equinix REST API[​](#equinix-rest-api "直接链接至Equinix REST API") 要创建订阅以从Equinix API获取您的数据,请向端点发送`POST`请求[`/smartview/v2/streaming/subscriptions`](https://docs.equinix.com/zh-Hans/api-catalog/smartviewv2/streaming-subscription-api/createsubscription.md)。在请求正文中,指定`channelType`AS`REST`。 指定应在对象中接收哪些数据`messageType`。 cURL 请求示例: ``` curl -X  POST 'https://api.equinix.com/smartview/v2/streaming/subscriptions' -H 'content-type: application/json' -H 'authorization: Bearer ' -d '{     "messageType": {         "asset": [],         "environmental": [             {                 "accountNumber": "116710",                 "ibx": [                     "LD9"                 ],                 "level": [                     "CAGE"                 ]             }         ],         "power": [],         "meteredPower": [],         "systemAlert": [],         "customAlert": []     },     channel": { "channelType": "REST", "restChannelConfiguration": { } } }'  ``` 可用选项的完整列表`messageType`,请参阅《[API参考手册》](https://docs.equinix.com/zh-Hans/api-catalog/smartviewv2/streaming-subscription-api/createsubscription.md)。 示例回答: ``` HTTP/1.1 201 Created Location: /smartview/v2/streaming/subscriptions/0f6bdb36-e130-4924-b038-ee1785fad999 ``` `Location`响应中的标题包含使用实时源所需的订阅ID。