

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 AWS 最终用户消息 SMS AWS CLI 中的创建注册
<a name="registrations-sms-cli"></a>

以下部分举例说明了如何使用 AWS CLI创建、填写注册内容和提交注册。有关如何使用 python 或 shell 脚本创建和提交免费电话号码注册的示例，请参阅[自动向 AWS 最终用户发送消息美国免费电话](https://aws.amazon.com/blogs/messaging-and-targeting/automate-us-tfn-registrations/)号码注册。注册要求因国家/地区而异，有些是单页表单，而其他如 10DLC，则可能需要按特定顺序提交多份表单。请查看[具体的注册说明](registrations.md)，了解提交顺序，以及是否需要上传任何支持文档，例如授权书（LOA）。

## 背景
<a name="registrations-sms-cli-contextual"></a>

某些国家/地区要求您注册公司身份，以便购买发起身份，并审核您发送给其所在国家/地区收件人的消息。
+ 您提供的注册信息可能会由第三方审核。第三方因国家而异，但可能是执行审核的政府监管机构或移动运营商。
+ 第三方公司审核您的注册所需的时间因注册类型而异。

## 先决条件
<a name="registrations-sms-cli-prerequisite"></a>

在开始之前，您必须：
+ 安装和配置 AWS CLI，请参阅[AWS Command Line Interface 用户指南](https://docs.aws.amazon.com/cli/latest/userguide/)[中的配置 AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)。
+ [有权](security-iam.md)在目标区域使用 AWS 最终用户消息 SMS。 AWS 账户 
+ 注册**AssociationBehavior**指定了何时可以将注册与原始身份关联并与原始身份解除关联的顺序，请参阅。[SupportedAssociation](https://docs.aws.amazon.com/pinpoint/latest/apireference_smsvoicev2/API_SupportedAssociation.html)
  + `ASSOCIATE_BEFORE_SUBMIT`：提交注册时必须提供发起身份。
  + `ASSOCIATE_ON_APPROVAL`：适用于所有发件人 ID 注册。注册获得批准后，系统将自动预置发件人 ID。
  + `ASSOCIATE_AFTER_COMPLETE`：适用于电话号码注册，即您必须先完成注册，然后再关联一个或多个电话号码。
**重要**  
购买发起身份后，无论注册状态如何，您都需要为其付费，详情请参阅 [AWS 终端用户消息发送服务定价](https://aws.amazon.com/end-user-messaging/pricing/)。  
提交注册后，在第三方完成审核并向您返回结果之前，您无法对注册进行任何更改，也无法取消注册与任何资源的关联。

以下是注册相关的其他资源：
+ [How to Build a Compliant SMS Opt-In Process](https://aws.amazon.com/blogs/messaging-and-targeting/how-to-build-a-compliant-sms-opt-in-process-with-amazon-pinpoint/)
+ [10DLC 注册使用 AWS 最终用户消息发送短信的最佳实践](https://aws.amazon.com/blogs/messaging-and-targeting/10dlc-registration-best-practices-to-send-sms-with-amazon-pinpoint/)

# 创建注册（创建注册命令 AWS CLI ）
<a name="registrations-sms-cli-create"></a>

使用 [create-registration](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/create-registration.html) 命令创建新的空白注册。该**RegistrationType**参数决定要创建的注册类型。如果您不知道要创建的注册类型的值，请使用[describe-registration-type-definitions](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/describe-registration-type-definitions.html)命令检索所有注册类型的列表。

以下示例说明了如何创建免费电话号码注册表。

```
$ aws pinpoint-sms-voice-v2 create-registration --registration-type US_TOLL_FREE_REGISTRATION --tags "Key=Name,Value=MyTFNRegistration"
```

成功完成后，保存的值 **RegistrationId**，因为其他命令需要使用该值。

**注意**  
要在注册中添加一个易记名称，必须添加一个标签，其中**键**设置为 **Name**，**值**设置为要使用的易记名称。  
您也可以为资源添加标签以进行计费，请参阅[针对账单为资源添加标签](sms-billing-tag.md)。

下面的示例显示了 `describe-registration-type-definitions` 命令的部分输出。因为设置**AssociationBehavior**为免费电话号码`ASSOCIATE_BEFORE_SUBMIT`，必须先购买免费电话号码并将其与注册关联，然后才能提交注册以供批准。有关**AssociationBehavior**和的更多信息 **DisassociationBehavior**，请参阅[SupportedAssociation](https://docs.aws.amazon.com/pinpoint/latest/apireference_smsvoicev2/API_SupportedAssociation.html)。

```
{
    "RegistrationTypeDefinitions": [
        {
            "RegistrationType": "US_TOLL_FREE_REGISTRATION",
            "SupportedAssociations": [
                {
                    "ResourceType": "TOLL_FREE",
                    "IsoCountryCode": "US",
                    "AssociationBehavior": "ASSOCIATE_BEFORE_SUBMIT",
                    "DisassociationBehavior": "DISASSOCIATE_ALL_CLOSES_REGISTRATION"
                }
            ],
            "DisplayHints": {
                "Title": "US toll-free number registration"
            }
        },
...
```

# 获取字段定义（describe-registration-field-definitions AWS CLI 命令）
<a name="registrations-sms-cli-field-definitions-get"></a>

接下来，您需要获取每个字段的定义，以了解相关要求，例如字段允许的最大字符数。

每个注册表都分为多个部分，而每个部分包含一个或多个字段。使用[describe-registration-field-definitions](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/describe-registration-field-definitions.html)命令检索注册的所有章节和字段定义。稍后需要**FieldPath**为每个字段使用才能设置其值。还用于确定字段**FieldRequirement**是必填字段还是可选字段。

以下示例展示了如何检索免费电话号码注册表的字段定义。

```
$ aws pinpoint-sms-voice-v2 describe-registration-field-definitions --registration-type  US_TOLL_FREE_REGISTRATION
```

下面是该命令的部分输出：

```
{
    "RegistrationFieldDefinitions": [
        {
            "SectionPath": "companyInfo",
            "FieldPath": "companyInfo.companyName",
            "FieldType": "TEXT",
            "FieldRequirement": "REQUIRED",
            "TextValidation": {
                "MinLength": 1,
                "MaxLength": 100,
                "Pattern": "^(?=\\s*\\S)[\\s\\S]+$"
            },
            "DisplayHints": {
                "Title": "Company name",
                "ShortDescription": "Legal name which your company is registered under.",
                "ExampleTextValue": "Example Corp"
            }
        },
...
```

# 创建附件（create-registration-attachment AWS CLI 命令）
<a name="registrations-sms-cli-attachments"></a>

根据注册要求，您可能需要填写并附上授权书、用户选择加入工作流程证明或其他类型的必要文档。请查看[具体的注册说明](registrations.md)，以了解详情并下载相关表单。

使用[create-registration-attachment](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/create-registration-attachment.html)命令创建注册附件。您可以将文件上传到 Amazon S3 存储桶并使用 URL，也可以将文档作为命令的一部分附上。使用**AttachmentUrl**或 **AttachmentBody**，如果同时指定了两者，则返回异常。最大文件大小为 500 KB，有效的文件扩展名包括.pdf、.jpeg 和 .png。

以下示例说明如何创建注册附件和使用**AttachmentUrl**参数。

```
$ aws pinpoint-sms-voice-v2 create-registration-attachment --attachment-url s3://BucketName/FileName
```

成功完成后，该命令将返回其他命令所需的 **RegistrationAttachmentID**。

 有关 Amazon S3 命令（例如创建存储桶或上传文件）的更多信息，请参阅[通过 AWS CLI 使用高级别（s3）命令](https://docs.aws.amazon.com/cli/latest/userguide/cli-services-s3-commands.html)。

# 设置字段定义值（put-registration-field-value AWS CLI 命令）
<a name="registrations-sms-cli-field-definitions-set"></a>

接下来，您需要为“获取字段定义”**步骤返回的所有必填字段添加值，包括您创建的任何附件。我们建议您根据使用案例，同时填写所有可选字段。字段是必填字段或可选字段，具体取决于**FieldRequirement**值。使用[put-registration-field-value](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/put-registration-field-value.html)命令设置字段值。
+ 以下示例展示了如何为公司名称这类文本字段添加值。

  ```
  $ aws pinpoint-sms-voice-v2 put-registration-field-value --registration-id RegID --field-path companyInfo.companyName --text-value AnyCompany
  ```

  在上述命令中，请替换以下内容：
  + *RegID*替换为从 “*创建注册” 步骤返回的注册* ID。
  + *AnyCompany*替换为贵公司的名称。
+ 以下示例展示了如何为选择字段添加值。

  ```
  $ aws pinpoint-sms-voice-v2 put-registration-field-value --registration-id RegID --field-path messagingUseCase.monthlyMessageVolume --text-choices SelectValue
  ```

  在上述命令中，请替换以下内容：
  + *RegID*替换为从 “*创建注册” 步骤返回的注册* ID。
  + *SelectValue*替换为该字段的其中一个选项值。

    使用[describe-registration-field-definitions](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/describe-registration-field-definitions.html)命令仅获取一个字段的选项：

    ```
    aws pinpoint-sms-voice-v2 describe-registration-field-definitions --registration-type  US_TOLL_FREE_REGISTRATION --field-paths messagingUseCase.monthlyMessageVolume
    ```

    ```
    {
        "RegistrationFieldDefinitions": [
            {
                "SectionPath": "messagingUseCase",
                "FieldPath": "messagingUseCase.monthlyMessageVolume",
                "FieldType": "SELECT",
                "FieldRequirement": "REQUIRED",
                "SelectValidation": {
                    "MinChoices": 1,
                    "MaxChoices": 1,
                    "Options": [
                        "10",
                        "100",
                        "1,000",
                        "10,000",
                        "100,000",
                        "250,000",
                        "500,000",
                        "750,000",
                        "1,000,000",
                        "5,000,000",
                        "10,000,000+"
                    ]
                },
                "DisplayHints": {
                    "Title": "Monthly SMS volume",
                    "ShortDescription": "Estimated number of SMS messages which will be sent from this toll-free number each month."
                }
            }
        ],
        "RegistrationType": "US_TOLL_FREE_REGISTRATION"
    }
    ```
+ 以下示例展示了如何添加附件。

  ```
  $ aws pinpoint-sms-voice-v2 put-registration-field-value --registration-id RegID --field-path messagingUseCase.optInImage --registration-attachment-id RegistrationAttachmentID
  ```

  在上述命令中，请替换以下内容：
  + *RegID*替换为从 “*创建注册” 步骤返回的注册* ID。
  + *RegistrationAttachmentID*替换为从 “*创建附件” 步骤返回的注册附件* ID。

# 请求来源身份（request-phone-number AWS CLI 命令）
<a name="registrations-sms-cli-request-phone-number"></a>

**注意**  
购买发起身份后，无论注册状态如何，您都需要为其付费，详情请参阅 [AWS 终端用户消息发送服务定价](https://aws.amazon.com/end-user-messaging/pricing/)。  
如果注册**AssociationBehavior**是，`ASSOCIATE_AFTER_COMPLETE`则在提交注册并获得批准之前，您无需购买或关联原始身份。

现在，您需要申请一个发起身份，该身份稍后将与注册相关联。此示例说明如何使用[request-phone-number](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/request-phone-number.html)命令通过请求免费电话号码。 AWS CLI使用[request-sender-id](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/request-sender-id.html)来请求发件人 ID。

```
$ aws pinpoint-sms-voice-v2 request-phone-number --iso-country-code US --message-type TRANSACTIONAL --number-capabilities SMS --number-type TOLL_FREE
```

命令成功执行后，将返回电话号码的唯一标识符，而该标识符用于将电话号码与注册相关联。

# 将资源与注册关联（create-registration-association AWS CLI 命令）
<a name="registrations-sms-cli-associate-phone-number"></a>

**注意**  
如果注册**AssociationBehavior**是，`ASSOCIATE_AFTER_COMPLETE`则在提交注册并获得批准之前，您无需购买或关联原始身份。

要将来源身份与注册关联，请使用[create-registration-association](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/create-registration-association.html) AWS CLI 命令。

```
$ aws pinpoint-sms-voice-v2 create-registration-association --registration-id RegID --resource-id PhoneNumberID
```

在上述命令中，请替换以下内容：
+ *RegID*替换为从 “*创建注册” 步骤返回的注册* ID。
+ *PhoneNumberID*替换为 “*申请来源身份” 步骤中返回的电话号码 ID。*

**注意**  
此命令用于将任何适用的资源与注册关联。例如，它可以用来将 10DLC 活动注册与 10DLC 品牌注册相关联。

# 提交您的注册（submit-registration-version AWS CLI 命令）
<a name="registrations-sms-cli-submit"></a>

提交注册后，您将无法对其进行任何更改。提交前，请务必仔细检查您的注册信息，确保所有数据均正确无误。

**重要**  
提交注册后，在第三方完成审核并向您返回结果之前，您无法对注册进行任何更改，也无法取消注册与任何资源的关联。

要 AWS CLI 使用[submit-registration-version](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/create-registration-association.html)命令提交注册。

```
$ aws pinpoint-sms-voice-v2 submit-registration-version --registration-id RegID
```

在上述命令中，请替换以下内容：
+ *RegID*替换为从 “*创建注册” 步骤返回的注册* ID。

## 检查您的注册状态（describe-registrations 命令 AWS CLI ）
<a name="registrations-sms-cli_next_steps"></a>

提交注册后，您可以使用 [describe-registrations](https://docs.aws.amazon.com/cli/latest/reference/pinpoint-sms-voice-v2/describe-registrations.html) 命令或[控制台](registrations-status.md)检查其状态。

如果注册**AssociationBehavior**是，`ASSOCIATE_AFTER_COMPLETE`则在注册状态设置为 “**完成**” 后，您可以购买原始身份并将其与注册关联。

如果注册状态更改为 **REQUIRES\$1UPDATES**，则可以查找并[编辑标记的字段](registrations-edit.md)，然后重新提交注册。有关注册被拒原因的列表，请参阅[Gen-AI 对注册的反馈](registrations-genai-feedback.md)。如果您在拒绝注册 支持 时需要帮助，可以[开票](registrations-request-support.md)。