Authorization headerpurchase-history permissioncommunityID401 if the key is missing or invalid, and 403 if the key lacks the permissionupdate:purchase-history pub/sub event; the store service processes it and performs the database writeredemptionInstructions, when provided, updates PurchaseHistory.product.redemptionInstructions only; the source Product record is not modifiedvoucherCode and voucherExpiryDate, when provided together, update the source Voucher record (code, expiryDate) through the normal voucher update service pathvoucher:update socket event, HOT content-hash stamping, and HOT-to-legacy voucher sync when enabledvoucherCode, voucherExpiryDate) so historical order views stay stable502 if the upstream store service is unreachable or the publisher times outpurchaseHistoryID accepts either the Mongo _id or the human-readable purchase/order ID (e.g. ORD202641612055614747)redemptionInstructions by itself, or send voucherCode and voucherExpiryDate together, or send all three fieldsvoucherCode or voucherExpiryDate is provided, both are requiredredemptionInstructions: optional, trimmed, non-empty when provided, max 10000 charsvoucherCode: trimmed, non-empty when provided, max 512 charsvoucherExpiryDate: trimmed, valid calendar date in DD/MM/YYYY format409 if the new voucher code already exists for another voucher in the same product and community404 if the purchase history, product snapshot target, or voucher target does not exist in this community400{
"voucherCode": "UPDATED-VOUCHER-2026",
"voucherExpiryDate": "31/12/2026"
}{
"redemptionInstructions": "Collect at the main counter between 10am and 6pm. Present your order ID and a valid photo ID."
}{
"redemptionInstructions": "Collect at the main counter between 10am and 6pm. Present your order ID and a valid photo ID.",
"voucherCode": "UPDATED-VOUCHER-2026",
"voucherExpiryDate": "31/12/2026"
}/purchase-histories/{purchaseHistoryID} with the request body, query parameters, or multipart fields shown below. Partner API key required when this surface is enabled for the community. Confirm gateway access before using in production.data with status and message.400 invalid request body, query, ObjectId, pagination, file format, or missing required field.401 missing, invalid, expired, or insufficient API key/token.403 key is valid but cannot access this community/channel/user/resource, where supported by the service.404 target resource, route, or community-scoped record was not found.409 duplicate or conflicting state for create/update operations, where applicable.500 unexpected Returning.AI service error.curl --location --request PATCH 'https://api.returning.ai/purchase-histories/ORD202641612055614747' \
--header 'Authorization: Bearer XXXXXX' \
--header 'Content-Type: application/json' \
--data '{
"voucherCode": "UPDATED-VOUCHER-2026",
"voucherExpiryDate": "31/12/2026"
}'{
"meta": {
"status": "success",
"statusCode": 200
},
"message": "Update purchase history success.",
"data": {
"_id": "507f1f77bcf86cd799439012",
"purchaseID": "ORD202641612055614747",
"communityID": "507f1f77bcf86cd799439013",
"userID": "507f1f77bcf86cd799439014",
"voucherCode": "UPDATED-VOUCHER-2026",
"voucherExpiryDate": "2026-12-31T00:00:00.000Z",
"product": {
"_id": "507f1f77bcf86cd799439015",
"name": "Gold Voucher",
"redemptionInstructions": "Collect at the main counter between 10am and 6pm. Present your order ID and a valid photo ID."
},
"voucher": {
"_id": "507f1f77bcf86cd799439016",
"code": "UPDATED-VOUCHER-2026",
"status": "redeemed",
"expiryDate": "2026-12-31T00:00:00.000Z"
},
"createdAt": "2026-04-01T00:00:00.000Z",
"updatedAt": "2026-04-20T00:00:00.000Z"
}
}