Overview
The Hedge Pay API uses JWT (JSON Web Tokens) for authentication. All API requests must include a valid access token in the Authorization header.Access tokens expire after 7 days. We recommend implementing automatic token refresh to avoid service interruptions.
Authentication Flow
Getting Your Credentials
- Sign up at dashboard.hedgepay.com
- Navigate to Settings → API Keys
- Generate your API credentials:
- API Key: Public identifier for your application
- API Secret: Secret key (keep this secure!)
- Partner ID: Your unique partner identifier
Generate Access Token
Exchange your API credentials for an access token:Response
Using the Access Token
Include the access token in the Authorization header for all API requests:Token Refresh
Refresh your token before it expires to maintain uninterrupted service:Token Revocation
Revoke a token when it’s no longer needed:Scopes and Permissions
Tokens are issued with specific scopes that determine API access:Environment-Specific Endpoints
- Production
- Sandbox
Error Handling
Authentication errors return standard HTTP status codes:Error Response Example
Security Best Practices
Store Credentials Securely
Store Credentials Securely
- Never commit API secrets to version control
- Use environment variables or secret management services
- Rotate API keys regularly
- Use different keys for development and production
Implement Token Refresh
Implement Token Refresh
- Refresh tokens before expiry
- Handle refresh failures gracefully
- Implement exponential backoff for retries
- Store refresh timestamps
Secure Client Applications
Secure Client Applications
- Never expose API secrets in client-side code
- Use server-side proxy for API calls
- Implement CORS properly
- Validate webhook signatures
Monitor and Audit
Monitor and Audit
- Log all authentication events
- Monitor for unusual patterns
- Set up alerts for failed authentications
- Review API key usage regularly
SDK Authentication
Our SDKs handle authentication automatically:Next Steps
API Reference
Start making API calls
Webhooks
Set up webhook authentication

