palbaseDocs

Palbase IAP · API

POST/iap/experiments

Start an experiment

Starts an experiment on a placement: from then on the placement shows each subject in its audience — the signed-in user (a guest included), else the installation — its variant's paywall, the same every time (a hash of the experiment and the subject, placed on the weights; nothing is stored). Every variant's paywall must be published (422 invalid_experiment); one experiment runs on a placement at a time (409 experiment_running). An experiment for the rules (audience rules) shows the viewers the placement's rules targeting it send it — the placement is one already (404 placement_not_found); one for everyone (audience placement, when none is named) is decided before the placement's rules, and the placement keeps its default for when it ends.

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

audience"placement" | "rules" · optionalplacement (when none): everyone at the placement — made when new —, decided before its rules; rules: the viewers the placement's rules targeting it send it — the placement is one already.
namestring · requiredIts name (1 to 100 characters).
placementstring · requiredThe placement it runs on (for everyone there, made when new).
variantsobject[] · required2 to 4 variants, each its own published paywall; the first is the one a stop keeps.
curl
curl -X POST "https://<your-ref>.palbase.studio/iap/experiments" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"name":"string","placement":"string","variants":[{"key":"string","paywall_id":"00000000-0000-0000-0000-000000000000","weight":1}]}'

Responses

201The experiment, running

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`); an experiment for the rules on a placement the project does not have (`placement_not_found`)

409An experiment runs on the placement (`experiment_running`); or the project has 200 placements (`too_many_placements`); 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 experiment breaks a rule (`invalid_experiment`): 2 to 4 variants, each its own published paywall, a key and a weight of 1 to 1000. 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

503Temporarily unavailable; retrying is safe after Retry-After

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

Operation StartExperiment of iap's contract.