License keys
The default way to verify purchases. Every purchase creates one license key (key_…). Your server collects it once when the buyer returns, stores it on your own user, and validates it whenever it needs to know what that customer may use. Your login stays yours; buyers never see a UseThatApp sign-in. Included in the per-sale fee, nothing to enable.
Configure
UTA_CLIENT_ID=<client id from Manage app → Integration>
UTA_CLIENT_SECRET=<client secret> # or UTA_CLIENT_SECRET_PATH=/path/to/fileInstall usethatapp 2.3.0 or later (pip install -U usethatapp / npm install usethatapp@latest). Every call on this page is server-to-server, authenticated with the client id and secret; never put the secret in a browser bundle or a desktop binary. Without the SDK, send them as HTTP Basic credentials — see the reference.
1. Collect the key when the buyer returns
After a paid checkout, the buyer is redirected to your next URL with ?uta_order=<ref> appended. Exchange the ref for the key and attach it to the user signed in to your app.
from usethatapp import get_order, UtaOrderProcessingError
ref = request.args["uta_order"]
if not current_user.is_authenticated:
session["pending_uta_order"] = ref # finish after sign-in
return redirect("/login")
try:
order = get_order(ref)
except UtaOrderProcessingError:
return render("finishing_up.html") # retry in a second or two
current_user.license_key = order.license_key
current_user.license_id = order.license_id
save(current_user)import { getOrder, UtaOrderProcessingError } from "usethatapp";
const ref = req.query.uta_order;
if (!req.user) {
req.session.pendingUtaOrder = ref; // finish after sign-in
return res.redirect("/login");
}
let order;
try {
order = await getOrder(ref);
} catch (e) {
if (e instanceof UtaOrderProcessingError) {
return res.render("finishing-up"); // retry in a second or two
}
throw e;
}
req.user.licenseKey = order.license_key;
req.user.licenseId = order.license_id;
await save(req.user);- The ref is an opaque token, valid for 30 days and only for your app. It is not a secret on its own: it is useless without your client secret. Exchanging it again returns the same key, so page reloads are safe.
- If no one is signed in to your app, keep the ref in your session, let them sign in or sign up, then exchange it. Never drop it: it is how the purchase reaches the right account without matching emails.
UtaOrderProcessingError(HTTP 202) means the payment cleared but the key is not stored yet. Show "finishing up" and retry after a second or two.- The receipt email carries the same link with
uta_order, so a buyer who closes the tab can finish later.
2. Validate at your gates
from usethatapp import validate_license_key
PRO = "prod_<your-pro-id>" # from Manage app, MCP list_products, or the Pricing API
state = validate_license_key(current_user.license_key)
if state.entitled and state.product_public_id == PRO:
unlock_pro()import { validateLicenseKey } from "usethatapp";
const PRO = "prod_<your-pro-id>"; // from Manage app, MCP list_products, or the Pricing API
const state = await validateLicenseKey(currentUser.licenseKey);
if (state.entitled && state.product_public_id === PRO) {
unlockPro();
}- Gate on
entitledandproduct_public_id.product_idcarries the same value. Never branch on the plan's display name. - Validate when a session starts and cache the answer in that session for up to a day, never past
period_end(nullfor one-time purchases, which do not expire). The limit is 120 calls a minute per server IP and app. - A subscription that moves to another plan keeps its key;
product_public_idreports the plan held now.
What the status means
| status | entitled | Meaning and what to do |
|---|---|---|
active | true | Paid subscription in good standing. |
trialing | true | In a free trial; is_trial is true and period_end is the conversion date. |
one_time_active | true | One-time purchase. It does not expire. |
past_due, unpaid | false | A renewal failed and the card is being retried. The same key returns to active if payment succeeds. Ask the buyer to update their card on the manage page; keep their data. |
paused | false | Suspended; may resume. |
canceled | false | Terminal: the paid period ran out after a cancellation, or retries were exhausted. |
A buyer who cancels keeps entitled: true until period_end; they paid for that period. Treat any status not listed here according to entitled. A canceled key still validates normally (with entitled: false); only a string that was never a key for your app raises UtaNotFoundError.
Apps without a return redirect
For a desktop or command-line app, let the buyer paste their key. It is on the checkout success page, in the receipt email, and on their manage page at any time. The app sends it to your backend, which calls validate_license_key.
Lost or leaked keys
Lost: send the buyer to their manage page, where the key is always visible. Do not rotate it — rotating breaks the copy your app has stored.
Leaked: rotate it by license id. The new key is returned once and the old one stops working immediately, so store the new key and deliver it to the customer yourself. Rotating a canceled license raises UtaLicenseCanceledError. Limit: 30 a minute.
from usethatapp import regenerate_license_key
state = regenerate_license_key(user.license_id)
user.license_key = state.license_key
save(user)import { regenerateLicenseKey } from "usethatapp";
const state = await regenerateLicenseKey(user.licenseId);
user.licenseKey = state.license_key;
await save(user);Errors
UtaNotFoundError with .code unknown_key, unknown_order or unknown_license: the value was never issued for your app. UtaConfigError: missing or rejected client credentials. UtaServerError: rate limited (wait retry_after / retryAfter seconds) or a server error; retry with backoff. Full table: errors.
