Generate a public and private JWS key pair
Run these commands in your terminal:private_key.pem, containing your private key.public_key.pem, containing your public key.
public_key.pem
private_key.pem
Upload your public key to the dashboard
- Go to dashboard.fintoc.com.
- Open API Keys in the sidebar.
- If your organization has products that require JWS, open JWS Public Keys, select Add JWS Key, and upload your JWS public key.
Generate a signature
After you upload your public key to the Fintoc dashboard, generate signatures with your private key. Each signature protects the integrity and authenticity of a Transfers API call that moves money.Generate signatures with an SDK
The Node SDK and Python SDK generate signatures for you. Pass the private key when you initialize the Fintoc client. The SDK then signs each protected request:Generate a signature manually
If you want to write your own implementation or use a different programming language, follow these steps:Prepare the payload
JWS signature generation operates on the exact JSON string sent in the HTTP request. Create that string by serializing your outbound transfer request body with your language’s JSON serializer.JSON string must be consistentWhen serializing your request body to JSON, you must use the exact same string for two purposes:
- Creating the JWS signature
- Sending as the payload in your HTTP request
Load the private key and configure headers
Load your private key from the PEM file and configure the protected JWS header. The header includes theRS256 signing algorithm, a unique nonce, and the current Unix timestamp in ts. The crit field identifies ts and nonce as critical fields.
Prevent replay attacks
Fintoc uses thenonce and ts headers during JWS authentication to protect against replay attacks and ensure request integrity.
Include a unique, random nonce in every request. The nonce makes each signature distinct, even when you send the same data multiple times. Fintoc accepts each nonce only once and rejects requests that reuse a nonce.
The Unix timestamp in ts records when you created the request. Fintoc validates that the timestamp falls within a 2-minute window and rejects outdated requests.
Together, nonce and ts prevent replays: Fintoc rejects any intercepted request that reuses a nonce or falls outside the timestamp window.
Generate the signing input
Create the JWS signing input by joining the base64url-encodedheaders and raw_body with a period (.). Encode both values without padding:
Generate the JWS token signature
Create the cryptographic signature from the signing input and your private key:- Sign the signing input with your private key using RSA and PKCS #1 v1.5 padding.
- Base64url-encode the resulting signature without padding.
Verify the JWS token (optional)
Some libraries re-encode JSON payloads with different spacing, key ordering, or character encoding. To debug a signature, decode the payload locally and confirm that it matches theraw_body sent in the HTTP request. Do not share a token that contains sensitive transfer data.
Construct the Fintoc-JWS-Signature header
Construct the Fintoc-JWS-Signature header by concatenating the protected header and signature:
Use the complete example
The following functions combine the manual signature steps. Install the Pythoncryptography package before running the Python example.
Test the integration
Confirm your signature works before you go live. Using atest mode API key, sign a create outbound transfer request and send the signature in the Fintoc-JWS-Signature header.
- Build the request body and serialize it with your JSON serializer.
- Generate the signature from the serialized body with the function above.
- Send the request with the
Fintoc-JWS-Signatureheader set to the generated signature.
201 Created and the created transfer when the signature is valid. A signature error or 401 Unauthorized response can indicate a mismatched request body, a reused nonce, or a ts value outside the 2-minute window.