Examples

Use this page when you want end-to-end starting points rather than route-by-route explanation.

Base URLs

Auth patterns

Server-side merchant automation normally uses:
Session-assisted merchant tools can use:

Runnable Grok Build and Next.js example

Use the public example when you want a complete protected-resource application rather than isolated request snippets:
  • Guide: https://docs.hilt.so/developers/grok-build
  • Source: https://github.com/Hiltpay/hilt-developer-assets/tree/main/examples/grok-build-nextjs
It includes a protected Next.js route, Hilt entitlement checks, HTTP 402 responses, local and Hilt sandbox validation, live Hilt Pay API mode, raw-body webhook verification, tests, AGENTS.md, and a Grok project skill. The example keeps Hilt keys and sandbox proofs on the server. It serves protected content only after entitlement is active.

Example 1: Create a hosted access product

cURL

TypeScript

Set renewal_mode to ONE_OFF for single-payment products. Use native subscription setup for recurring products when the workspace has been enabled for it.

Official SDKs and Postman

If you want a faster start than hand-written fetch or requests, use the official developer assets:
  • TypeScript SDK: npm install @hiltpay/sdk
  • TypeScript SDK source: https://github.com/Hiltpay/hilt-sdk-js
  • Python SDK: pip install hilt-sdk
  • Python SDK source: https://github.com/Hiltpay/hilt-sdk-python
  • Developer assets repo: https://github.com/Hiltpay/hilt-developer-assets
The SDKs wrap the same examples shown below. The developer-assets repo carries public OpenAPI snapshots, Postman imports, and example webhook payloads for products, checkout, payments, memberships, receipts, support, and webhooks.

Example 2: Protect an AI API endpoint with Hilt Pay API

This is the metered Hilt Pay API runtime. Atomically consume one usage unit before billable work. When no unit is available, return HTTP 402 Payment Required with Hilt’s x402 V2 PAYMENT-REQUIRED header. On the paid retry, settle PAYMENT-SIGNATURE through Hilt, consume one unit, and serve. Solana USDC is the live settlement rail.

FastAPI

The complete runnable FastAPI example includes local no-money simulation, retry-idempotency tests, and webhook verification: examples/hilt-access-fastapi in the developer-assets repository.

Node and Express

Use the same rule in every framework:
  1. atomically consume one unit before billable work
  2. return 402 with Hilt’s PAYMENT-REQUIRED header when usage is missing
  3. let the buyer pay and retry with PAYMENT-SIGNATURE
  4. settle the signature through Hilt
  5. atomically consume one unit and serve only after consumption succeeds
POST /v1/access/entitlements/check is useful for durable or time-based access display and planning. It is not the authority for a billable metered request. Use this when your own bot or backend already knows who the buyer is before checkout.
Representative response:

Example 4: Start a buyer session and keep the payment id

cURL

What to keep from the response

Persist:
  • payment_id
  • amount_minor_units
  • merchant_amount_minor_units
  • asset_symbol
  • expires_at

Example 5: Poll payment status during an active buyer session

cURL

TypeScript

Use this when the buyer is still waiting on the checkout screen. For longer-running automation after checkout, prefer Hilt webhooks.

Python

Rust

Example 6: Read the post-payment trail

Look up a membership

Read receipts in Python

Example 7: Open a support ticket

Example 8: Continue a support thread

Example 9: Webhook consumer after checkout

If your application already has queue workers or background automation, native webhooks are now the cleanest Hilt integration.

TypeScript

Python

Example rule of thumb

The simplest reliable pattern is:
  1. let Hilt run checkout and settlement
  2. keep the payment_id
  3. let your backend react to webhook events afterwards
  4. read GET /v1/payments/{payment_id} only when the buyer is actively waiting or you need a fallback check
That is usually cleaner than rebuilding the payment, membership, receipt, and support state machine yourself.

Common questions

Which Hilt example should I copy first?

Start with product creation, then signed handoff or checkout session start, then payment status, then webhook handling.

Do the examples replace the SDKs?

No. The examples show the underlying API patterns. Use the SDKs when you want typed helpers and less hand-written request code.

What is the safest example pattern?

Let Hilt run hosted checkout and settlement, store payment_id, and react to signed webhook events after checkout.