Create and Delete Event Subscriptions

📘

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 requests and responses that show how to use Buy with Prime Event interface to create and delete event subscriptions.

To learn how to call the Buy with Prime API, see Call the Buy with Prime API.

For troubleshooting, see Troubleshoot Events.


Create an event subscription

The following example uses the createEventSubscription mutation to subscribe to the REFUND_REQUESTED event.

For a list of event types, see Event Types.

After successful completion of this request, you will see a new partner event source in the Amazon EventBridge console.

Request
// GraphQL mutation

mutation{
  createEventSubscription(
    input:{
      destination:{
        eventBridge:{
         region:"us-east-1"
         partnerEventSource:{ 
            account:"example-aws-account-id"
            name:"example-partner-event-source-name"
          }
        }
      }
      eventType:"REFUND_REQUESTED"
    }
  ){
    subscriptionId
  }
}
Response
{
  "data": {
    "createEventSubscription": {
      "subscriptionId": "example-subscription-id"
    }
  }
}

Delete an event subscription

The following example uses the deleteEventSubscription mutation to delete the subscription with the specified subscriptionId.

Request
// GraphQL mutation

mutation{
  deleteEventSubscription(subscriptionId:"example-subscription-id"){
    subscriptionId
  }
}
Response
{
  "data": {
    "deleteEventSubscription": {
      "subscriptionId": "example-subscription-id"
    }
  }
}

Related topics