palbaseDocs

Palbase IAP · API

POST/iap/coupons

Create a coupon

Makes a coupon: a code that opens one of the catalog's offers. A palbase coupon's one-time codes are made here; a shared code of a discount on the web is the Stripe promotion code of the offer's coupon too. An apple coupon is an App Store offer code App Store Connect makes (the stores module writes it; apple.state says how it went) — its one-time codes are given out as Palbase's are.

Called by your server, with the project's secret key.

Headers

Idempotency-Keystring · optionalMakes the write safe to send again (at most 255 characters). A retry with the same key and the same request gets the first answer back, marked `Idempotent-Replayed: true`, and changes nothing; the same key with a different request is refused with 422, and while the first request still runs a retry gets 409 with Retry-After. Answers are kept for 24 hours.

Request body

codestring · optionalA code many share, 3 to 32 letters and digits.
expires_atstring (date-time) · optionalWhen it ends (an App Store batch's codes must).
keystring · requiredIts key.
kind"palbase" | "apple" · requiredpalbase or apple.
max_redemptionsinteger · optionalHow many times the shared code is taken.
namestring · requiredIts name.
offerstring · requiredThe offer it opens.
one_time_codesinteger · optionalHow many codes of one use each to make (1 to 25000).
planstring · optionalAn App Store offer code's plan of the offer's product.
signed_in_onlyboolean · optionalA guest cannot redeem it.
curl
curl -X POST "https://<your-ref>.palbase.studio/iap/coupons" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"key":"string","kind":"palbase","name":"string","offer":"string"}'

Responses

201The coupon

400The coupon is not one: its key (`invalid_key`), name (`invalid_name`), kind (`invalid_kind`), code (`invalid_code`), codes (`one_kind_of_code`, `invalid_count`), end (`expires_in_past`, `expires_required`)

401No key, not a key of this project, or a token that is not valid (the edge's answer)

403Not the project's secret key (`secret_key_required`)

409A coupon of this key or code exists (`coupon_exists`), or a request with this Idempotency-Key is still running

422The catalog has no such offer (`offer_not_found`), or an App Store offer code is not on one of its iOS plans (`not_an_app_store_offer`); or the Idempotency-Key was sent with another request

503Temporarily unavailable; retrying is safe after Retry-After

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

Operation CreateCoupon of iap's contract.