---
title: "Top up credits with an x402 payment (agent-native)"
method: POST
path: "/api/billing/credits/x402"
---

# Top up credits with an x402 payment (agent-native)

`POST /api/billing/credits/x402`

## Request

- Base URL: `https://www.trezalabs.com`
- URL: `https://www.trezalabs.com/api/billing/credits/x402`
- Auth: HTTP bearer

Adds a fixed amount of Treza credit per call, paid via the x402 protocol (HTTP 402): call without payment to receive a 402 challenge carrying the price and networks, sign the payment with an x402-capable wallet, and retry with the payment-signature header. The challenge lists two ways to pay the same amount: USDC on Base (eip155:8453) first, then USDC on Solana mainnet (solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp); a client pays the first one it has a wallet for, and neither needs gas money in the paying wallet. Grants are idempotent per settled transaction. A bearer (API key, OAuth token, or session) is optional and only chooses which account is credited; without one the credits are keyed to the paying wallet, so an agent holding nothing but a wallet can still fund itself. A Base wallet and a Solana wallet are separate accounts, and their balances are not shared. Only available when the deployment has x402 enabled; the balance endpoint's x402 field says so.

## Response `200`

Credits granted

- object
  - `grantedUsd` number
  - `duplicate` boolean: True when this payment was already credited (idempotent replay).
  - `balanceUsd` number
  - `network` string: Where the payment settled: eip155:8453 (Base) or solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp (Solana).

## Other responses

- `401`: A bearer was sent and is invalid, or the request carried neither a bearer nor a settled payer
- `402`: Payment required: the challenge response carrying x402 payment instructions
- `429`: Rate limit exceeded
- `503`: x402 payments are not enabled on this deployment

---

[API](https://skmtc.dev/trezalabs/apis/treza-pipelines-api.md) · [All operations](https://skmtc.dev/trezalabs/apis/treza-pipelines-api/llms.txt) · [OpenAPI document](https://skmtc.dev/trezalabs/apis/treza-pipelines-api/revisions/a76574c1731b?raw)
