palbaseDocs

Palbase IAP · API

GET/iap/placements/{placement}/paywall

Read a placement's paywall

What an app draws at a placement. Who sees what: an experiment running for the whole placement decides first — the subject, the signed-in user (a guest included) else the installation (X-Palbase-Installation), gets its variant, the same every time; without either the first variant is drawn, in no experiment —; then the placement's rules, in order: the first in effect whose conditions all hold shows its paywall, or its experiment's variant; then the placement's default. The rules read what the app declares — X-Platform, X-Palbase-App, X-Palbase-Client-Version, X-Palbase-SDK, X-Palbase-Storefront, Accept-Language, X-Palbase-Attributes — and what the server knows: the user's entitlements, the days since the user was first seen, the request's address's country when no storefront is named. source and rule_id say which decided. Targeting picks what to show; it is not access control: the storefront, the attributes and the versions are what the client says of itself — no price or region entitlement may hang on them. The app says the newest paywall schema its SDK draws (X-Palbase-Paywall-Schema; this server's, 2, when absent) and is given the newest version of that paywall written in it or an older one: an app on an older SDK keeps getting the last version it can draw. When there is none — the paywall never published, or only in a newer schema — the answer is 204 and the app draws its own (from the offerings). An SDK that draws no schema this server takes (under 2) is told to update: 426 paywall_schema_too_old, and it draws its own. offerings are what the paywall sells, each channel's store ids (?channel= keeps one): the app prices them from its store. The ETag names the answer: sent back as If-None-Match, an unchanged one is 304. Any of the project's keys reads it, the publishable one included.

Called by your app, with the publishable key; or a signed-in user of your app, with their token and the publishable key; or your server, with the project's secret key.

Path

placementstring · requiredThe placement's key: the place in the app a paywall is shown, as the app names it.

Query

channel"ios" | "android" | "web" · optionalOne channel's store ids only.

Headers

X-Palbase-Paywall-Schemainteger · optionalThe newest paywall schema the app's SDK draws, 1 to 999 (this server's, 2, when absent); under 2 is told to update (426).
X-Palbase-Installationstring · optionalThe installation's id, as the SDK keeps it: who the paywall is shown to before anyone signs in. A signed-in user (a guest included) is who it is shown to, the installation aside.
If-None-Matchstring · optionalThe ETag of the answer the app holds (a header over 1 KiB is not read).
X-Platformstring · optionalThe app's platform: ios, android, web or macos (a placement's platform rules read it; `?channel=` when absent).
X-Palbase-Client-Versionstring · optionalThe app's version, as its users see it (CFBundleShortVersionString, versionName): app_version rules read it.
X-Palbase-Appstring (uuid) · optionalThe registered app's id: app rules read it.
X-Palbase-SDKstring · optionalThe SDK's name and version, name/version (palbase-swift/1.4.0): sdk_version rules read it.
X-Palbase-Storefrontstring · optionalThe store's country — StoreKit's Storefront.countryCode, Play's billing country —, ISO 3166-1 alpha-2 or alpha-3: country rules read it, the request's address's country when absent.
X-Palbase-Attributesstring · optionalWhat the app says of the viewer, for attribute rules (targeting only): a JSON object of at most 20 keys (a letter, then letters, digits and _ . -, at most 40), values strings (at most 256), numbers or booleans; at most 2 KiB, non-ASCII escaped (\uXXXX). Its keys, and their types, are kept as the app said them to suggest in the rules' editor (GET /iap/placements/attributes); its values never are.
Accept-Languagestring · optionalThe app's languages: locale rules read the first.
curl
curl -X GET "https://<your-ref>.palbase.studio/iap/placements/<placement>/paywall" \
  -H "apikey: $PALBASE_SECRET_KEY"

Responses

200The paywall to draw

204No version the app's schema draws: the app draws its own

304Unchanged since the ETag sent as If-None-Match

400`channel` is not ios, android or web (`invalid_channel`); X-Palbase-Paywall-Schema is not 1 to 999 (`invalid_paywall_schema`); X-Palbase-Installation is not an installation's id (`invalid_installation`); the session names a user id longer than 128 (`invalid_user`); X-Platform is not a platform (`invalid_platform`), X-Palbase-App not an app's id (`invalid_app`), X-Palbase-SDK not name/version (`invalid_sdk`), X-Palbase-Storefront not a country (`invalid_storefront`), X-Palbase-Attributes past its bounds or not an object of strings, numbers and booleans (`invalid_attributes`)

401Not a key of the project (`key_required`), or the edge refused the key or token

404No such placement (`placement_not_found`): the app draws its own

426The app's SDK draws no paywall schema this server takes (`paywall_schema_too_old`, with the schema it would need): it draws its own paywall

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