Skip to main content

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

  1. Sign up at dashboard.hedgepay.com
  2. Navigate to Settings β†’ API Keys
  3. Generate your API credentials:
    • API Key: Public identifier for your application
    • API Secret: Secret key (keep this secure!)
    • Partner ID: Your unique partner identifier
Never expose your API Secret in client-side code or public repositories. Store it securely in environment variables.

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

Error Handling

Authentication errors return standard HTTP status codes:

Error Response Example

Security Best Practices

  • 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
  • Refresh tokens before expiry
  • Handle refresh failures gracefully
  • Implement exponential backoff for retries
  • Store refresh timestamps
  • Never expose API secrets in client-side code
  • Use server-side proxy for API calls
  • Implement CORS properly
  • Validate webhook signatures
  • 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