Skip to main content
Requests to Transfers endpoints that move money require a JSON Web Signature (JWS). The signature verifies the integrity and authenticity of the request. Protected actions include creating outbound transfers and returning inbound transfers.

Generate JWS keys

Generate a key pair, upload the public key, and use the private key to sign each protected request.

Generate a pair of public and private JWS keys

Run these commands in your terminal:
This generates two files:
  • private_key.pem, which contains your private key.
  • public_key.pem.pub, which contains your public key.
Each key should look similar to the following examples:
public_key.pem
private_key.pem
Never share your JWS private keyKeep your JWS private key confidential. Fintoc never asks for this key. Anyone with access to the private key can sign transfer requests on your behalf.

Upload your public key to the dashboard

  1. Open dashboard.fintoc.com.
  2. Select API Keys in the sidebar.
  3. If your organization has a product that requires JWS, find the JWS Public Keys section. Select Add JWS Key, and upload your JWS public key.

Generate a signature

After you upload your public key to the Fintoc dashboard, use your private key to generate a signature. The signature verifies the integrity and authenticity of each Transfers API request that moves money.

Use an SDK

The Python SDK and Node SDK generate signatures for you. Initialize the Fintoc client with your private key:
Node

Follow a step-by-step example

Follow these steps to write your own implementation or use a different programming language.

Prepare the payload

Generate the JWS signature from the exact JSON string that you send in the HTTP request. Use your language’s JSON serializer to convert the outbound transfer request body to a JSON string.
Use the same JSON stringUse the same serialized JSON string for both actions:
  1. Create the JWS signature.
  2. Send the payload in your HTTP request.
Any difference between the signed JSON and the HTTP request payload can invalidate the signature.

Load the private key and configure headers

Load your private key from the PEM file and configure the JWS headers. Include the RS256 signing algorithm, a unique nonce, the current Unix timestamp, and the critical header names.

Prevent a replay attack

Fintoc uses the nonce and ts headers to protect requests against replay attacks. The headers also help verify request integrity. Set nonce to a unique, random value for every request. This value makes each signature distinct, even when you send the same data more than once. Fintoc rejects a request if its nonce was already used. Set ts to the Unix timestamp when you create the request. Fintoc rejects requests outside a two-minute window. Together, nonce and ts prevent an intercepted request from being reused.

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 input using your private key with:
    1. RSA with PKCS1v15 padding
    2. SHA-256 hashing
  2. Base64URL-encode the resulting signature (without padding)

Optional: verify the JWS token

Some libraries re-encode JSON payloads with different spacing, key ordering, or character encoding. To debug a signature locally, decode the payload and compare it with the raw_body sent in the HTTP request. You can also inspect a token containing only non-sensitive test data at jwt.io.

Construct the Fintoc-JWS-Signature header

Construct the Fintoc-JWS-Signature header by joining the protected header and signature:

Review the complete example

The following function combines the preceding steps. Install the imported libraries before running the example.