Create and Cancel Privacy Requests
Buy with Prime API is now available for early access
Sign up for early access to the Buy with Prime API using the 'Sign Up' button below. The API may change as Amazon receives feedback and iterates on it.
This topic contains examples of how to create and cancel privacy requests with Buy with Prime.
For details about privacy requests, see Privacy Interface. For steps to process privacy requests, see Steps to Process Privacy Requests.
Create a data retrieval request
To create a data retrieval request, you use the startPersonalDataRetrievalTask
mutation. In the request, you must provide the customer's email address.
You can optionally provide a clientToken
to serve as an idempotency key that ensures that multiple identical requests are only processed once with an eight-hour period. This is particularly useful in scenarios where network issues might cause you to need to retry a request. If you don’t provide a clientToken
, a default clientToken
is generated for each request.
Data retrieval tasks run immediately after they have been initiated and can't be cancelled.
The response to the data retrieval request contains a taskId
, which you can provide to the personalDataRetrievalTask
query if the customer later asks for an update on their data retrieval request before you receive a data retrieval event.
The following example shows how to submit a data retrieval request.
Request
// GraphQL mutation
mutation {
startPersonalDataRetrievalTask(input: {
dataSubject: {
type: SHOPPER
email: "[email protected]"
}
}) {
taskId
}
}
Response
{
"data": {
"startPersonalDataRetrievalTask": {
"taskId": "example-task-id"
}
}
}
Create a data deletion request
To create a data deletion request, you use the startPersonalDataDeletionTask
mutation. In the request, you must provide the customer's email address.
You can optionally provide a clientToken
to serve as an idempotency key that ensures that multiple identical requests are only processed once with an eight-hour period. This is particularly useful in scenarios where network issues might cause you to need to retry a request. If you don’t provide a clientToken
, a default clientToken
is generated for each request.
The response to the data deletion request contains a taskId
, which you can provide to the personalDataDeletionlTask
query if the customer later asks for an update on their data deletion request before you receive a data deletion event.
When you create a data deletion request, you can specify a holding period to initiate data deletion after a certain number of days. The holding period can range from 0 to 180 days. If you don't provide a holding period, the default value is 10 days. During the holding period, you can cancel the data deletion request by calling the cancelPersonalDataDeletionTask
mutation.
The data deletion request fails if the customer has any open Buy with Prime orders. If you subscribed to data deletion events, you receive a PERSONAL_DATA_DELETION_TASK_FAILED
event. In this case, you must resubmit the startPersonalDataDeletionTask
request after all orders for that customer are closed.
The following example shows a data deletion request with a holding period five days before the data should be deleted.
Request
// GraphQL mutation
mutation {
startPersonalDataDeletionTask(input: {
dataSubject: {
type: SHOPPER
email: "[email protected]"
}
holdingPeriod: 5
clientToken: "example-client-token"
}) {
taskId
}
}
Response
{
"data": {
"startPersonalDataDeletionTask": {
"taskId": "example-task-id"
}
}
}
Cancel a data deletion request
To cancel a data deletion request during the holding period that you specified when you created a data deletion request, you use the cancelPersonalDataDeletionTask
mutation. If the holding period has expired and the data deletion is in progress, this request fails.
The following example shows how to cancel a data deletion request.
Request
// GraphQL mutation
mutation {
cancelPersonalDataDeletionTask(input: {
taskId: "example-task-id"
}) {
taskId
}
}
Response
{
"data": {
"cancelPersonalDataDeletionTask": {
"taskId": "example-task-id"
}
}
}
Error Response (Request is In Progress)
{
"errors": [
{
"message": "The personalDataDeletionTask cannot be cancelled with a status of IN_PROGRESS.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"cancelPersonalDataDeletionTask"
],
"extensions": {
"classification": {
"type": "ValidationError",
"code": "CannotCancelPersonalDataDeletionTask",
"details": {
"message": "The personalDataDeletionTask cannot be cancelled with a status of IN_PROGRESS."
}
}
}
}
],
"data": {
"cancelPersonalDataDeletionTask": null
}
}
Related topics
Updated 16 days ago