Skip to main content

Getting started with Flask

Start accepting x402 payments in your Flask server in 2 minutes.
You can find the full code for this example here.

Step 1: Install dependencies

Step 2: Set your environment variables

Your .env file should look like this:

Step 3: Create a new Flask app

Step 4: Run the server

Your server is now accepting x402 payments!

Step 5: Test the server

You can test payments against your server locally by following the httpx example or the requests example from the x402 repository. Just set your environment variables to match your local server, install the dependencies, and run the examples.

x402 reference

For a deeper dive into message shapes, headers, verification and settlement responses, see the x402 Reference.

Need help?

Join our Community

Have questions or want to connect with other developers? Join our Discord server.