Skip to content

Commit 9c10c5e

Browse files
docs: use x402 v2 header names (PAYMENT-REQUIRED, PAYMENT-SIGNATURE, PAYMENT-RESPONSE) (#650)
1 parent 9339cff commit 9c10c5e

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/pages/guides/upgrade-x402.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ MPP builds on the same `402` pattern that x402 established, and extends it with
1818

1919
| | x402 | MPP |
2020
|---|---|---|
21-
| **Challenge** | `X-PAYMENT-REQUIRED` header | `WWW-Authenticate: Payment` header |
22-
| **Credential** | `X-PAYMENT` header | `Authorization: Payment` header |
23-
| **Receipt** | `X-PAYMENT-RESPONSE` header | `Payment-Receipt` header |
21+
| **Challenge** | `PAYMENT-REQUIRED` header | `WWW-Authenticate: Payment` header |
22+
| **Credential** | `PAYMENT-SIGNATURE` header | `Authorization: Payment` header |
23+
| **Receipt** | `PAYMENT-RESPONSE` header | `Payment-Receipt` header |
2424
| **Payment methods** | Stablecoins only | Stablecoins, cards, digital wallets, and many other methods |
2525
| **Sessions** | No | Yes—off-chain vouchers for sub-cent streaming |
2626
| **Error format** | Custom | [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) Problem Details |
@@ -40,9 +40,9 @@ The request lifecycle is the same—only the header names and encoding change.
4040
participant Client
4141
participant Server
4242
Client->>Server: GET /resource
43-
Server-->>Client: 402 + X-PAYMENT-REQUIRED
44-
Client->>Server: GET /resource + X-PAYMENT
45-
Server-->>Client: 200 + X-PAYMENT-RESPONSE
43+
Server-->>Client: 402 + PAYMENT-REQUIRED
44+
Client->>Server: GET /resource + PAYMENT-SIGNATURE
45+
Server-->>Client: 200 + PAYMENT-RESPONSE
4646
`} />
4747

4848
**MPP**
@@ -60,30 +60,30 @@ The request lifecycle is the same—only the header names and encoding change.
6060

6161
MPP uses three protocol objects in every payment flow—the same lifecycle x402 uses, with standardized names:
6262

63-
- **Challenge** — The server's `402` response advertising what payment is required. Sent in the `WWW-Authenticate: Payment` header. Equivalent to x402's `X-PAYMENT-REQUIRED`.
64-
- **Credential** — The client's signed payment authorization. Sent in the `Authorization: Payment` header. Equivalent to x402's `X-PAYMENT`.
65-
- **Receipt** — The server's confirmation that payment settled. Sent in the `Payment-Receipt` header. Equivalent to x402's `X-PAYMENT-RESPONSE`.
63+
- **Challenge** — The server's `402` response advertising what payment is required. Sent in the `WWW-Authenticate: Payment` header. Equivalent to x402's `PAYMENT-REQUIRED`.
64+
- **Credential** — The client's signed payment authorization. Sent in the `Authorization: Payment` header. Equivalent to x402's `PAYMENT-SIGNATURE`.
65+
- **Receipt** — The server's confirmation that payment settled. Sent in the `Payment-Receipt` header. Equivalent to x402's `PAYMENT-RESPONSE`.
6666

6767
## Running MPP and x402 side by side
6868

6969
MPP and x402 use completely different HTTP headers (see [comparison above](#what-mpp-adds)), so they coexist on the same server without conflict. This lets you adopt MPP incrementally—add it to new endpoints while existing x402 clients continue working.
7070

71-
A single `402` response can include **both** sets of headers simultaneously. x402 clients read `X-PAYMENT-REQUIRED` and ignore `WWW-Authenticate`, while MPP clients read `WWW-Authenticate: Payment` and ignore the `X-` headers.
71+
A single `402` response can include **both** sets of headers simultaneously. x402 clients read `PAYMENT-REQUIRED` and ignore `WWW-Authenticate`, while MPP clients read `WWW-Authenticate: Payment` and ignore the x402 headers.
7272

7373
```http
7474
HTTP/1.1 402 Payment Required
7575
WWW-Authenticate: Payment id="abc", realm="api.example.com",
7676
method="tempo", intent="charge", request="eyJ..."
77-
X-PAYMENT-REQUIRED: {"scheme":"exact","network":"base-sepolia",
77+
PAYMENT-REQUIRED: {"scheme":"exact","network":"base-sepolia",
7878
"maxAmountRequired":"10000","resource":"..."}
7979
```
8080

81-
On the return trip, MPP clients send `Authorization: Payment <credential>` while x402 clients send `X-PAYMENT: <payload>`. Your server checks which header is present and verifies accordingly:
81+
On the return trip, MPP clients send `Authorization: Payment <credential>` while x402 clients send `PAYMENT-SIGNATURE: <payload>`. Your server checks which header is present and verifies accordingly:
8282

8383
```ts [server.ts]
8484
app.get('/api/data', (req, res, next) => {
8585
const hasPayment = req.headers['authorization']?.startsWith('Payment ')
86-
const hasX402 = !!req.headers['x-payment']
86+
const hasX402 = !!req.headers['payment-signature']
8787

8888
if (hasPayment) {
8989
return mppx.charge({ amount: '0.01' })(req, res, next)
@@ -93,15 +93,15 @@ app.get('/api/data', (req, res, next) => {
9393
}
9494

9595
// No credential — advertise both protocols
96-
res.setHeader('X-PAYMENT-REQUIRED', JSON.stringify(x402Challenge))
96+
res.setHeader('PAYMENT-REQUIRED', JSON.stringify(x402Challenge))
9797
mppx.charge({ amount: '0.01' })(req, res, () => {})
9898
}, (req, res) => {
9999
res.json({ data: 'premium content' })
100100
})
101101
```
102102

103103
:::tip
104-
Because MPP uses the standard `WWW-Authenticate` scheme, it works with HTTP intermediaries (proxies, CDNs, API gateways) that understand [RFC 7235](https://www.rfc-editor.org/rfc/rfc7235) authentication. x402's custom `X-` headers are opaque to these intermediaries.
104+
Because MPP uses the standard `WWW-Authenticate` scheme, it works with HTTP intermediaries (proxies, CDNs, API gateways) that understand [RFC 7235](https://www.rfc-editor.org/rfc/rfc7235) authentication. x402's custom `PAYMENT-*` headers are opaque to these intermediaries.
105105
:::
106106

107107
## Prompt mode

src/pages/mpp-vs-x402.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ Choose **x402** only if you explicitly want a narrow, stablecoin-focused paywall
2323
|---|---|---|
2424
| **Core model** | Stablecoin payment attached to a request | General payment protocol for machine-to-machine payments |
2525
| **HTTP status** | `402 Payment Required` | `402 Payment Required` |
26-
| **Challenge header** | `X-PAYMENT-REQUIRED` | `WWW-Authenticate: Payment` |
27-
| **Credential header** | `X-PAYMENT` | `Authorization: Payment` |
28-
| **Receipt header** | `X-PAYMENT-RESPONSE` | `Payment-Receipt` |
26+
| **Challenge header** | `PAYMENT-REQUIRED` | `WWW-Authenticate: Payment` |
27+
| **Credential header** | `PAYMENT-SIGNATURE` | `Authorization: Payment` |
28+
| **Receipt header** | `PAYMENT-RESPONSE` | `Payment-Receipt` |
2929
| **Payment methods** | Blockchain-based methods | Stablecoins, cards, Lightning, wallets, and custom methods |
3030
| **Sessions / streaming** | No native session flow | Yes—session intent for pay-as-you-go billing |
3131
| **Request binding** | Narrower | First-class Challenge binding and request digest support |

0 commit comments

Comments
 (0)