order
Version 2024-01-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
Returns a single order.
Required scope(s)
View Order Data
Response
Return type Order
Arguments
Argument | Description |
---|---|
orderId (String) | DeprecatedNo longer supported ID of the order to retrieve. |
orderIdentifier (OrderIdentifierInput) | Identifier of the order to retrieve |
Examples
Get Order With Specified Alias
Request
query order {
order(
orderIdentifier: {
orderAlias: { aliasType: "EXTERNAL_ID", aliasId: "example-alias-id" }
}
) {
id
lineItems {
id
quantity {
unit
amount
}
}
}
}
Response
{
"data": {
"order": {
"id": "example-order-id",
"lineItems": [
{
"id": "example-line-item-id",
"quantity": {
"unit": "ONE",
"amount": 1
}
}
]
}
}
}
Get Order With Single Field
Request
query order {
order(orderIdentifier: {orderId: "322-YYN9-93WX87"}) {
lineItems {
purchasedItem {
price {
currentPrice {
amount
}
}
}
}
}
}
Response
{
"data": {
"order": {
"lineItems": [
{
"purchasedItem": {
"price": {
"currentPrice": {
"amount": 10.0
}
}
}
}
]
}
}
}
Get Order With Multiple Line Items
Request
query order {
order(orderIdentifier: {orderId: "322-YYN9-93WX87"}) {
id
lineItems {
id
quantity {
unit
amount
}
createdAt
purchasedItem {
title
price {
currentPrice {
currencyCode
amount
}
}
}
}
}
}
Response
{
"data": {
"order": {
"id": "322-8D53-AK3EJK",
"lineItems": [
{
"id": "88eaa8941c-b27324fb27",
"quantity": {
"unit": "ONE",
"amount": 1
},
"createdAt": "2022-02-22T16:13:11.798Z",
"purchasedItem": {
"title": "Sample product 1 title",
"price": {
"currentPrice": {
"currencyCode": "USD",
"amount": 10.0
}
}
}
},
{
"id": "6aa26b8761-0868dbc493",
"quantity": {
"unit": "ONE",
"amount": 1
},
"createdAt": "2022-02-22T16:13:11.798Z",
"purchasedItem": {
"title": "Sample product 2 title",
"price": {
"currentPrice": {
"currencyCode": "USD",
"amount": 10.0
}
}
}
}
]
}
}
}
Get Order With Cancellation And Refund
Request
query order {
order(orderIdentifier: {orderId: "322-YYN9-93WX87"}) {
lineItems {
id
createdAt
purchasedItem {
title
price {
currentPrice {
currencyCode
amount
}
}
}
cancellations {
details{
reason
}
}
}
refunds{
summary{
refundTotal{
totalAmount{
currencyCode
amount
}
}
}
}
}
}
Response
{
"data": {
"order": {
"lineItems": [
{
"id": "cce0ec937f-1d6ab6c29a",
"createdAt": "2024-02-26T20:21:20.533Z",
"purchasedItem": {
"title": "Sample product title",
"price": {
"currentPrice": {
"currencyCode": "USD",
"amount": 10.0
}
}
},
"cancellations": {
"details": [
{
"reason": "Customer requested to cancel"
}
]
}
}
],
"refunds": {
"summary": {
"refundTotal": {
"totalAmount": {
"currencyCode": "USD",
"amount": 10.0
}
}
}
}
}
}
}
Get Order With Undefined Fields
Request
query order {
order(orderIdentifier: {orderId: "322-YYN9-93WX87"}) {
undefined_field
}
}
Response
{
"errors": [
{
"message": "Input request is not valid, the following issues were encountered: [Validation error of type FieldUndefined: Field 'undefined_field' in type 'Order' is undefined @ 'order/undefined_field']",
"locations": [
{
"line": 3,
"column": 3
}
],
"path": [],
"extensions": {
"classification": {
"errorType": "ValidationException",
"errorCode": 400,
"type": "ValidationError",
"code": "UnspecifiedError",
"details": {}
}
}
}
]
}
Get Order With Invalid Identifier
Request
query order {
order(orderIdentifier: {orderId: "invalid_id"}) {
id
lineItems {
id
quantity {
unit
amount
}
createdAt
purchasedItem {
title
price {
currentPrice {
currencyCode
amount
}
}
}
}
}
}
Response
{
"errors": [
{
"message": "Request references a resource which does not exist.",
"locations": [
{
"line": 2,
"column": 2
}
],
"path": [
"order"
],
"extensions": {
"classification": {
"errorType": "ResourceNotFoundException",
"errorCode": 404,
"type": "ResourceNotFoundError"
}
}
}
],
"data": {
"order": null
}
}
Updated 3 days ago