Before starting, ensure the x402 feature flag is enabled on your account. Contact [email protected] if you need access.
Prerequisites
- Pinata account with x402 feature flag enabled
- API JWT from Pinata App
- Private file uploaded to Pinata
- Ethereum wallet address to receive payments
Step 1: Upload a Private File
First, upload a file to Private IPFS:cid for the next step.
Step 2: Create a Payment Instruction
Define your payment requirements:max_amount_required uses USDC’s smallest unit. USDC has 6 decimals, so to convert USD to the token amount, multiply by 1,000,000:
| USD Amount | max_amount_required | Calculation |
|---|---|---|
| $0.01 | "10000" | $0.01 × 1,000,000 |
| $0.10 | "100000" | $0.10 × 1,000,000 |
| $1.00 | "1000000" | $1.00 × 1,000,000 |
| $5.00 | "5000000" | $5.00 × 1,000,000 |
| $10.00 | "10000000" | $10.00 × 1,000,000 |
- Production: Use
"base"with0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 - Testing: Use
"base-sepolia"with0x036CbD53842c5426634e7929541eC2318f3dCF7e
id for the next step.
Step 3: Attach CID to Payment Instruction
Link your private file to the payment instruction:{instruction_id} with the ID from Step 2 and {cid} with the CID from Step 1.
Step 4: Share Your Monetized Content
Your file is now monetized! Share this URL with requesters:Replace
your-gateway.mypinata.cloud with your actual dedicated Pinata gateway domain (e.g., my-gateway.mypinata.cloud), and {cid} with your file’s CID.Step 5: Test the Payment Flow
When a requester accesses your URL without payment, the gateway returns a 402 response with payment requirements:X-Payment header.
Next Steps
- Manage Multiple Files: Attach multiple CIDs to the same payment instruction
- Update Pricing: Use the Update Payment Instruction endpoint
- Monitor Access: Check your gateway analytics to track paid downloads
- Requester Guide: Learn how requesters access paid content in the Accessing Paid Content guide
Common Issues
404 Not Found: Verify the CID is private and correctly attached to a payment instruction 403 Forbidden: Check that your API key has the required permissions (OrgFilesWrite)
409 Conflict: If deleting a payment instruction fails, remove all CID attachments first
Need help? Contact [email protected]