palbaseDocs

Palbase IAP · API

POST/iap/coupons/redeem

Redeem a coupon code

Redeems a code the customer typed, once a customer: a grant at once, a discount or a trial theirs to buy (GET /iap/offers lists it with the coupon). A one-time code is anyone's once; a shared code up to its cap. Emits iap.coupon.redeemed (and iap.offer.redeemed for a grant).

Called by a signed-in user of your app, with their token and the publishable key.

Request body

codestring · requiredThe code, any case.
curl
curl -X POST "https://<your-ref>.palbase.studio/iap/coupons/redeem" \
  -H "apikey: $PALBASE_PUBLISHABLE_KEY" \
  -H "authorization: Bearer $USER_ACCESS_TOKEN" \
  -H "content-type: application/json" \
  -d '{"code":"string"}'

Responses

200What it opened

400The request is malformed, or a field breaks a rule (the error names which)

401No customer's session (`session_required`): a customer's own is reached with the publishable key and their access token; or the edge refused the key or the token

403A guest redeems no coupon kept for signed-in customers (`sign_in_required`); or the edge refused the key

404No coupon has this code (`coupon_not_found`)

409The customer redeemed it, or took its offer, already (`coupon_redeemed`), or the one-time code was redeemed (`code_used`)

410The coupon ended (`coupon_ended`), was taken as many times as it may be (`coupon_exhausted`), or its offer ended (`offer_ended`)

422An App Store offer code is redeemed in the App Store's sheet (`redeem_at_app_store`)

429Over 10 codes a minute for this customer or 60 from this address, in this project (`too_many_attempts`), or over the project's request limit; Retry-After says when to try again

503Temporarily unavailable; retrying is safe after Retry-After

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation RedeemCoupon of iap's contract.