createEventSubscription
Version 2024-11-01
Important
The Buy with Prime API is offered as a preview and might change as we receive feedback and iterate on the interfaces. We are sharing this early documentation to help you learn about the Buy with Prime API as we write and iterate on the content.
Overview
Create an event subscription to receive an eventType.
Response
Return type CreateEventSubscriptionResponse
Arguments
Argument | Description |
---|---|
input (CreateEventSubscriptionInput required) | Input parameters used when creating an event subscription |
Examples
Create Webhook Event Subscription With Inline Auth Config Input
Request
mutation {
createEventSubscription(
input: {
destination: {
webhook: {
url: "https://webhook-endpoint.com",
method: POST,
authConfig: {
oAuthConfig: {
clientParameters: {
clientId: "client_id"
clientSecret: "client_secret"
},
authEndpoint: "https://auth-endpoint.com",
httpMethod: POST
}
}
}
}
eventType: "BUYABILITY_CHANGED"
}
) {
subscriptionId
}
}
Response
{
"data": {
"createEventSubscription": {
"subscriptionId": "8e5da864-34ee-461d-9d76-0babcef14677"
}
}
}
Create Webhook Event Subscription With Auth Profile Id Input
Request
mutation {
createEventSubscription(
input: {
destination: {
webhook: {
url: "https://webhook-endpoint.com",
method: POST,
authProfileId: "auth-profile-id"
}
}
eventType: "BUYABILITY_CHANGED"
}
) {
subscriptionId
}
}
Response
{
"data": {
"createEventSubscription": {
"subscriptionId": "8e5da864-34ee-461d-9d76-0babcef14677"
}
}
}
Create Webhook Event Subscription Input
Request
mutation {
createEventSubscription(
input: {
destination: {
webhook: {
url: "https://webhook-endpoint.com",
method: POST
}
}
eventType: "BUYABILITY_CHANGED"
}
) {
subscriptionId
}
}
Response
{
"data": {
"createEventSubscription": {
"subscriptionId": "8e5da864-34ee-461d-9d76-0babcef14677"
}
}
}
Create Event Subscription With Event Bridge Input
Request
mutation {
createEventSubscription(
input: {
destination: {
eventBridge: {
partnerEventSource: {
account: "919191919191",
name: "BuyWithPrimeEventSource"
}
region: "us-east-1"
}
}
eventType: "BUYABILITY_CHANGED"
}
) {
subscriptionId
}
}
Response
{
"data": {
"createEventSubscription": {
"subscriptionId": "8e5da864-34ee-461d-9d76-0babcef14677"
}
}
}
Create Webhook Event Subscription With Invalid Auth Profile Id
Request
mutation {
createEventSubscription(
input: {
destination: {
webhook: {
url: "https://webhook-endpoint.com",
method: POST,
authProfileId: "invalid-auth-profile-id"
}
}
eventType: "BUYABILITY_CHANGED"
}
) {
subscriptionId
}
}
Response
{
"errors": [
{
"message": "Input request is not valid. Retrying the same request is not likely to succeed. An example could be query or argument value is not correct or valid.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createEventSubscription"
],
"extensions": {
"classification": {
"type": "ValidationError",
"code": "UnspecifiedError",
"details": {},
"errorType": "ValidationException",
"errorCode": 400
}
}
}
],
"data": null
}
Create Event Subscription With Event Bridge Input With Invalid Region
Request
mutation {
createEventSubscription(
input: {
destination: {
eventBridge: {
partnerEventSource: {
account: "919191919191",
name: "BuyWithPrimeEventSource"
}
region: "invalidRegion"
}
}
eventType: "BUYABILITY_CHANGED"
}
) {
subscriptionId
}
}
Response
{
"errors": [
{
"message": "Input request is not valid, the following issues were encountered: [/createEventSubscription/input/destination/eventBridge/region must match \"^(us(-gov)?|ap|ca|cn|eu|sa|af)-(central|(north|south)?(east|west)?)-[0-9]$\"]",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createEventSubscription"
],
"extensions": {
"classification": {
"type": "ValidationError",
"code": "ValidationError",
"details": {},
"errorType": "ValidationException",
"errorCode": 400
}
}
}
],
"data": null
}
Create Event Subscription With Event Bridge Input With Invalid Event Type
Request
mutation {
createEventSubscription(
input: {
destination: {
eventBridge: {
partnerEventSource: {
account: "919191919191",
name: "BuyWithPrimeEventSource"
}
region: "us-east-1"
}
}
eventType: "INVALID_EVENT"
}
) {
subscriptionId
}
}
Response
{
"errors": [
{
"message": "You do not have sufficient access to perform this action.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createEventSubscription"
],
"extensions": {
"classification": {
"type": "AccessDeniedError",
"errorType": "AccessDeniedException",
"errorCode": 403
}
}
}
],
"data": null
}
Updated 17 days ago