createPurchaseGroup

📘

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 a PurchaseGroup which represents a bundle of products.

ℹ️

Required scope(s)

View & Edit Catalog Data

Response

Return type CreatePurchaseGroupResponse

Arguments

ArgumentDescription
input (CreatePurchaseGroupInput required)

Specifies the input fields required to create a purchase group.

Examples


Create Purchase Group With Purchase Group Members By Sku

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          externalId: "example-externalId"
        }
      },
      members:[
        {
          product: {
            sku: "example-sku-1"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            sku: "example-sku-2"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "data": {
    "createPurchaseGroup": {
      "id": "01234567abcdef"
    }
  }
}

Create Purchase Group With Purchase Group Members By Mixed Input

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          externalId: "example-externalId"
        }
      },
      members:[
        {
          product: {
            externalId: "example-externalId-1"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            sku: "example-sku-2"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "data": {
    "createPurchaseGroup": {
      "id": "01234567abcdef"
    }
  }
}

Create Purchase Group With Purchase Group Members By External Id

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          externalId: "example-externalId"
        }
      },
      members:[
        {
          product: {
            externalId: "example-external-id-1"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            externalId: "example-external-id-2"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "data": {
    "createPurchaseGroup": {
      "id": "01234567abcdef"
    }
  }
}

Create Purchase Group With Purchase Group Members By Amazon Sku

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          externalId: "example-externalId"
        }
      },
      members:[
        {
          product: {
            amazonSku: { value: "example-amazon-sku-1" }
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            amazonSku: { value: "example-amazon-sku-2" }
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "data": {
    "createPurchaseGroup": {
      "id": "01234567abcdef"
    }
  }
}

Create Purchase Group With New Item

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct:{
        representativeProduct: {
            externalId: "product-externalId"
            amazonSku: {
              value: "product-amazon-sku"
            }
            sku: "product-sku"
            offerPrime: true
            productDetailPageUrl: "https://example.com/products/my-product"
            image: {
              sourceUrl: "https://example.com/products/my-product.jpg"
            }
        }
      },
      members:[
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            productId: "ghijkl01234567"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "data": {
    "createPurchaseGroup": {
      "id": "01234567abcdef"
    }
  }
}

Create Purchase Group With Existing Item By Sku

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          sku: "example-sku"
        }
      },
      members:[
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            productId: "ghijkl01234567"
          },
          memberAmount: {
            value: 2,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "data": {
    "createPurchaseGroup": {
      "id": "01234567abcdef"
    }
  }
}

Create Purchase Group With Existing Item By Product Id

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          productId: "01234567abcdef"
        }
      },
      members:[
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            productId: "ghijkl01234567"
          },
          memberAmount: {
            value: 2,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "data": {
    "createPurchaseGroup": {
      "id": "01234567abcdef"
    }
  }
}

Create Purchase Group With Existing Item By External Id

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          externalId: "example-externalId"
        }
      },
      members:[
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            productId: "ghijkl01234567"
          },
          memberAmount: {
           value: 2,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "data": {
    "createPurchaseGroup": {
      "id": "01234567abcdef"
    }
  }
}

Create Purchase Group With Existing Item By Amazon Sku

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          amazonSku: { value: "example-amazon-sku" }
        }
      },
      members:[
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            productId: "ghijkl01234567"
          },
          memberAmount: {
            value: 2,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "data": {
    "createPurchaseGroup": {
      "id": "01234567abcdef"
    }
  }
}

Purchase Group Member Is Representative Product

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          productId: "01234567abcdef"
        }
      },
      members:[
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 3,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

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": [
        "createPurchaseGroup"
      ],
      "extensions": {
        "classification": {
          "type": "ValidationError",
          "code": "InvalidProductGroupMember",
          "details": {
            "message": "Purchase group member cannot be a representative product.",
            "product": {
              "productId": {
                "type": "PRODUCT_ID",
                "value": "abcdef01234567",
                "marketplaceId": null
              }
            }
          },
          "errorType": "ValidationException",
          "errorCode": 400
        }
      }
    }
  ],
  "data": {
    "createPurchaseGroup": null
  }
}

Missing Representative Item Input

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {},
      members:[
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            productId: "ghijkl01234567"
          },
          memberAmount: {
            value: 2,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "errors": [
    {
      "message": "Input request is not valid, the following issues were encountered: [Input object on field /createPurchaseGroup/input/representativeProduct must contain exactly one field]",
      "locations": [],
      "path": [
        "createPurchaseGroup"
      ],
      "extensions": {
        "classification": {
          "type": "ValidationError",
          "code": "ValidationError",
          "details": {},
          "errorType": "ValidationException",
          "errorCode": 400
        }
      }
    }
  ],
  "data": {
    "createPurchaseGroup": null
  }
}

Missing Purchase Group Members

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          productId: "01234567abcdef"
        }
      },
      members:[]
    }
  ) {
    id
  }
}

Response

{
  "errors": [
    {
      "message": "Input request is not valid, the following issues were encountered: [/createPurchaseGroup/input/members size must be between 1 and 10]",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createPurchaseGroup"
      ],
      "extensions": {
        "classification": {
          "type": "ValidationError",
          "code": "ValidationError",
          "details": {},
          "errorType": "ValidationException",
          "errorCode": 400
        }
      }
    }
  ],
  "data": {
    "createPurchaseGroup": null
  }
}

Duplicate Purchase Group Members

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
            productId: "01234567abcdef"
        }
      },
      members:[
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 1,
            unit: "UNIT"
          }
        },
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 3,
            unit: "UNIT"
          }
        },
      ]
    }
  ) {
    id
  }
}

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": [
        "createPurchaseGroup"
      ],
      "extensions": {
        "classification": {
          "type": "ValidationError",
          "code": "InvalidProductGroupMember",
          "details": {
            "message": "Purchase group members cannot have duplicate products.",
            "product": {
              "productId": {
                "type": "PRODUCT_ID",
                "value": "abcdef01234567",
                "marketplaceId": null
              }
            }
          },
          "errorType": "ValidationException",
          "errorCode": 400
        }
      }
    }
  ],
  "data": {
    "createPurchaseGroup": null
  }
}

Create With New Representative Item Already Registered

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          productId: "01234567abcdef"
        }
      },
      members:[
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 3,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

Response

{
  "errors": [
    {
      "message": "Input request is not valid, the following issues were encountered: [The value for identity SKU is already used by another item, The value for identity MSKU is already used by another item, The value for identity EXTERNAL_ID is already used by another item]",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createPurchaseGroup"
      ],
      "extensions": {
        "classification": {
          "type": "ValidationError",
          "code": "DuplicateSku",
          "details": {},
          "errorType": "ValidationException",
          "errorCode": 400
        }
      }
    }
  ],
  "data": {
    "createPurchaseGroup": null
  }
}

Create With Existing Representative Item Already Registered

Request

mutation createPurchaseGroup {
  createPurchaseGroup(
    input: {
      representativeProduct: {
        representativeProductId: {
          productId: "01234567abcdef"
        }
      },
      members:[
        {
          product: {
            productId: "abcdef01234567"
          },
          memberAmount: {
            value: 3,
            unit: "UNIT"
          }
        }
      ]
    }
  ) {
    id
  }
}

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": [
        "createPurchaseGroup"
      ],
      "extensions": {
        "classification": {
          "type": "ValidationError",
          "code": "InvalidRepresentativeProduct",
          "details": {
            "message": "The representativeProductId is already associated with a purchase group."
          },
          "errorType": "ValidationException",
          "errorCode": 400
        }
      }
    }
  ],
  "data": {
    "createPurchaseGroup": null
  }
}