Documentation
Everything you need to get started with PayFence.
Quick Start Guide
Follow these steps to start monetizing your API with PayFence. Most teams are up and running in under 10 minutes.
- 1
Create your PayFence account
Sign up at app.payfence.io. You can sign in with Google, GitHub, or email. No credit card required to get started.
- 2
Register your API site
Add a new site with a name, your API's origin URL, and a URL-friendly slug. The slug becomes part of your PayFence gateway URL.
- 3
Connect your Stripe account
Link your Stripe account through Stripe Connect. This enables PayFence to create subscriptions and process payments on your behalf. All revenue flows directly to your Stripe account.
- 4
Create access plans
Define one or more pricing plans with monthly or annual billing, request quotas, and rate limits. Each plan maps to a Stripe product and price automatically.
- 5
Mark endpoints as paid
Specify which endpoint path patterns require a valid subscription. Unprotected endpoints are passed through without enforcement.
- 6
Share your gateway URL or install the SDK
Point your customers to your PayFence gateway URL, or install the PayFence middleware SDK in your application for in-process enforcement. Both modes provide the same access control and quota management.
Glossary
Key terms and concepts used throughout PayFence.
- Site
- Your API or MCP tool endpoint registered in PayFence. Each site has a name, origin URL, and a unique slug. A site is the top-level container for plans, resources, and tokens.
- Plan
- A pricing tier with request quotas and billing configuration. Plans define how much a customer pays and how many requests they are allowed to make within a billing period.
- Token
- An API key issued to a paying customer when they subscribe to a plan. Tokens are included in request headers and used by PayFence to identify the customer and enforce quotas.
- Entitlement
- The usage allowance tied to a customer's active subscription. Entitlements track remaining request counts, billing period boundaries, and quota resets.
- Resource
- An endpoint path pattern that requires payment. Resources are defined as URL patterns (e.g.,
/api/v1/*) and are matched against incoming requests to determine whether enforcement applies. - Decision
- The allow-or-deny verdict that PayFence issues for each incoming request. Decisions are based on token validity, subscription status, and remaining quota. Every decision is logged for analytics and debugging.
Frequently Asked Questions
Do I need to change my API code to use PayFence?
No. In proxy mode, PayFence sits in front of your API as a reverse proxy. Your API receives the same requests it always has -- PayFence just validates access before forwarding them. If you prefer tighter integration, the middleware SDK lets you add enforcement with a single line of code in your application.
Does PayFence read or store my request bodies?
No. PayFence only inspects request metadata such as headers, URL paths, and query parameters. Request and response bodies are passed through untouched and are never stored by PayFence. This ensures your data privacy and minimizes latency overhead.
How do my customers get their API keys?
When a customer subscribes to one of your plans through the PayFence checkout flow, they receive a token (API key) automatically. They include this token in the Authorization header of their API requests. You can also issue tokens manually from the dashboard.
What happens when a customer exceeds their quota?
PayFence returns a 429 Too Many Requests response with headers indicating the quota limit, remaining count, and reset time. The customer can upgrade their plan or wait for the quota to reset at the start of their next billing period.
How does billing work? Where does the money go?
PayFence uses Stripe Connect so payments from your customers flow directly to your Stripe account. PayFence collects a platform fee on each transaction. You manage payouts, refunds, and disputes through your Stripe dashboard as usual.
Can I use PayFence with MCP tool endpoints?
Yes. PayFence works with any HTTP endpoint, including MCP (Model Context Protocol) tool servers. As AI agents increasingly call tools via HTTP, PayFence lets you monetize and control access to those tool endpoints the same way you would a traditional REST API.
Need more help?
We're here to help you get set up. Book a demo call or reach out to our team.