

**支援終止通知：**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-endpoints"></a>

*端點*代表訊息的目的地，例如行動裝置、電話號碼或電子郵件地址。在您可以傳送訊息給您的對象的成員之前，您必須為該個人定義一或多個端點。

將端點加到 Amazon Pinpoint，端點會成長為受眾資料庫。這些資料包含：
+ 使用 Amazon Pinpoint API 加入或更新的端點。
+ 隨著使用者來到您的應用程式，您的用戶端程式碼新增或更新的端點。

定義端點時，您會指定*管道*和*地址*。管道是用來傳送訊息給端點的平台類型。管道的範例包含推送通知服務、簡訊或電子郵件。指定要傳送訊息給端點的位置，例如裝置字符、電話號碼或電子郵件地址。

若要新增關於您的對象的更多詳細資訊，您可以以自訂和標準屬性來豐富您的端點。這些屬性包括有關您的使用者、其偏好設定、裝置、其使用的用戶端版本或其位置的資料。新增此類型的資料到您的端點時，您可以：
+ 在 Amazon Pinpoint 主控台中檢視受眾相關圖表。
+ 根據端點屬性區隔您的對象，使得您可以將訊息傳送到適合的鎖定目標對象。
+ 透過整合將取代為使用者屬性值的訊息變數來個人化您的訊息。

如果您使用 Mobile SDKs 或 AWS Amplify JavaScript 程式庫整合 Amazon Pinpoint， AWS 則行動或 JavaScript 用戶端應用程式會自動註冊端點。用戶端會為每個新使用者註冊端點，並且為傳回的使用者更新端點。若要從行動裝置或 JavaScript 用戶端註冊端點，請參閱[在應用程式中註冊 Amazon Pinpoint 端點](integrate-endpoints.md)。

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

以下範例說明如何將端點加入 Amazon Pinpoint 專案。此端點代表位在西雅圖並使用 iPhone 的對象成員。您可以透過 Apple 推送通知服務 (APN) 傳送訊息給此人員。端點的地址為 APN 提供的裝置字符。

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

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

**Example Update Endpoint 命令**  
若要新增或更新端點，請使用 [update-endpoint](https://docs.aws.amazon.com/cli/latest/reference/pinpoint/update-endpoint.html) 命令：  

```
$ aws pinpoint update-endpoint \
> --application-id application-id \
> --endpoint-id endpoint-id \
> --endpoint-request file://endpoint-request-file.json
```
其中：  
+ *application-id* 是您要加入或更新端點的 Amazon Pinpoint 專案的 ID。
+ *example-endpoint* 是您要指派給新端點的 ID，或是您要更新的現有端點的 ID。
+ *endpoint-request-file.json* 是包含 `--endpoint-request` 參數輸入的本機 JSON 檔案的檔案路徑。

**Example 端點請求檔案**  
範例 `update-endpoint` 命令會使用 JSON 檔案做為 `--endpoint-request` 參數的引數。此檔案包含的端點定義類似以下：  

```
{
  "ChannelType": "APNS",
  "Address": "1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a8b9c0d1e2f",
  "Attributes": {
    "Interests": [
      "Technology",
      "Music",
      "Travel"
    ]
  },
  "Metrics": {
    "technology_interest_level": 9.0,
    "music_interest_level": 6.0,
    "travel_interest_level": 4.0
  },
  "Demographic": {
    "AppVersion": "1.0",
    "Make": "apple",
    "Model": "iPhone",
    "ModelVersion": "8",
    "Platform": "ios",
    "PlatformVersion": "11.3.1",
    "Timezone": "America/Los_Angeles"
  },
  "Location": {
    "Country": "US",
    "City": "Seattle",
    "PostalCode": "98121",
    "Latitude": 47.61,
    "Longitude": -122.33
  }
}
```
如需可用於定義端點的屬性，請參閱 *Amazon Pinpoint API 參考*中的 [EndpointRequest](https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-endpoints-endpoint-id.html#apps-application-id-endpoints-endpoint-id-schemas) 結構描述。

------
#### [ 適用於 Java 的 AWS SDK ]

使用 適用於 Java 的 AWS SDK提供的用戶端，可以在 Java 應用程式中使用 Amazon Pinpoint API。

**Example 代碼**  
若要加入端點，請初始化 [https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/pinpoint/model/EndpointRequest.html](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/pinpoint/model/EndpointRequest.html) 物件，然後傳遞給 `AmazonPinpoint` 用戶端的 [https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/pinpoint/model/UpdateEndpointRequest.html](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/pinpoint/model/UpdateEndpointRequest.html) 方法：  

```
import com.amazonaws.regions.Regions;
import com.amazonaws.services.pinpoint.AmazonPinpoint;
import com.amazonaws.services.pinpoint.AmazonPinpointClientBuilder;
import com.amazonaws.services.pinpoint.model.*;
import java.util.Arrays;

public class AddExampleEndpoint {

	public static void main(String[] args) {

		final String USAGE = "\n" +
				"AddExampleEndpoint - Adds an example endpoint to an Amazon Pinpoint application." +
				"Usage: AddExampleEndpoint <applicationId>" +
				"Where:\n" +
				"  applicationId - The ID of the Amazon Pinpoint application to add the example " +
				"endpoint to.";

		if (args.length < 1) {
			System.out.println(USAGE);
			System.exit(1);
		}

		String applicationId = args[0];

		// The device token assigned to the user's device by Apple Push Notification
		// service (APNs).
		String deviceToken = "1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a8b9c0d1e2f";

		// Initializes an endpoint definition with channel type and address.
		EndpointRequest wangXiulansIphoneEndpoint = new EndpointRequest()
				.withChannelType(ChannelType.APNS)
				.withAddress(deviceToken);

		// Adds custom attributes to the endpoint.
		wangXiulansIphoneEndpoint.addAttributesEntry("interests", Arrays.asList(
				"technology",
				"music",
				"travel"));

		// Adds custom metrics to the endpoint.
		wangXiulansIphoneEndpoint.addMetricsEntry("technology_interest_level", 9.0);
		wangXiulansIphoneEndpoint.addMetricsEntry("music_interest_level", 6.0);
		wangXiulansIphoneEndpoint.addMetricsEntry("travel_interest_level", 4.0);

		// Adds standard demographic attributes.
		wangXiulansIphoneEndpoint.setDemographic(new EndpointDemographic()
				.withAppVersion("1.0")
				.withMake("apple")
				.withModel("iPhone")
				.withModelVersion("8")
				.withPlatform("ios")
				.withPlatformVersion("11.3.1")
				.withTimezone("America/Los_Angeles"));

		// Adds standard location attributes.
		wangXiulansIphoneEndpoint.setLocation(new EndpointLocation()
				.withCountry("US")
				.withCity("Seattle")
				.withPostalCode("98121")
				.withLatitude(47.61)
				.withLongitude(-122.33));

		// Initializes the Amazon Pinpoint client.
		AmazonPinpoint pinpointClient = AmazonPinpointClientBuilder.standard()
				.withRegion(Regions.US_EAST_1).build();

		// Updates or creates the endpoint with Amazon Pinpoint.
		UpdateEndpointResult result = pinpointClient.updateEndpoint(new UpdateEndpointRequest()
				.withApplicationId(applicationId)
				.withEndpointId("example_endpoint")
				.withEndpointRequest(wangXiulansIphoneEndpoint));

		System.out.format("Update endpoint result: %s\n", result.getMessageBody().getMessage());

	}
}
```

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

對 REST API 直接提出 HTTP 請求，可以使用 Amazon Pinpoint。

**Example PUT Endpoint 請求**  
若要新增端點，請將 `PUT` 請求發出至位在以下 URI 的 [Endpoint](https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-endpoints-endpoint-id.html) 資源：  
`/v1/apps/application-id/endpoints/endpoint-id`  
其中：  
+ *application-id* 是您要加入或更新端點的 Amazon Pinpoint 專案的 ID。
+ *endpoint-id* 是您要指派給新端點的 ID，或是您要更新的現有端點的 ID。
在您的請求中，包括所需的標頭，並提供 [EndpointRequest](https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-endpoints-endpoint-id.html#apps-application-id-endpoints-endpoint-id-schemas) JSON 做為內文：  

```
PUT /v1/apps/application_id/endpoints/example_endpoint HTTP/1.1
Host: pinpoint.us-east-1.amazonaws.com
X-Amz-Date: 20180415T182538Z
Content-Type: application/json
Accept: application/json
X-Amz-Date: 20180428T004705Z
Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20180428/us-east-1/mobiletargeting/aws4_request, SignedHeaders=accept;content-length;content-type;host;x-amz-date, Signature=c25cbd6bf61bd3b3667c571ae764b9bf2d8af61b875cacced95d1e68d91b4170
Cache-Control: no-cache

{
  "ChannelType": "APNS",
  "Address": "1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a8b9c0d1e2f",
  "Attributes": {
    "Interests": [
      "Technology",
      "Music",
      "Travel"
    ]
  },
  "Metrics": {
    "technology_interest_level": 9.0,
    "music_interest_level": 6.0,
    "travel_interest_level": 4.0
  },
  "Demographic": {
    "AppVersion": "1.0",
    "Make": "apple",
    "Model": "iPhone",
    "ModelVersion": "8",
    "Platform": "ios",
    "PlatformVersion": "11.3.1",
    "Timezone": "America/Los_Angeles"
  },
  "Location": {
    "Country": "US",
    "City": "Seattle",
    "PostalCode": "98121",
    "Latitude": 47.61,
    "Longitude": -122.33
  }
}
```
如果您的請求成功，您會收到類似以下的回應：  

```
{
    "RequestID": "67e572ed-41d5-11e8-9dc5-db288f3cbb72",
    "Message": "Accepted"
}
```

------

## 相關資訊
<a name="audience-define-endpoints-related"></a>

如需 Amazon Pinpoint API 中端點資源的詳細資訊 (包括支援的 HTTP 方法和請求參數)，請參閱 *Amazon Pinpoint API 參考*中的[端點](https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-endpoints-endpoint-id.html)。

如需使用變數將訊息個人化的詳細資訊，請參閱 *Amazon Pinpoint 使用者指南*中的[訊息變數](https://docs.aws.amazon.com/pinpoint/latest/userguide/campaigns-message.html#campaigns-message-variables.html)。

如需端點適用之配額的相關資訊，例如您可指派的屬性數目，請參閱 [端點配額](quotas.md#quotas-endpoint)。