Skip to main content
To make requests to our Transfers endpoints that move money, you’ll need to include a JSON Web Signature (JWS). JWS is a standard for digitally signing data to ensure its integrity and authenticity. Protected actions include creating outbound transfers and returning inbound transfers.

Generate JWS Keys

To sign an API call, you’ll need to follow these steps:

Generate a pair of Public and Private JWS Keys

Execute this command in your terminal:
This generates two files:
  • private_key.pem containing your private key
  • public_key.pem containing your public key
Each file should look similar to this example:
public_key.pem
private_key.pem
Never share your JWS Private KeyYour JWS Private Key is highly sensitive and must remain confidential at all times. Fintoc will never ask for this key. If someone gains access to your private key, they could maliciously sign transfer requests on your behalf.

Upload your Public Key to the Dashboard

  1. Go to dashboard.fintoc.com
  2. Go to the API Keys tab on the side bar
  3. If products that require JWS are active for your organization, you’ll see a JWS Public Keys section. Click the “Add JWS Key” button and upload your JWS Public Key.

Generate Signature

Now that you loaded your Public Key to your Fintoc Dashboard, you can generate a signature based on the Private Key. This is necessary to ensure integrity and authenticity for each Transfer API call that moves money.

Using our SDK

If you’re using Python or Node, our Python SDKand Node SDK automatically generates the signatures for you. Simply initialize the Fintoc client with the jws_private_key argument, and the SDK will take care of the rest:
Node

Step by step example

If you want to write your own implementation or use a different programming language, follow these steps:

Prepare the payload

For JWS signature generation, we need to work with the exact JSON string that will be sent in the HTTP request. This is typically created by converting your Outbound Transfer request body object into a JSON string using 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 slight difference between the JSON used to create the JWS signature and the payload in your HTTP request may invalidate the signature.

Load Private Key and Configure Headers

Load your private key from the PEM file and set up the JWS headers. Headers include the signing algorithm (RS256), a unique nonce to prevent duplicated signatures, current timestamp, and critical fields specification.

Preventing a replay attack

Fintoc uses the nonce and ts timestamp headers in its JWS authentication process to protect against replay attacks and ensure request integrity. The nonce string should be a unique, random value and needs to be included in every request, making each signature distinct even if the same data is sent multiple times. Fintoc ensures that each nonce is used only once, and will reject any request that contains a duplicated nonce. The ts timestamp records when the request was created, and Fintoc’s servers validate that it falls within a 2 minute time window to prevent the processing of outdated requests. Together, the nonce and timestamp provide robust protection by ensuring that intercepted or tampered requests cannot be reused, safeguarding your integration against malicious activities.

Generate the Signing Input

The signing input for a JWS consists of concatenating the base64url-encoded headers and the base64url-encoded raw_body with a period . between them, both without padding:

Generate JWS Token Signature

Once you have the signing input ready, you’ll create the cryptographic signature using your private key. The process involves:
  1. Sign the input using your private key with:
    1. RSA with PKCS1v15 padding
    2. Base64URL-encode the resulting signature (without padding)
  2. Base64URL-encode the resulting signature (without padding)

Optional: Verify JWS Token

Some libraries may re-encode JSON payloads with different spacing or key ordering, or change its encoding. To debug the signature, you can inspect the generated token at https://jwt.io to verify its content. We also recommend to double-check that the JWS Token payload is equal to the raw_body being sent in the http request.

Construct the Fintoc-JWS-Signature Header

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

Complete example

Here’s a complete example function that puts it all together (you will have to install the mentioned libraries to try it out).