Skip to content

Get Customer Orders

About

The customerOrders query retrieves a paginated list of orders belonging to the authenticated customer. This is a read-only API — customers can only view their own orders. Use this query to:

  • Display order history in the customer's account dashboard
  • Show order list with status, totals, and dates
  • Filter orders by status (pending, processing, completed, etc.)
  • Implement pagination for customers with many orders
  • Build order tracking interfaces

Orders are automatically scoped to the authenticated customer and the current channel.

Authentication

This query requires customer authentication:

  • Authenticated customers: Provide a valid customer authentication token in the Authorization header. Obtain this token via the Customer Login API.
Authorization: Bearer <accessToken>
X-STOREFRONT-KEY: <storefrontKey>

Arguments

ArgumentTypeRequiredDescription
firstInt❌ NoNumber of items to return (forward pagination). Max: 100.
afterString❌ NoCursor for forward pagination. Use endCursor from previous response.
lastInt❌ NoNumber of items for backward pagination. Max: 100.
beforeString❌ NoCursor for backward pagination. Use startCursor from previous response.
statusString❌ NoFilter by order status: pending, processing, completed, canceled, closed, fraud.

Possible Returns

FieldTypeDescription
edges[CustomerOrderEdge!]Array of order edges with cursor and node.
edges.cursorString!Cursor for this edge, used in pagination.
edges.nodeCustomerOrder!The customer order object.
edges.node._idInt!Numeric order ID.
edges.node.incrementIdString!Human-readable order number.
edges.node.statusString!Order status: pending, processing, completed, canceled, closed, fraud.
edges.node.channelNameString!Channel the order was placed on.
edges.node.isGuestIntWhether the order was placed as guest.
edges.node.customerEmailString!Customer email address.
edges.node.customerFirstNameString!Customer first name.
edges.node.customerLastNameString!Customer last name.
edges.node.shippingMethodStringShipping method code.
edges.node.shippingTitleStringShipping method display name.
edges.node.couponCodeStringApplied coupon code.
edges.node.isGiftIntWhether the order is a gift.
edges.node.totalItemCountInt!Number of distinct items.
edges.node.totalQtyOrderedInt!Total quantity ordered.
edges.node.grandTotalFloat!Grand total.
edges.node.baseGrandTotalFloat!Base grand total.
edges.node.grandTotalInvoicedFloatGrand total invoiced.
edges.node.grandTotalRefundedFloatGrand total refunded.
edges.node.subTotalFloat!Sub total.
edges.node.baseSubTotalFloat!Base sub total.
edges.node.taxAmountFloatTax amount.
edges.node.baseTaxAmountFloatBase tax amount.
edges.node.discountAmountFloatDiscount amount.
edges.node.baseDiscountAmountFloatBase discount amount.
edges.node.shippingAmountFloatShipping amount.
edges.node.baseShippingAmountFloatBase shipping amount.
edges.node.baseCurrencyCodeString!Base currency code.
edges.node.channelCurrencyCodeStringChannel currency code.
edges.node.orderCurrencyCodeString!Order currency code.
edges.node.createdAtDateTime!Order creation timestamp.
edges.node.updatedAtDateTime!Order last update timestamp.
pageInfoPageInfo!Pagination metadata.
pageInfo.hasNextPageBoolean!Whether more pages exist forward.
pageInfo.hasPreviousPageBoolean!Whether more pages exist backward.
pageInfo.startCursorStringCursor for first item in page.
pageInfo.endCursorStringCursor for last item in page.
totalCountInt!Total orders matching filters.

Order Status Values

StatusDescription
pendingAwaiting payment confirmation
processingPayment confirmed, order being processed
completedOrder fulfilled and delivered
canceledOrder canceled
closedOrder closed
fraudFlagged as fraudulent

Use Cases

1. Order History Dashboard

Fetch all customer orders to display in the account dashboard with pagination.

2. Pending Orders

Filter by status: "pending" to show orders awaiting payment or processing.

3. Order Tracking

Display order status and details for customers to track their purchases.

4. Completed Orders

Filter by status: "completed" to show fulfilled orders for reorder functionality.

Best Practices

  1. Use Pagination — Always implement pagination for better performance, especially for active customers
  2. Show Status — Display the order status prominently so customers can track progress
  3. Filter by Status — Provide status filters so customers can quickly find specific orders
  4. Cache Results — Cache order lists for better performance
  5. Handle Empty States — Provide helpful UI when the customer has no orders

Error Handling

Unauthenticated Request

json
{
  "errors": [
    {
      "message": "Customer is not logged in.",
      "locations": [{ "line": 2, "column": 3 }],
      "path": ["customerOrders"]
    }
  ]
}

Released under the MIT License.