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:| Scope | Description |
|---|---|
users:read | Read user information |
users:write | Create and update users |
accounts:read | View connected bank accounts |
accounts:write | Connect and disconnect accounts |
transfers:read | View transfer history |
transfers:write | Initiate and cancel transfers |
roundups:read | View round-up settings |
roundups:write | Modify round-up settings |
webhooks:write | Manage webhook subscriptions |
Environment-Specific Endpoints
- Production
- Sandbox
Error Handling
Authentication errors return standard HTTP status codes:| Status Code | Error | Description |
|---|---|---|
401 | INVALID_CREDENTIALS | Invalid API key or secret |
401 | TOKEN_EXPIRED | Access token has expired |
401 | TOKEN_INVALID | Malformed or invalid token |
403 | INSUFFICIENT_SCOPE | Token lacks required permissions |
429 | RATE_LIMITED | Too many authentication attempts |
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

