order

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

Returns a single order.

Response

Return type Order

Arguments

ArgumentDescription
orderIdentifier (OrderIdentifierInput required)

Identifier of the order to retrieve

Examples


Get Order With Specified Alias

Request

query order { order( orderIdentifier: { alias: { aliasType: "EXTERNAL_ID", aliasId: "example-alias-id" } } ) { id lineItems { id amount { unit value } } } }

Response

{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 } } ] } } }

Get Order With Single Field

Request

query order { order(orderIdentifier: {orderId: "322-ABC1-AAAAAA"}) { lineItems { product { price { currencyCode amount } } } } }

Response

{ "data": { "order": { "lineItems": [ { "product": { "price": { "currencyCode": "USD", "amount": 10.0 } } } ] } } }

Get Order With Return Package Details

Request

query order { order(orderIdentifier: {orderId: "322-ABC1-AAAAAA"}) { id returns { details { id createdAt updatedAt aliases { aliasId aliasType } state returnLineItems { id returnFor { orderLineItemAmounts { amount { value } lineItem { id amount { value } } } } } returnPackageDetails { id state reason returnPackageFor { orderLineItemAmounts { lineItem { id } amount { value } } } packageTracker { packageTrackerIdentifier { trackingNumber carrierCode } estimatedDeliveryDate { earliest latest } latestMilestone { status { code message { locale value } } address { locality region country } occurredAt } milestones { status { code message { locale value } } address { locality region country } occurredAt } } } } } } }

Response

{ "data": { "order": { "id": "322-ABC1-AAAAAA", "returns": { "details": [ { "id": "SAMPLE_RETURN_ID", "createdAt": "2024-11-18T10:51:10.185299806Z", "updatedAt": "2024-11-18T10:51:10.185299806Z", "aliases": null, "state": "CREATED", "returnLineItems": [ { "id": "SAMPLE_RETURN_LINE_ITEM_ID", "returnFor": { "orderLineItemAmounts": [ { "amount": { "value": 1 }, "lineItem": { "id": "SAMPLE_LINE_ITEM_ID", "amount": { "value": 1 } } } ] } } ], "returnPackageDetails": [ { "id": "SAMPLE_RETURN_PACKAGE_ID", "state": "DELIVERED", "reason": null, "returnPackageFor": { "orderLineItemAmounts": [ { "lineItem": { "id": "SAMPLE_ID" }, "amount": { "value": 1 } } ] }, "packageTracker": { "packageTrackerIdentifier": { "trackingNumber": "SampleTrackingNumber1", "carrierCode": "ups" }, "estimatedDeliveryDate": { "earliest": "2024-07-02T05:54:53Z", "latest": "2024-07-04T05:54:53Z" }, "latestMilestone": { "status": { "code": "DELIVERED", "message": { "locale": "en-US", "value": "something" } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-07-02T05:54:53Z" }, "milestones": [{ "status": { "code": "DELIVERED", "message": { "locale": "en-US", "value": "something" } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-07-02T05:54:53Z" }] } } ] } ] } } } }

Get Order With Multiple Line Items

Request

query order { order(orderIdentifier: {orderId: "322-ABC1-AAAAAA"}) { id lineItems { id amount { unit value } createdAt product { title price { currencyCode amount } } } } }

Response

{ "data": { "order": { "id": "322-ABC1-AAAAAA", "lineItems": [ { "id": "88eaa8941c-b27324fb27", "amount": { "unit": "ONE", "value": 1 }, "createdAt": "2022-02-22T16:13:11.798Z", "product": { "title": "Sample product 1 title", "price": { "currencyCode": "USD", "amount": 10.0 } } }, { "id": "6aa26b8761-0868dbc493", "amount": { "unit": "ONE", "value": 1 }, "createdAt": "2022-02-22T16:13:11.798Z", "product": { "title": "Sample product 2 title", "price": { "currencyCode": "USD", "amount": 10.0 } } } ] } } }

Get Order With Cancellation And Refund

Request

query order { order(orderIdentifier: {orderId: "322-ABC1-AAAAAA"}) { lineItems { id createdAt product { title price { 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", "product": { "title": "Sample product title", "price": { "currencyCode": "USD", "amount": 10.0 } }, "cancellations": { "details": [ { "reason": "Customer requested to cancel" } ] } } ], "refunds": { "summary": { "refundTotal": { "totalAmount": { "currencyCode": "USD", "amount": 10.0 } } } } } } }

Get Order With Package Tracker

Request

query order { order(orderIdentifier: {orderId: "322-ABC1-AAAAAA"}) { id lineItems { id packageInformation { details { id state reason packageTracker { packageTrackerIdentifier { trackingNumber carrierCode } estimatedDeliveryDate { earliest latest } latestMilestone { status { code message { locale value } } address { locality region country } occurredAt } milestones { status { code message { locale value } } address { locality region country } occurredAt } trackingUrl } } } } } }

Response

{ "data": { "order": { "id": "322-ABC1-AAAAAA", "lineItems": [ { "id": "3a62130895-aadd755a24", "packageInformation": { "details": [ { "id": "deliveryid-1", "state": "IN_TRANSIT", "reason": null, "packageTracker": { "packageTrackerIdentifier": { "trackingNumber": "SampleTrackingNumber1", "carrierCode": "ups" }, "estimatedDeliveryDate": { "earliest": "2024-07-02T05:54:53Z", "latest": "2024-07-04T05:54:53Z" }, "latestMilestone": { "status": { "code": "IN_TRANSIT", "message": { "locale": "en-US", "value": "Package on the way." } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-07-02T05:54:53Z" }, "milestones": [ { "status": { "code": "IN_TRANSIT", "message": { "locale": "en-US", "value": "Package on the way." } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-07-02T05:54:53Z" } ], "trackingUrl": "https://www.swiship.com/track?id=SampleTrackingNumber1" } }, { "id": "deliveryid-2", "state": "DELIVERED", "reason": null, "packageTracker": { "packageTrackerIdentifier": { "trackingNumber": "SampleTrackingNumber2", "carrierCode": "ups" }, "estimatedDeliveryDate": { "earliest": "2024-07-09T12:03:25Z", "latest": "2024-07-09T12:03:25Z" }, "latestMilestone": { "status": { "code": "DELIVERED", "message": { "locale": "en-US", "value": "Package delivered." } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-07-02T05:54:53Z" }, "milestones": [ { "status": { "code": "DELIVERED", "message": { "locale": "en-US", "value": "Package delivered." } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-07-02T05:54:53Z" }, { "status": { "code": "IN_TRANSIT", "message": { "locale": "en-US", "value": "Package on the way." } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-07-01T01:54:53Z" } ], "trackingUrl": "https://www.swiship.com/track?id=SampleTrackingNumber2" } }, { "id": "deliveryid-3", "state": "CANCELLED", "reason": "CUSTOMER_REQUESTED", "packageTracker": null } ] } } ] } } }

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 amount { unit value } createdAt product { title price { 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 } }


Did this page help you?