{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/zh/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Webhook"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"webhook","__idx":0},"children":["Webhook"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["云手机或云浏览器的操作一旦得到最终结果，MoreLogin 就会向你自己的 HTTPS 地址 POST 一个 JSON 事件，你不必再轮询结果。每个团队只保存一个回调地址，Local API 与 Open API 写的是同一份记录。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"配置回调地址","__idx":1},"children":["配置回调地址"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["两个入口提供同一个操作。Open API："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST \"https://api.morelogin.com/webhook/config\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -d '{\n    \"callbackUrl\": \"https://example.com/morelogin/webhook\",\n    \"enabled\": true\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Local API："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST \"http://127.0.0.1:40000/api/webhook/config\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"callbackUrl\": \"https://example.com/morelogin/webhook\",\n    \"enabled\": true\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Local API 这条路由由桌面客户端提供，因此需要 MoreLogin 客户端 v2.66.0 或更高版本。Open API 入口不依赖客户端。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["teamId"]}," 不会从请求中读取。每次调用配置的都是服务端上下文所属的团队，因此你无法把其他团队的事件指向自己的地址。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["地址必须是 HTTPS、1 到 1024 个字符，带主机名，不含用户信息与片段，端口合法。它解析到的每个地址都必须是公网可路由的：localhost、内网、链路本地、CGNAT、云元数据、协议保留、文档示例与 6to4 等范围会被 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/api-reference/getting-started/error-codes"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["41001"]}]}," 拒绝。实际投递建连时会再校验一次，因此某个域名若之后解析到内网范围，只会导致该次投递失败，而不会打到你的内网。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["保存是按团队的 upsert，因此同样的请求体发两次没有副作用。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"关闭投递","__idx":2},"children":["关闭投递"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enabled: false"]}," 会保留已存的地址并停止创建新事件。已排队的事件会被逐条取消，取消发生在每个事件下次被授权的时刻，且仅当配置那时仍处于停用状态——所以如果你很快重新启用，排队中的事件会继续投递，而不会被丢弃。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"一次投递长什么样","__idx":3},"children":["一次投递长什么样"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["每次投递都是带以下请求头的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST"]},"："]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"请求头"},"children":["请求头"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"值"},"children":["值"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Content-Type"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["application/json"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["User-Agent"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MoreLogin-Webhook/1.0"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-Webhook-Event-Id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["与正文中的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventId"]}," 相同"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-Webhook-Event-Type"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["与正文中的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventType"]}," 相同"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["这两个 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-Webhook-*"]}," 请求头刻意与正文字段重复，这样路由或队列就能直接按它们分发，不必解析 JSON。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"eventId\": \"c7f3a2b10d8e4f6a9c1b2d3e4f5a6b7c\",\n  \"eventType\": \"cloud_phone.power_off\",\n  \"eventTime\": \"1787241600000\",\n  \"data\": {\n    \"teamId\": \"10001\",\n    \"cloudPhoneId\": \"20001\",\n    \"reason\": \"MONEY_SAVING\"\n  },\n  \"result\": {\n    \"success\": true,\n    \"code\": \"0\",\n    \"message\": null\n  }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"字段"},"children":["字段"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"说明"},"children":["说明"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventId"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["唯一事件 ID。同一事件的重试与内部重放都复用它，因此它就是幂等键"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventType"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["稳定的事件名称，取值见下表"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventTime"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["最终结果发生的时间，Unix 毫秒时间戳。",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["以字符串发送"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data.teamId"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["拥有该资源的团队。",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["以字符串发送"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data.cloudPhoneId"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["该事件对应的云手机。",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["以字符串发送"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data.cloudBrowserId"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["该事件对应的云浏览器环境。",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["以字符串发送"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data.runId"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["该事件对应的云浏览器运行实例"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data.reason"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["仅在 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_phone.power_off"]}," 与 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_browser.stop"]}," 上出现"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result.success"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["该操作最终是否成功"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result.code"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["成功时为 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0"]},"；否则是与语言无关的稳定业务错误码"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result.message"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["成功时为 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]},"；否则是按团队语言给出的说明，缺失时降级为 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["en-US"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["所有数字型标识和 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventTime"]}," 都以 JSON 字符串到达，与 API 其余部分一致——参见 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/api-reference/getting-started/response-format"},"children":["通用响应格式"]},"。请按字符串解析而不是按数字，否则 64 位 ID 会丢精度。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"事件","__idx":4},"children":["事件"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"eventType"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventType"]}]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"它报告的最终结果"},"children":["它报告的最终结果"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_phone.power_on"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["开机成功或失败"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_phone.power_off"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["关机成功。关机失败不产生事件"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_phone.restart"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["重启成功或失败"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_phone.reset"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["重置成功或失败"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_phone.new_machine"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["一键新机成功或失败"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_browser.start"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["云浏览器开启成功或失败"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_browser.stop"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["云浏览器每一次关闭尝试，无论成功与否"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["云手机事件携带 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["teamId"]}," 与 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloudPhoneId"]},"。云浏览器事件携带 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["teamId"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloudBrowserId"]}," 与 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["runId"]},"。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["开机、重启、重置与一键新机只有在供应商回调成功且本地同步已提交后才报告 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["success: true"]},"。开机计费失败，或异步代理检测失败并完成失败收尾时，都报告开机失败，且",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["不会"]},"另外产生关机事件。安装预设应用、清理过期文件等推迟执行的任务不改变该结果。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["若关机操作打断了开机过程，本次尝试不产生开机事件；随后真正关机成功时仍会产生独立的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_phone.power_off"]},"。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"停止原因","__idx":5},"children":["停止原因"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_phone.power_off"]}," 会在 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data.reason"]}," 中给出："]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"取值"},"children":["取值"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"含义"},"children":["含义"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["NORMAL"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["普通关机"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MONEY_SAVING"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["省钱模式"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OTHER"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["欠费、到期、运维或其他原因"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloud_browser.stop"]}," 会在 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data.reason"]}," 中给出："]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"取值"},"children":["取值"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"含义"},"children":["含义"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["NORMAL"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["普通关闭"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MONEY_SAVING"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["省钱模式"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ENERGY_SAVING"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["节能模式"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["BROWSER_EXITED"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["浏览器异常退出"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OTHER"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["其他原因"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["内部归档失败只影响 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result"]},"，绝不覆盖关闭流程开始时固化的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["reason"]},"。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"投递重试与顺序","__idx":6},"children":["投递、重试与顺序"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["任何 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["2xx"]}," 都算投递成功。其他任何状态码，以及连接超时、读取超时和网络错误，都算失败。连接超时为 5 秒，读取超时为 30 秒。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["投递失败后最多重试 6 次，间隔依次为 10 秒、30 秒、60 秒、3 分钟、10 分钟和 30 分钟。也就是单个事件最多 7 次请求。第 6 次重试仍失败后，该事件不再自动重试。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["同一台云手机、或同一个云浏览器的事件，按创建顺序逐个投递。不同资源之间并行投递，因此不要假设它们之间有任何先后顺序。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["同一事件的重试始终复用相同的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventId"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventTime"]}," 和请求正文。在网络或服务恢复的极端场景下，同一事件可能被投递多次且这些值保持不变，因此请",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["按 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventId"]}," 去重"]},"。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["对云浏览器关闭来说，一次关闭尝试恰好产生一个事件。之后的人工重试、人工强制释放，或系统发起的强制释放都属于新操作，会得到新的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventId"]},"。两次尝试绝不会被合并成一个事件。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["云手机操作通过供应商任务 ID、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["traceId"]}," 或稳定的业务时间来识别。三者都不存在时，服务会生成一个 UUID 并把当前的最终回调视为一次新操作，因此你会收到新的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventId"]},"，而不会让两次不同的操作被合并成一个。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"编写接收端","__idx":7},"children":["编写接收端"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["存下事件后就尽快返回 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["2xx"]},"，真正的处理放到异步。响应正文会被忽略，而处理缓慢会耗掉你 30 秒的读取预算，即使你已经收到了事件，它也会被推入重试队列。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["按 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eventId"]}," 去重。遇到重复请直接视为已处理，而不要重复执行副作用。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["不要因为请求打到了你的地址就把正文当作可信输入。本期不对回调签名，因此任何知道你地址的人都能向它发送请求。请使用难以猜测的地址，并且在执行代价较大的动作之前，先通过 API 确认状态——例如云手机用 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/api-reference/cloud-phone/open-api"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/info"]}]},"，云浏览器运行实例用 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudbrowser/page"]},"。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result.code"]}," 使用与同步接口相同的业务错误码，因此失败可以在 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/api-reference/getting-started/error-codes"},"children":["错误码"]}," 中查到。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result.message"]}," 是给人看的字符串，措辞与语言都可能变化；请按 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result.success"]}," 和 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result.code"]}," 分支，绝不要按 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result.message"]}," 分支。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["每个事件的机器可读契约，包括 schema 与逐事件示例，随共享资源规格一起发布，见 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/api-reference/shared-resources/open-api"},"children":["Shared Resources Open API"]},"。"]}]},"headings":[{"value":"Webhook","id":"webhook","depth":1},{"value":"配置回调地址","id":"配置回调地址","depth":2},{"value":"关闭投递","id":"关闭投递","depth":3},{"value":"一次投递长什么样","id":"一次投递长什么样","depth":2},{"value":"事件","id":"事件","depth":2},{"value":"停止原因","id":"停止原因","depth":3},{"value":"投递、重试与顺序","id":"投递重试与顺序","depth":2},{"value":"编写接收端","id":"编写接收端","depth":2}],"frontmatter":{"seo":{"title":"Webhook"}},"lastModified":"2026-09-03T02:52:33.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/zh/api-reference/getting-started/webhooks","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}