palbaseDocs

Palbase IAP · API

POST/iap/apple/connect

Hand over an In-App Purchase key with a grant

Takes an In-App Purchase key with a grant, for one of the environment's registered iOS apps. Apple is asked, with a call that changes nothing (the app's notification history of the last hour, in the sandbox), whether it takes the key for the app; the key is kept sealed with the project's own key, the grant is spent, and the stores module is asked to set this environment's address (POST /iap/webhooks/apple) as the app's notification address in App Store Connect. Each key tried counts against the grant — 10 at most. A key connected again replaces the one before. Emits iap.store.changed (connected).

Called by .

Request body

bundle_idstring · requiredThe app the key is for: one of this environment's registered iOS apps.
grantstring · requiredThe grant a connect link carries.
issuer_idstring · requiredThe key's issuer: App Store Connect → Users and Access → Integrations → In-App Purchase.
key_idstring · requiredThe key's id (10 capital letters and digits).
private_keystring · requiredThe key's .p8 file as Apple let it be downloaded (SubscriptionKey_<key id>.p8: PEM, PKCS#8). An App Store Connect API key is not this key.
curl
curl -X POST "https://<your-ref>.palbase.studio/iap/apple/connect" \
  -H "content-type: application/json" \
  -d '{"bundle_id":"string","grant":"string","issuer_id":"string","key_id":"string","private_key":"string"}'

Responses

200Connected

400No grant (`grant_required`), or the body is not the request

410The grant is used, expired, or was tried with 10 keys already (`grant_invalid`): ask for a new one

413The body is over 16 KiB

422The key's ids or file are not a key's (`key_id_invalid`, `issuer_invalid`, `not_a_key`), the app is none of the environment's iOS apps (`bundle_not_registered`), Apple does not take the key for the app (`apple_key_refused`), or refused its first call otherwise (`apple_refused`)

429Over the project's request limit; Retry-After says when to try again

502The App Store could not be reached (`apple_unreachable`); retrying is safe after Retry-After

503Temporarily unavailable; retrying is safe after Retry-After

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

Operation ConnectAppleKey of iap's contract.