Find Order Discount by Code
Beta/v1/sales/order-discounts/actions/find-by-codeIdempotent with Idempotency-Key header. Learn more
Validates a discount code and returns the matching order discount, so a code a buyer typed can be attached to an order.
When buyer_account_id is provided, or the caller is a customer user, the lookup also verifies that the buyer has not already redeemed the discount on another order, and reports an already-redeemed code as not found. Pass sales_order_id to exclude an order the buyer is currently editing from that check.
codestringThe discount code to look up, as the buyer typed it.
Matching ignores letter case, so save10 finds a discount stored as SAVE10.
buyer_account_idoptional stringThe buyer account to check for prior use of this code.
When set, the lookup returns a not-found error if that buyer has already redeemed the discount on another order, so a one-use-per-customer code can be rejected before it is attached to a new one. Customer callers cannot set this — their own account is always used.
sales_order_idoptional stringSales order ID to exclude from the prior-usage check.
Set this when re-validating a code on an existing order so the order's own usage does not count against the buyer.
idstringOrder discount ID.
objectstringenumValues:order_discountResource type identifier.
namestringDisplay name of the discount.
codestringThe code a buyer enters to apply this discount to an order.
Codes are unique within your account and are matched without regard to letter case.
percentagestring (decimal)The fraction of the order total taken off, as a decimal string.
This is a multiplier, not a whole percent: 0.1 takes 10% off. Only read when discount_type is percentage.
amountstring (decimal)The flat amount taken off the order total, as a decimal string.
Only read when discount_type is amount.
discount_typestringenumValues:percentageamountHow the discount is calculated.
percentage: the order total is reduced by the fraction inpercentage.amount: the order total is reduced by the flat amount inamount.
order_countintegerHow many sales orders this discount has been applied to, across all buyers.
created_atstring (date-time)Creation timestamp.
updated_atstring (date-time)Last updated timestamp.
Responses
Successful response for Find Order Discount by Code