palbaseDocs

Palbase IAP · API

POST/iap/me/merge

Move a guest's purchases to the account

With the account's session and the guest's proof: everything the guest bought — subscriptions and purchases, grants, credits and quota use — goes to the account in one step, and the guest's id points to the account from then on (its session reads 409 customer_merged). It cannot be undone; asked again, it is the same merge. Answers what the account has now. Emits iap.customer.merged, the credits' events and iap.customer.changed for both.

Called by a signed-in user of your app, with their token and the publishable key.

Request body

grantstring · requiredThe proof the guest asked for.
curl
curl -X POST "https://<your-ref>.palbase.studio/iap/me/merge" \
  -H "apikey: $PALBASE_PUBLISHABLE_KEY" \
  -H "authorization: Bearer $USER_ACCESS_TOKEN" \
  -H "content-type: application/json" \
  -d '{"grant":"string"}'

Responses

200What the account has now

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

401No customer's session (`session_required`): a customer's own is reached with the publishable key and their access token; or the edge refused the key or token

403A guest's session (`account_required`): merge with the account's

404The user's id is longer than a customer's (`customer_not_found`)

409The guest's purchases went to another account already (`already_merged`), or this session's own did (`customer_merged`)

410The proof is used or expired (`merge_grant_invalid`): ask for a new one with the guest's session; or the user was deleted (`customer_erased`)

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

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

503Another change to this customer is in progress (`customer_busy`), or the platform could not answer now; retrying is safe after Retry-After

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

Operation MergeGuest of iap's contract.