palbaseDocs

Palbase IAP · API

PUT/iap/catalog

Save the catalog

Saves a new revision of the whole catalog. It is checked first: a problem that is not a warning refuses it, with every problem listed (422 invalid_catalog); a warning (a channel's feature the product goes without) does not. If-Match names the revision it was edited from (0 for the first): of two people editing at once, the second is told (412 catalog_changed), not overwritten. Nothing is written to a store: a plan made from an older revision goes stale, and a new one is made (POST /iap/catalog/plans). Emits iap.catalog.changed.

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

Headers

If-Matchstring · requiredThe revision the catalog was edited from, as the ETag of GET /iap/catalog names it ("0" for the first).
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

base_localestring · requiredThe language every product names itself in (a tag such as en or pt-BR); the others are translations. Stripe keeps one name: this one's.
creditsobject[] · requiredThe kinds of credit the project counts ("tokens").
entitlementsobject[] · requiredWhat a customer has or not ("pro").
limitsobject[] · requiredThe metered quotas ("ai_requests a month").
offersobject[] · optionalPrices for a while, to whom the project chooses.
productsobject[] · requiredThe products.
curl
curl -X PUT "https://<your-ref>.palbase.studio/iap/catalog" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"base_locale":"string","credits":[{"key":"string","name":"string"}],"entitlements":[{"key":"string","name":"string"}],"limits":[{"free":0,"key":"string","name":"string","window":"string"}],"products":[{"channels":{},"key":"string","locales":{},"plans":[{"key":null,"price":null}],"type":"string"}]}'

Responses

200The saved revision

400The catalog cannot be read: a field it does not know, or of the wrong type (`invalid_catalog`)

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 request with this Idempotency-Key is still running (`idempotency_key_in_use`, Retry-After)

412The catalog changed since it was read (`catalog_changed`): read it again and apply the edit to the new revision

413The catalog is over 512 KiB

422The catalog breaks a rule (`invalid_catalog`, with every problem); nothing was saved. Or the Idempotency-Key was sent with a different request (`idempotency_key_reused`)

428No If-Match (`if_match_required`): send the revision the catalog was edited from

429Over 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 SaveCatalog of iap's contract.