Skip to main content
This guide explains how to get x402 access tokens and make authenticated requests to AI agents.

Overview

To query an AI agent, subscribers need to:
  1. Have an active subscription to a plan associated with the agent
  2. Generate an x402 access token
  3. Include the token in requests to the agent

Get X402 Access Token

The x402 access token authorizes requests to agents and enables credit verification/settlement.

Token Generation Parameters

Token Generation with Delegation

For erc4337 (crypto) plans, token generation uses delegations. The supported flow is create-first: create the delegation once, then reference it by delegation_id on every token request. Delegations are plan-agnostic by default, so a single delegation can back token requests across many plans.
Deprecated: passing spending_limit_cents / duration_secs (or a payment method) directly to get_x402_access_token — inline “create-on-the-fly” — still works but emits a DeprecationWarning and will be removed in a future release. Create the delegation first as shown above.

Make Requests to Agents

Using the x402 Payment Header

Include the access token in the payment-signature header (per x402 v2 HTTP transport spec):

Decode Access Token

You can decode the token to inspect its contents:

Complete Example

Error Handling

402 Payment Required

Token Expired or Invalid

Request Flow Diagram

Next Steps

Request Validation

How agents validate incoming requests

x402 Protocol

Deep dive into x402 verification and settlement