Overview
To query an AI agent, subscribers need to:- Have an active subscription to a plan associated with the agent
- Generate an x402 access token
- 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
| Parameter | Type | Required | Description |
|---|---|---|---|
plan_id | str | Yes | The payment plan ID |
agent_id | str | No | Target agent ID (recommended) |
token_options | X402TokenOptions | No | Scheme and delegation configuration |
Token Generation with Delegation
For erc4337 (crypto) plans, token generation now uses delegations. Two patterns are supported:Make Requests to Agents
Using the x402 Payment Header
Include the access token in thepayment-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