Overview
This guide covers everything you need to know about authenticating with the Cred Protocol API, from creating API keys to implementing secure authentication in your applications.Authentication Methods
The Cred Protocol API supports two authentication methods:1. API Key Authentication (Recommended)
The standard authentication method using Bearer tokens. Every request includes your API key in theAuthorization header. Usage is tracked against your subscription’s Cred Unit balance.
2. x402 Payment Authentication (No Account Required)
For instant access without creating an account, you can pay per request using USDC stablecoins via the x402 protocol. This enables accountless API access with immediate settlement.x402 payments use the Coinbase Developer Platform (CDP) as a facilitator and support USDC on Base network.
Creating API Keys
Step-by-Step Guide
1
Sign In
Go to app.credprotocol.com and sign in to your account.
2
Navigate to Dashboard
Click on Dashboard in the navigation menu.
3
Access API Keys
Find the API Keys section in your dashboard.
4
Create New Key
Click Create API Key and enter a descriptive name for your key.
5
Copy and Store Securely
Copy your API key immediately and store it securely. You won’t be able to view the full key again.
Implementation Examples
Environment Variables
Always store your API key in environment variables:Backend Proxy Pattern
For web applications, create a backend proxy to keep your API key secure:SDK Pattern
Create a reusable client for your application:Security Best Practices
Never expose keys in client-side code
Never expose keys in client-side code
API keys should never be included in frontend JavaScript, mobile apps, or anywhere they can be viewed by end users.
Use environment variables
Use environment variables
Store API keys in environment variables, never in code:
- Use
.envfiles for local development - Use secret management services in production (AWS Secrets Manager, HashiCorp Vault, etc.)
- Never commit
.envfiles to version control
Rotate keys regularly
Rotate keys regularly
Establish a key rotation schedule:
- Create a new API key
- Update your application to use the new key
- Verify the new key works in production
- Revoke the old key
Use separate keys for environments
Use separate keys for environments
Create different API keys for:
- Development
- Staging
- Production
Monitor key usage
Monitor key usage
Regularly review your API usage in the Dashboard to:
- Detect unusual activity patterns
- Identify compromised keys
- Optimize your usage
Troubleshooting
Common Errors
401 Unauthorized
401 Unauthorized
403 Forbidden
403 Forbidden
- Accessing a feature not included in your plan
- Rate limit exceeded
- Check your plan limits in the Dashboard
- Upgrade your plan if needed
- Implement rate limiting in your application
Testing Your API Key
Use this simple test to verify your API key is working:x402 Payment Authentication
The x402 protocol enables instant API access by paying per request with USDC. This is ideal for:- Testing the API before committing to a subscription
- Low-volume usage where a subscription isn’t cost-effective
- Programmatic access from applications that can’t store API keys
- Instant access without account creation or approval delays
How It Works
- Make a request without authentication
- Receive a
402 Payment Requiredresponse with payment details - Sign a USDC transfer authorization using your wallet
- Retry the request with the signed payment in the
X-PAYMENTheader - Receive your API response (payment settles automatically)
Payment Required Response
When you make a request without authentication, you’ll receive:X-PAYMENT-REQUIRED header with base64-encoded payment requirements that x402-compatible wallets can process automatically.
Pricing
x402 payments use the same pricing as Cred Units at $0.01 per Cred Unit:| Operation | Cred Units | x402 Price |
|---|---|---|
| Credit Score | 1 CU | $0.01 |
| Full Report | 7 CUs | $0.07 |
| Enhanced Report | 10 CUs | $0.10 |
Supported Networks
- Production: Base (Mainnet)
- Testing: Base Sepolia