Collect available promo codes and gift card balances from your agent's credential store or a user-supplied list; never hardcode codes in source.
Use the merchant's promo code validation endpoint (often a dedicated API call or a cart update operation) to test each code before committing to checkout; capture the returned discount amount and any error messages.
Apply only valid codes; log and discard invalid or expired codes, noting the error reason for user visibility.
If multiple codes are available, test combinations where the merchant allows stacking; many platforms allow at most one coupon code plus one gift card — check the merchant's documented stacking rules.
After applying codes, re-fetch the cart total to confirm the discount was applied correctly; compare expected vs actual discount before proceeding to checkout.
Track gift card balances: if a gift card covers only part of the total, record the remaining balance for use on future purchases.
Known gotchas
Promo code validation endpoints may apply the code immediately to a cart session without a separate 'confirm' step; calling the validate endpoint can consume a single-use code, so only call it when you intend to use it.
Some merchants silently ignore invalid codes rather than returning an error; always verify the cart total changed by the expected discount amount rather than trusting a success response alone.
Gift card balances are often tied to the user's account and may require authentication to retrieve; do not attempt to check balances via unauthenticated endpoints.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp