palbaseDocs

Palbase IAP · API

POST/iap/customers/{customer_id}/limits/{limit_key}/grants

Grant more of a limit

Gives a customer more units of a limit in the window it is in now — a promotion, a support case — saying why; the next window starts from what their products give again. The Idempotency-Key names the grant in the project for good: sent again — a minute or a month later — it gives nothing more (200, Idempotent-Replayed); with another customer, limit, amount or source it is refused (422 idempotency_key_reused). A customer not seen before is made; a guest merged into an account gives the account. Answers the limit as it stands for them now. Emits iap.customer.changed when it gave.

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).
limit_keystring · requiredThe limit (a key of the catalog's limits).

Headers

Idempotency-Keystring · requiredNames the operation for good (1 to 255 characters): sent again — a minute or a month later — with the same request, it is the same one, never a second; with a different request it is refused (422 `idempotency_key_reused`). Required. The key is the project's, not the customer's: the same key on two customers names one operation (the second is refused as a different request), so put the customer's id in it.

Request body

amountinteger · requiredHow many units more.
reasonstring · requiredWhy: the record.
source"promotion" | "support" · requiredWhy, in kind.
curl
curl -X POST "https://<your-ref>.palbase.studio/iap/customers/<customer_id>/limits/<limit_key>/grants" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"amount":1,"reason":"string","source":"promotion"}'

Responses

200The grant this Idempotency-Key made before; the limit as it stands now

201The limit, as it stands for them now

400`source` is not promotion or support (`invalid_source`), no reason, or one over 500 characters (`reason_required`), no Idempotency-Key (`idempotency_key_required`), or a field out of its bounds (`invalid_<field>`)

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

404The catalog defines no such limit (`limit_not_found`), or the customer's id is longer than a customer's (`customer_not_found`)

409A request with this Idempotency-Key is still running (`idempotency_key_in_use`, Retry-After)

410The user was deleted (`customer_erased`): their id is no customer's again

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