Handle 402 responses
AllowKit is designed to handle the 402 flow automatically once @allowkit/x402 ships (see the
roadmap). Understanding both sides clarifies what it takes off your plate.
Without AllowKit
Section titled “Without AllowKit”The developer must:
- parse the 402 response
- decide whether to pay
- sign/send the payment
- retry the request
- prevent duplicate payments
- log the transaction
With AllowKit
Section titled “With AllowKit”AllowKit is designed to handle:
- 402 detection
- payment requirement parsing
- policy evaluation
- payment execution
- retry with proof
- receipt generation
- duplicate payment protection (see Idempotency)
Sequence
Section titled “Sequence”Agent │ │ GET paid resource ▼Resource │ │ 402 Payment Required ▼AllowKit │ │ check policy + allowance │ pay if approved ▼Resource │ │ retry with payment proof ▼Agent receives response