

**终止支持通知：** AWS 将于 2026 年 10 月 30 日终止对亚马逊 Pinpoint 的支持。2026 年 10 月 30 日之后，您将不再能够访问 Amazon Pinpoint 控制台或 Amazon Pinpoint 资源（端点、分段、活动、旅程和分析）。有关更多信息，请参阅 [Amazon Pinpoint 终止支持](https://docs.aws.amazon.com/console/pinpoint/migration-guide)。**注意：** APIs 与短信相关、语音、移动推送、OTP 和电话号码验证不受此更改的影响，并受 AWS 最终用户消息的支持。

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

# 以编程方式从 Amazon Pinpoint 中删除端点
<a name="audience-define-remove"></a>

一个端点表示联系您的某个客户的单个方法。每个端点都可以引用客户的电子邮件地址、移动设备标识符、电话号码或您可以向其发送消息的其他目标类型。在许多司法管辖区内，此类信息可能被视为个人数据。当您不想再向某个目标发送消息时（例如目标变得不可访问或客户关闭了账户时），可以删除该端点。

## 示例
<a name="audience-define-remove-endpoints"></a>

以下示例说明如何删除端点。

------
#### [ AWS CLI ]

可以通过在 AWS CLI 中运行命令来使用 Amazon Pinpoint。

**Example 删除端点命令**  
要删除端点，请使用 [https://docs.aws.amazon.com/cli/latest/reference/pinpoint/delete-endpoint.html](https://docs.aws.amazon.com/cli/latest/reference/pinpoint/delete-endpoint.html) 命令：  

```
$ aws pinpoint delete-endpoint \
> --application-id application-id \
> --endpoint-id endpoint-id
```
其中：  
+ *application-id* 是包含端点的 Amazon Pinpoint 项目的 ID。
+ *endpoint-id* 是要删除的终端节点的 ID。
对此命令的响应是您删除的端点的 JSON 定义。

------
#### [ 适用于 Java 的 AWS SDK ]

您可以通过使用 适用于 Java 的 AWS SDK 提供的客户端在您的 Java 应用程序中使用 Amazon Pinpoint API。

**Example 代码**  
要删除端点，请使用 `AmazonPinpoint` 客户端的 `deleteEndpoint` 方法。提供 `DeleteEndpointRequest` 对象作为方法参数：  

```
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.pinpoint.PinpointClient;
import software.amazon.awssdk.services.pinpoint.model.DeleteEndpointRequest;
import software.amazon.awssdk.services.pinpoint.model.DeleteEndpointResponse;
import software.amazon.awssdk.services.pinpoint.model.PinpointException;
```

```
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.pinpoint.PinpointClient;
import software.amazon.awssdk.services.pinpoint.model.DeleteEndpointRequest;
import software.amazon.awssdk.services.pinpoint.model.DeleteEndpointResponse;
import software.amazon.awssdk.services.pinpoint.model.PinpointException;

/**
 * Before running this Java V2 code example, set up your development
 * environment, including your credentials.
 *
 * For more information, see the following documentation topic:
 *
 * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
 */
public class DeleteEndpoint {
    public static void main(String[] args) {
        final String usage = """

                Usage:   <appName> <endpointId >

                Where:
                  appId - The id of the application to delete.
                  endpointId - The id of the endpoint to delete.
                """;

        if (args.length != 2) {
            System.out.println(usage);
            System.exit(1);
        }

        String appId = args[0];
        String endpointId = args[1];
        System.out.println("Deleting an endpoint with id: " + endpointId);
        PinpointClient pinpoint = PinpointClient.builder()
                .region(Region.US_EAST_1)
                .build();

        deletePinEncpoint(pinpoint, appId, endpointId);
        pinpoint.close();
    }

    public static void deletePinEncpoint(PinpointClient pinpoint, String appId, String endpointId) {
        try {
            DeleteEndpointRequest appRequest = DeleteEndpointRequest.builder()
                    .applicationId(appId)
                    .endpointId(endpointId)
                    .build();

            DeleteEndpointResponse result = pinpoint.deleteEndpoint(appRequest);
            String id = result.endpointResponse().id();
            System.out.println("The deleted endpoint id  " + id);

        } catch (PinpointException e) {
            System.err.println(e.awsErrorDetails().errorMessage());
            System.exit(1);
        }
        System.out.println("Done");
    }
}
```

有关完整的 SDK 示例，请参阅 [GitHub](https://github.com/) 上的 [DeleteEndpoint.java](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javav2/example_code/pinpoint/src/main/java/com/example/pinpoint/DeleteEndpoint.java)。

------
#### [ HTTP ]

可以通过直接向 REST API 发出 HTTP 请求来使用 Amazon Pinpoint。

**Example DELETE 端点请求**  
要删除端点，请向[端点](https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-endpoints-endpoint-id.html)资源发出 `DELETE` 请求：  

```
DELETE /v1/apps/application-id/endpoints/endpoint-id HTTP/1.1
Host: pinpoint.us-east-1.amazonaws.com
Content-Type: application/json
Accept: application/json
Cache-Control: no-cache
```
其中：  
+ *application-id* 是包含端点的 Amazon Pinpoint 项目的 ID。
+ *endpoint-id* 是要删除的终端节点的 ID。
对此请求的响应是您删除的端点的 JSON 定义。

------