Skip to main content
Set up a public-private key pair to sign protected Transfers API requests. Transfers API requests that move money must include a JSON Web Signature (JWS). A JWS digitally signs data to ensure its integrity and authenticity. Protected actions include creating outbound transfers and returning inbound transfers.

Generate a public and private JWS key pair

Run these commands in your terminal:
This generates two files:
  • private_key.pem, containing your private key.
  • public_key.pem, containing your public key.
The files use the following formats:
public_key.pem
private_key.pem
Never share your JWS private keyYour JWS private key is sensitive and must remain confidential. Fintoc never asks for this key. Anyone with your private key can sign malicious transfer requests on your behalf.

Upload your public key to the dashboard

  1. Go to dashboard.fintoc.com.
  2. Open API Keys in the sidebar.
  3. 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:
  1. Creating the JWS signature
  2. Sending as the payload in your HTTP request
Any difference between the JSON used to create the JWS signature and the HTTP request payload may invalidate the signature.

Load the private key and configure headers

Load your private key from the PEM file and configure the protected JWS header. The header includes the RS256 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 the nonce 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-encoded headers 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:
  1. Sign the signing input with your private key using RSA and PKCS #1 v1.5 padding.
  2. 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 the raw_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 Python cryptography package before running the Python example.

Test the integration

Confirm your signature works before you go live. Using a test mode API key, sign a create outbound transfer request and send the signature in the Fintoc-JWS-Signature header.
  1. Build the request body and serialize it with your JSON serializer.
  2. Generate the signature from the serialized body with the function above.
  3. Send the request with the Fintoc-JWS-Signature header set to the generated signature.
Fintoc returns 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.