palbaseDocs

Palbase IAP · API

POST/iap/paywalls/assets

Register a paywall asset

Registers an object of the project's public bucket paywall-assets for its paywalls: Studio and the CLI upload it with the project's storage first (and make the bucket when it is missing), then register its path here. The module builds the object's address itself, from the project's own storage — never from an address it is given — and reads it there as every app will, saying what it is by its bytes, never by its name or the type it was stored with: an image (png, jpeg or webp, at most 2 MiB; never svg), a video (mp4 or mov, 50 MiB), a font (ttf, otf or woff2, 5 MiB), or an HTML block's zip (5 MiB; at most 200 files and 20 MiB opened, read to the end; index.html at its root; no file leaving the root, no link). It stops reading past the bound. It keeps the asset's SHA-256 and size: an app draws what it downloads only when it is that, and a paywall naming an asset whose object was since changed or removed is warned of in a draft and refused when published. A project has at most 500 assets.

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

kind"image" | "video" | "font" | "html" · optionalWhat the object is meant to be: a registration whose bytes are another kind is refused (asset_kind_mismatch).
pathstring · requiredThe object's path in the paywall-assets bucket (a leading / is the bucket's root). A . or .. segment, an empty one or a control character is refused, never resolved.
curl
curl -X POST "https://<your-ref>.palbase.studio/iap/paywalls/assets" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"path":"string"}'

Responses

201The asset

400path is not an object's path (`invalid_path`), or kind is not one (`invalid_request`); or the body is malformed

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

409The project has 500 assets (`too_many_assets`); or a request with this Idempotency-Key is still running (`idempotency_key_in_use`, Retry-After)

413The request body is too large (`request_too_large`)

422The object is not readable at its public address (`asset_unreadable`: the bucket is missing or not public, or the object is not there), its bytes are not the kind named (`asset_kind_mismatch`), or it is no asset a paywall takes (`unsupported_asset`, `asset_too_large`, `invalid_archive`, `archive_too_many_files`, `archive_too_large`, `unsafe_archive_path`, `archive_link`, `archive_no_index`). Or the Idempotency-Key was sent with a different request (`idempotency_key_reused`)

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

503The project's storage could not be read (`storage_unavailable`); retrying is safe after Retry-After

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

Operation RegisterPaywallAsset of iap's contract.