Keep the meanings of token separate

Tokenized Stacks API

Token can mean an API credential, a unit of model text, a usage entitlement, or a blockchain asset. This guide separates those meanings and focuses on access and metering design: what the caller may do, how consumption is recorded, and how expiry, revocation, retries, and recovery should behave.

Define what your token represents

Start by naming the unit and its purpose. An access token represents authorization. A usage credit represents an entitlement defined by a service. A language-model token is a processing unit within a model's text representation. A blockchain asset belongs to another system with its own rules. Using one word for all four can make a product description or API contract misleading.

For access design, the OAuth bearer-token specification explains that possession of a bearer token can be sufficient to access the associated resources. Protect credentials in storage and transport, and keep them out of public example files, page source, and ordinary logs. The token's visible string is not a safe place to infer its permissions.

Separate authorization from consumption

Define the operations a credential permits independently from how much usage remains. An account may have credits but lack permission for a particular resource. A valid credential may have expired entitlements. Model those conditions explicitly so clients receive an understandable result and the application can audit why a request was accepted or rejected.

Specify how credentials expire, are revoked, and are replaced. Plan the experience for a legitimate client whose token stops working. Keep the affected identity and scope available for diagnosis without exposing the secret itself. Avoid making a long-lived credential the only recoverable proof of account ownership.

Make metering consistent under retries

If requests consume credits, decide when consumption occurs: at acceptance, at completion, or according to measured work. Define behavior for failed operations, partial results, and repeated requests. A network interruption should not leave the accounting policy dependent on whether the client happened to receive the final response.

Keep usage records explainable to the account owner. Record the operation identifier, unit, quantity, and outcome needed to reconcile a balance. When a model service reports token usage, preserve the provider's unit definitions and distinguish them from your product's own credit system. Do not imply that the two are automatically equivalent.

Keep the product claim precise

Choose ordinary access controls and metering when they meet the requirement. If blockchain-based entitlement is being considered, document the additional system and recovery assumptions separately. StacksAPI.com discusses these design distinctions; it does not issue tokens, sell investment products, or operate the separate Stacks blockchain API.