Agent-to-agent micropayments

Hilt Pay API turns a paid agent request into durable operating state:
  • an x402 V2 payment requirement
  • confirmed Solana USDC settlement
  • a signed receipt
  • an entitlement with metered units
  • atomic usage records
  • webhook and support context
The public API namespace is /v1/access. x402 is the HTTP 402 Payment Required protocol shape. Solana USDC is the current public live settlement rail.

The runtime rule

For a metered endpoint, consume one unit before serving the result.
  1. Identify the calling customer or agent.
  2. Call POST /v1/access/entitlements/consume.
  3. Serve the resource when consumption succeeds.
  4. When access is missing or exhausted, create an x402 payment session.
  5. Return 402 with Hilt’s PAYMENT-REQUIRED header.
  6. Receive the buyer’s PAYMENT-SIGNATURE header.
  7. Call POST /v1/access/x402/settle.
  8. Consume one unit and serve the resource.
This avoids a check-then-use race. An entitlement check is useful for display and planning; atomic consumption is the authority for each metered request.

Create a metered product

amount_minor_units uses USDC’s six decimal places. The example price is 5 USDC.

Create the challenge

Relay the response’s encoded PAYMENT-REQUIRED value exactly. Do not rebuild the acceptance in your application. The product allows the Solana USDC settlement rail. The session selects payment_protocol: "x402" separately because x402 is the HTTP payment protocol, not a settlement rail.

Hilt exact payments

x402 allows payment schemes to define how value moves on each network. Hilt uses hilt-exact when the payment includes a Hilt platform fee. The acceptance contains:
  • the gross amount the buyer approves
  • the merchant’s direct USDC transfer
  • Hilt’s direct fee transfer
  • a requirement that both transfers share one signed Solana transaction
The API verifies the scheme, network, mint, gross amount, each recipient, each amount, the transfer authority, transaction signature, and instruction set. Unexpected instructions or changed payment terms are rejected before submission. When no second transfer is required, the acceptance can use the standard x402 exact scheme.

Sign and retry

Install the Hilt SDK plus the Solana libraries used by your wallet integration:
The buyer wallet constructs the two advertised USDC transfers and signs them as one transaction. The protected-resource server receives PAYMENT-SIGNATURE and calls hilt.payApi.settleX402(...) with its server-side key. The complete TypeScript example includes both boundaries and the Solana transaction builder.

Atomic usage consumption

Use the same stable request ID when retrying the same billable operation. Use a new ID for a new operation.

What Hilt records

Each successful payment can create or update:
  • payment and settlement evidence
  • signed receipt
  • entitlement period
  • granted and remaining usage
  • idempotent usage events
  • merchant webhook events
  • support and audit context
This is the difference between accepting a transaction and operating a paid agent product.

Safety boundaries

  • Never expose the Hilt API key to a browser or agent client.
  • Never grant access from a raw transaction hash or unverified wallet claim.
  • Never consume usage after serving the resource.
  • Never treat x402 as a chain, token, wallet, or settlement rail.
  • Use Hilt sandbox sessions to test payment, confirmation, and metered consumption without moving live funds.
  • Use setup readiness before accepting live traffic.
See Hilt Pay API, API keys, Testing, and Webhooks.