Authentication
Open Pay uses three distinct authentication mechanisms, each designed for a specific integration pattern.JWT Authentication
JWT authentication is used by the Merchant Portal and Admin Dashboard for user sessions.Login Flow
1
Authenticate
Send your credentials to the login endpoint:
2
Use the Access Token
Include the access token in the
Authorization header for all subsequent requests:3
Refresh When Expired
Access tokens expire after 15 minutes. Use the refresh token to obtain a new pair:
Refresh tokens are valid for 7 days and are single-use. Each refresh returns a new token pair.
Token Details
Two-Factor Authentication (2FA)
Open Pay supports TOTP-based two-factor authentication for portal users.1
Enable 2FA
Request a TOTP secret and QR code from the setup endpoint:
2
Verify and Activate
Submit a TOTP code from the authenticator app to confirm setup:
3
Login with 2FA
When 2FA is enabled, the login response returns
requires2FA: true instead of tokens. Submit the TOTP code to complete authentication:HMAC-SHA256 Authentication
HMAC-SHA256 is used for server-to-server API calls via SDKs or direct integration. Every request is signed with your API secret to ensure authenticity and prevent tampering.Required Headers
Signing Algorithm
The signature is computed as:- apiSecret is your secret key (from the Integrations page)
- timestamp is the value of the
X-Timestampheader - method is the uppercase HTTP method (
GET,POST, etc.) - path is the request path including query string (e.g.,
/v1/payments?limit=10) - body is the raw JSON request body (empty string for GET requests)
The server rejects requests where the timestamp differs from server time by more than 5 minutes to prevent replay attacks.
Code Examples
Error Responses
ED25519 Webhook Signatures
All outgoing webhooks from Open Pay are signed with an ED25519 private key. This allows you to verify that a webhook genuinely originated from Open Pay and has not been tampered with.Verification Flow
1
Retrieve the Public Key
Fetch the platform’s ED25519 public key (you can cache this):
2
Extract the Signature Headers
Each webhook request includes two signature headers:
The signed message is the concatenation of the timestamp and the raw JSON body:
3
Verify the Signature
Use the public key to verify the signature against the constructed message.
4
Prevent Replay Attacks
Always validate the timestamp to reject stale webhook deliveries:
Webhook Event Types
Best Practices
Never Expose Secrets Client-Side
API secrets and signing logic must live on your server. Never include them in frontend JavaScript or mobile app bundles.
Rotate Keys Periodically
Generate new API keys from the Integrations page and deprecate old ones. Open Pay supports multiple active keys per merchant for zero-downtime rotation.
Always Verify Webhooks
Never trust webhook payloads without verifying the ED25519 signature. Treat unverified payloads as potentially malicious.
Use Environment Variables
Store API keys, secrets, and webhook public keys in environment variables or a secrets manager — never hardcode them in source code.