On this page
createTokenPurchase
mutation · in the family Token purchase
What it does
Buy kernels — top up your group’s prepaid balance.
Buy platform tokens for the caller's group: resolves the group's wallet via the singleton marker (no wallet → NOT_FOUND/CONSTRUCT: open the TokenAccount first; a PAUSED wallet refuses CONFLICT/REF_STATE), gates real money by classification × Stripe mode (ruling — live-mode requires a production group; test-mode legal always), resolves the volume tier + computes tokensPurchased SERVER-side, mints the platform TEST PaymentIntent with the ruling- join metadata BEFORE the record (PI-first — a processor refusal aborts with NOTHING written; an orphaned TEST intent is the deferral-14a reconcile class), then commits the record carrying the pi_… ref. Settlement is the WEBHOOK's (ruling — the existing 8-event roster; succeeded posts the purchase entry + balance atomically; failed/canceled settles failed). Requires the unrestricted capability. Template class A16_BILLING (hand-derived v23).
What happens
Charges your billing method and credits the balance in one recorded purchase.
Careful
Real money for platform credits.
Who may call it
Capability area: Billing and the wallet — Your platform bill, token purchases and the usage and cost reads.
- Owner
- Manager
- Associate Manager
- An API key whose scope allows
api:createTokenPurchase
Arguments
| Name | Type | Required | Notes |
|---|---|---|---|
input | NewTokenPurchaseInput NewTokenPurchaseInput! | yes | No further notes. |
Returns
TokenPurchase TokenPurchase! — A TokenPurchase — buying platform tokens with real money (**Stripe primary**; ACH/wire/invoiced = deferral 7): $ → tokens at the volume tier (tier_1 | tier_2 | tier_3 — SERVER-computed, never client-asserted), loaded into the GROUP's TokenAccount as a purchase TokenEntry when the webhook settles. **AT/stack charging the MERCHANT** — the platform account's OWN PaymentIntent (distinct from the merchant's customer Payments and the Connect plane). **NON-REFUNDABLE**. The FSM is the ratified 3-STATE table VERBATIM: created(i) → succeeded ▣ / failed ✦, BOTH edges system:stripe_webhook — NO caller transitions and NOTHING mutable between birth and settlement ⇒ the wire realizes {create:true, update:false, transitions:false} (a NEW suppression combination — the webhook-settled document). The birth op mints the TEST PaymentIntent api-side with the LOAD-BEARING metadata {at_kind, tokenPurchaseId, rootId} (ruling — the lesson: PI metadata IS the join key; the EXISTING platform 8-event endpoint roster covers the lane — payment_intent.succeeded/payment_failed/canceled; canceled settles failed). The real-money gate = classification × Stripe MODE (ruling: live-mode charges require a production-classified group; test-mode is legal for ANY classification — that is how the goldens run; the mode derives from the custodied key, never asserted). Purchase-abandon reconciliation beyond canceled = deferral 14a. NOT searchable. Template class A16_BILLING (hand-derived v23).
Example request
mutation ExampleCreateTokenPurchase($input: NewTokenPurchaseInput!) {
createTokenPurchase(input: $input) {
id
sysId
type
caption
status
parentId
rootId
createdAt
updatedAt
revisionNum
revision
usdAmountCents
tokensPurchased
volumeTierCode
rateCardVersion
stripePaymentIntentId
settledAt
}
}
Variables:
{
"input": {
"caption": "Blue jeans",
"usdAmountCents": 1
}
}
Send it with the envelope naming the version: "extensions": {"at": {"version": {"name":"genesis","number":0}}}.
Example response
{
"data": {
"createTokenPurchase": {
"id": "01900000-0000-7000-8000-37386ae00000",
"sysId": "TP-EXMP-0000-000F",
"type": "TokenPurchase",
"caption": "Blue jeans",
"status": "created",
"parentId": "01900000-0000-7000-8000-065235280000",
"rootId": "01900000-0000-7000-8000-a093dd800000",
"createdAt": "2027-01-31T00:00:00.000Z",
"updatedAt": "2027-01-31T00:00:00.000Z",
"revisionNum": 1,
"revision": "01900000-0000-7000-8000-b7960e180000",
"usdAmountCents": 1,
"tokensPurchased": 1,
"volumeTierCode": "BJ-001",
"rateCardVersion": 1,
"stripePaymentIntentId": "<stripe payment intent id>",
"settledAt": "2027-01-31T00:00:00.000Z"
}
},
"extensions": {
"at": {
"callId": "01EXAMPLE-CALL-ID",
"version": {
"requested": {
"name": "genesis",
"number": 0
},
"serviced": {
"name": "genesis",
"number": 0
}
}
}
}
}
Errors this call can answer
VALIDATION/INVALID— Something in the request is not valid. (VALIDATION)AUTHN/REQUIRED— Sign in to do this. (AUTHN)AUTHZ/FORBIDDEN— Your role does not allow this action. (AUTHZ)RATE_LIMIT/THROTTLED— Too many requests in a short time. (RATE_LIMIT)CONFLICT/*— The record’s state, or a change made in the meantime, does not allow this; the codes are on the CONFLICT page. (CONFLICT)VALIDATION/VERSION_REQUIRED— The request did not say which app version it came from. (VALIDATION)