- Authenticate as a machine client (server-to-server)
- Provision an end-user in your app’s tenant
- Issue a signed, scoped JWT for that user
- Gate a request on the user’s entitlement balance
- Query usage to confirm metering is working
What you need:
curl, jq, and credentials from your PymtHouse app registration
Prerequisites
You need three values from your registered developer app. If you don’t have these yet, ask your platform admin or check your app’s settings page.Step 1 — Authenticate your backend
Exchange your M2M credentials for a short-lived machine token. This token authorizes Builder API calls on behalf of your app.scope=users:write users:token is the minimum needed for this guide. users:write lets you provision users; users:token lets you mint JWTs for them.Step 2 — Provision a user
Register a user in your app’s tenant. Use your own identifier — PymtHouse calls thisexternalUserId. This call is idempotent: running it again updates the existing record instead of creating a duplicate.
200 response confirms the user exists. PymtHouse automatically subscribes new users to the app’s Starter plan — they start with a default $5.00 USD allowance for AI job requests.
Step 3 — Issue a signed user JWT
Mint a short-lived access token scoped to this user. This is what you’ll pass to AI services as proof that this user is authorized to make a request.sub— the PymtHouse user record idazp/client_id— your publicapp_…client idscope—sign:job(gates this user to AI signing requests)
Authorization: Bearer ${USER_JWT} to any PymtHouse-integrated service.
Step 4 — Check the user’s entitlement balance
Before dispatching an AI request, verify the user has remaining balance. This is the access gate.hasAccess: true means the user can proceed. Gate your request on this field. When the balance is exhausted, hasAccess becomes false and the signer will reject requests with trial_credits_exhausted.
Step 5 — Query usage
After your first AI request goes through, verify it was metered:What’s next
You have the core flow working. Now wire it into your product:Integration patterns
Full working examples: SaaS app, CLI device flow, and metered billing. Pick the one that matches your architecture.
Builder SDK
Replace the curl calls with one TypeScript client.
mintSignerSessionForExternalUser handles upsert + mint + exchange in one call.Device flow
Add browser-based login for users authenticating from a CLI or terminal.
Billing setup
Connect Stripe, configure plans, and let users pay for usage beyond the Starter allowance.