palbaseDocs

Palbase IAP · API

POST/iap/customers/{customer_id}/spends/{spend_id}/commit

Commit a hold

Takes amount of what a hold keeps — all of it when no amount is given — and frees the rest; an amount of 0 takes nothing and releases the hold. Committed again with the same amount, it answers the same. A hold that ran out is refused (409 hold_expired): what it kept is free again. Emits the credits' and quota's events it crosses, and iap.customer.changed.

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

Path

customer_idstring · requiredThe customer: the user's id (a guest merged into an account names the account).
spend_idstring (uuid) · requiredThe spend's id.

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

amountinteger · optionalcommit: how much of the hold is taken, at most what it holds — absent, all of it; 0, nothing (the hold is released). reverse: how much of what the spend took is handed back in all — absent or 0, everything.
ttl_secondsinteger · optionalextend: the hold runs out this long from now (600 unless said).
curl
curl -X POST "https://<your-ref>.palbase.studio/iap/customers/<customer_id>/spends/<spend_id>/commit" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"amount":0,"ttl_seconds":1}'

Responses

200The spend

400A field out of its bounds (`invalid_amount`, `invalid_ttl`), or the body is not the request

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 customer (`customer_not_found`), or no such spend of theirs (`spend_not_found`)

409The hold ran out (`hold_expired`), or the spend is committed or released already (`spend_finalized`); 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 Idempotency-Key was sent with a different request (`idempotency_key_reused`)

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