Payment Processing
Get Public Key
Retrieves the public key for encrypting credit card information
GET
Get Public Key
Overview
This endpoint retrieves the current public key used for encrypting credit card data before sending it to Firmly’s payment endpoints. The key supports multiple formats to accommodate different encryption libraries and platforms.The public key is rotated periodically for security. Always fetch the current key before encrypting payment data rather than caching it for extended periods.
Authentication
This endpoint requires no authentication and is publicly accessible.Query Parameters
The format of the public key to returnSupported formats:
JWK- JSON Web Key format (default)PEM- Privacy Enhanced Mail formatRSA- PEM using RSAPublicKey format
Response Headers
The key identifier (kid) - present for all formats
Response Formats
JWK Format (Default)
Returns a JSON Web Key with the following properties:Key identifier/version
Key type (always “RSA”)
RSA modulus component (Base64URL encoded)
RSA exponent component (Base64URL encoded)
Key usage (always “enc” for encryption)
PEM Format
Returns the public key in PEM format as plain text:- Content-Type:
text/plain - Key ID available in
x-firmly-kidheader - Standard PEM header/footer with base64 encoded key
RSA Format
Returns the public key in RSA-specific PEM format:- Content-Type:
text/plain - Key ID available in
x-firmly-kidheader - Uses RSA PUBLIC KEY header/footer
Code Examples
Response Examples
JWK Format Response
PEM Format Response
RSA Format Response
Usage with Encryption Libraries
JavaScript (Web Crypto API)
Python (cryptography)
Node.js (node-jose)
Best Practices
Common Use Cases
- Credit Card Encryption: Primary use is for encrypting credit card data for payment endpoints
- Tokenization: Used with payment tokenization endpoints
- Secure Data Transmission: Any sensitive data sent to Firmly payment endpoints
Checkout Flow Integration
This endpoint is the first step in the secure payment flow:Complete Example Flow
Related Endpoints
- Complete Order (Simple Cart) - Complete checkout for Simple Cart API
- Complete Order (Full Cart) - Complete checkout for Full Cart API
- Place Order (Simple Cart) - Create cart and order in one call
- Place Order (Full Cart) - Create cart and order with advanced features
Get Public Key