> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ycloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 复制验证码认证

> 使用包含所需模板和验证流程的复制验证码认证体验。

复制验证码认证允许客户从 WhatsApp 复制验证码并将其输入到您的应用程序中。

<Frame caption="The customer copies the code, then enters it in your application. The code and expiry shown are demonstration values.">
  <img src="https://mintcdn.com/lchnan/gXEJIQXV2JH2VUQJ/product-assets/english-help-2026-09-22/meta-authentication-copy-code-annotated.svg?fit=max&auto=format&n=gXEJIQXV2JH2VUQJ&q=85&s=285ea260055d40a8647623d797848f19" alt="带有“复制验证码”按钮指示的 Meta 认证示例。" width={360} data-path="product-assets/english-help-2026-09-22/meta-authentication-copy-code-annotated.svg" />
</Frame>

来源：[Meta 官方示例](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/authentication-templates/authentication-templates/)。

WhatsApp 负责发送验证码。您的后端负责创建、校验、使其过期，并决定所请求的操作是否已获得授权。

## 创建认证模板

1. 打开 **模板**，选择 WABA，然后创建一个 **身份验证** 模板。
2. 选择复制验证码选项。
3. 决定是否包含安全建议和过期提示。
4. 设置与您预期的验证策略相匹配的过期提示。
5. 提交模板并确认目标语言的审核已通过。

认证使用规定的消息内容。请勿添加促销内容、媒体页眉或任意网站按钮将其变成通用消息。

如需通过 API 创建，请使用带有 `otp_type: "COPY_CODE"` 的 OTP 按钮。这与在 [优惠券模板](/zh/documentation/whatsapp-business-platform/messaging/message-templates/coupon-code-templates) 中使用的 `COPY_CODE` 促销按钮不同。

## 设计请求到验证的流程

1. 客户在您的应用程序中针对特定操作请求验证码。
2. 您的后端生成一个短期的单次有效验证码并将其与该请求绑定。
3. 您的系统将审核通过的模板发送到确认的目的地。
4. 客户复制或输入验证码。
5. 您的后端验证该请求、验证码、有效期和尝试次数限制。
6. 只有后端检查成功才算完成认证。

在验证码输入界面说明验证码发送到了何处。提供可控的重新发送选项以及修改号码的方法。请勿通过过于具体的错误消息泄露无关人员的账户是否存在。

## 在两个位置发送相同的验证码

发送认证消息时会在消息正文和 OTP 按钮的 URL 参数中使用验证码。这些值必须一致。

仅展示 **模板组件** 的示例（包含虚构验证码）：

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
[
  {
    "type": "body",
    "parameters": [{ "type": "text", "text": "123456" }]
  },
  {
    "type": "button",
    "sub_type": "url",
    "index": 0,
    "parameters": [{ "type": "text", "text": "123456" }]
  }
]
```

请勿将此 OTP URL 参数替换为营销用的 `coupon_code` 参数。完整的请求请参考 [发送 WhatsApp 消息](/zh/api-reference/guides/whatsapp-platform/send-whatsapp-message)，并避免在日志中记录真实验证码。

<a id="limitations" />

## 对齐三项过期控制设置

后端验证码过期时间、模板中显示的过期提示以及消息投递生存时间（TTL）是独立的控制项。设置提示并不会配置您的后端。

对于 5 分钟的验证流程，请在服务器端强制执行 5 分钟限制，显示相匹配的提示，并选择适当的投递有效期以避免已经失效的验证码在很久之后才送达。有关当前的 TTL 范围和默认值，请参阅 [认证模板](/zh/documentation/whatsapp-business-platform/messaging/message-templates/authentication-message-templates/index)。

## 测试失败路径

测试有效验证码、错误验证码、过期验证码、成功后重复使用、连续多次重发、更改手机号以及延迟投递等情况。确定新请求是否会使旧验证码失效，并向客户明确此行为。

在 iOS 26 及更高版本上，Meta 记载了自 2026 年 6 月 15 日起生效的来自 WhatsApp 推送通知的原生键盘建议功能。这与 Android 一键式集成相互独立，并且不能替代后端验证。

消息已送达或已读并不能作为认证成功的证明。

来源：[Meta 认证模板](https://developers.facebook.com/docs/whatsapp/business-management-api/authentication-templates/) 和 [YCloud 模板管理](/zh/api-reference/guides/whatsapp-platform/manage-whatsapp-templates)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.