

**支援終止通知：**2026 年 10 月 30 日， AWS 將結束對 Amazon Pinpoint 的支援。2026 年 10 月 30 日之後，您將無法再存取 Amazon Pinpoint 主控台或 Amazon Pinpoint 資源 (端點、區段、行銷活動、旅程和分析)。如需詳細資訊，請參閱 [Amazon Pinpoint 終止支援](https://docs.aws.amazon.com/console/pinpoint/migration-guide)。**注意：**與 SMS、語音、行動推播、OTP 和電話號碼驗證相關的 APIs 不受此變更影響，並受 AWS 最終使用者傳訊支援。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 以程式設計方式從 Amazon Pinpoint 刪除端點
<a name="audience-define-remove"></a>

端點代表聯絡您的其中一個客戶的單一方法。每個端點可以是指客戶的電子郵件地址、行動裝置識別符、電話號碼，或是可以接收所傳送訊息的其他目的地類型。在許多轄區，這類資訊可能視為個人所有。若不想再傳訊給特定目的地 (例如無法連接目的地，或客戶關閉帳戶)，可以刪除端點。

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

以下範例說明如何刪除端點。

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

透過 AWS CLI執行命令，可以使用 Amazon Pinpoint。

**Example Delete Endpoint 命令**  
若要刪除端點，請使用 [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 Endpoint 請求**  
若要刪除端點，請向[端點](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 定義。

------