palbaseDocs

Palbase IAP · API

PUT/iap/paywalls/{paywall_id}/draft

Save a paywall's draft

Replaces the paywall's draft; what the apps show changes only when it is published. If-Match names the draft revision it was edited from: of two people editing at once, the second is told (412 paywall_changed), not overwritten. The draft is checked as a draft (422 invalid_paywall, with every problem).

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

Path

paywall_idstring (uuid) · requiredThe paywall's id.

Headers

If-Matchstring · requiredThe draft revision the paywall was read at, as its ETag names it.
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

definitionobject · requiredA paywall: a design system (the theme's colors, type scale, radii and spacing) and a free layout of components that name it — a fixed header and footer around the part that scrolls, and sheets it opens. Every component takes a style, a condition to be shown, a style for when it is selected, and an entrance animation. Prices are never in it: an app fills `{{price}}` and the other variables from its store. Its assets (asset:<id>) are the project's, given as https addresses in the app's answer and listed for the app to download before it shows the paywall. The server refuses what it does not know and holds a definition to bounds: 128 KiB of JSON, 400 components, 16 deep, 500 characters a text, 40 languages, 8 stops a gradient, 2 seconds an animation, 10 carousel pages, 5 tabs, 5 sheets.
curl
curl -X PUT "https://<your-ref>.palbase.studio/iap/paywalls/<paywall_id>/draft" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"definition":{"default_locale":"string","name":"string","root":{"action":{"type":"close"},"content":null,"type":"button"},"schema":2,"theme":{"colors":{"dark":{},"light":{}}}}}'

Responses

200The paywall

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

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`)

404No such paywall (`paywall_not_found`)

409A request with this Idempotency-Key is still running (`idempotency_key_in_use`, Retry-After)

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

413The request is over 256 KiB (`request_too_large`)

422The draft breaks a rule (`invalid_paywall`, 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`)

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 SavePaywallDraft of iap's contract.