> For the complete documentation index, see [llms.txt](https://memolabs.gitbook.io/memo-gitbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://memolabs.gitbook.io/memo-gitbook/memo-docs-cn/memo-aiagent/x402-introduction/http-402.md).

# HTTP 402

数十年来，HTTP 402 Payment Required 一直被保留“未来使用”。x402 激活了它，并尝试“赎回互联网最初的原罪”（原文链接：[absolves the internet of its original sin](https://economyofbits.substack.com/p/marc-andreessens-original-sin)）。

## 什么是 HTTP 402？

[HTTP 402](https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.2) 是一个标准但极少被实际应用的 HTTP 响应状态码，表示访问该资源需要支付费用。

在 x402 中，该状态码被正式启用，用于：

* 告知客户端（买家或智能代理）该资源需要支付。
* 传递支付的具体信息：金额、币种、目标地址等。
* 提供完成支付所需的程序化（机器可处理）信息。

## 为什么 x402 使用 HTTP 402

HTTP 402 的核心价值在于：让访问 Web 资源的支付可以“无摩擦、原生 API 化”。这对以下场景尤其重要：

* 机器对机器（M2M）支付（如 AI Agent）。
* 按次 / 按量付费模式（API 调用、内容按次访问等）。
* 无需账号注册、无需传统支付渠道的微支付。

使用 402 状态码使得 x402 协议保持与 Web 原生兼容，可轻松嵌入任意基于 HTTP 的服务中。

## 总结

HTTP 402 是 x402 协议的基础：服务可以在标准的 HTTP 响应中直接声明支付要求。它的作用包括：

* 明确标识：需要支付
* 传递细节：支付所需的全部关键字段
* 无缝集成：融入已有的 HTTP 请求-响应工作流

借助 HTTP 402，支付不再是“跳出协议之外的附加流程”，而成为开放 Web 中一个标准、可自动化的组成部分。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://memolabs.gitbook.io/memo-gitbook/memo-docs-cn/memo-aiagent/x402-introduction/http-402.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
