Skip to main content

customerPurchaseHistory

Requires permission sales:sales_order:read.

The items a customer buys most often, at product, variant and unit level, for a rep's reorder view. Reps see only customers in their own scope. limit defaults to 30. Needs the sales order read permission.

Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.

Example:

query CustomerPurchaseHistory($partnerId: ID!) {
customerPurchaseHistory(partnerId: $partnerId) {
productName
variantName
lastOrderedAt
lastQty
lastUnitPrice
lastUomId
}
}

Variables:

{
"partnerId": "id"
}

Response:

{
"data": {
"customerPurchaseHistory": [
{
"productName": "string",
"variantName": "string",
"lastOrderedAt": "2025-01-15T00:00:00Z",
"lastQty": 0,
"lastUnitPrice": 0,
"lastUomId": "id"
}
]
}
}
customerPurchaseHistory(
limit: Int = 30
partnerId: ID!
): [CustomerPurchaseHistoryItem!]!

Arguments​

customerPurchaseHistory.limit ● Int scalar​

Maximum number of items to return. Defaults to 30.

customerPurchaseHistory.partnerId ● ID! non-null scalar​

The ID of the customer.

Type​

CustomerPurchaseHistoryItem object​

What a customer has bought of one product or variant, across their orders.