docs

Generate JWT access token

POST /api/auth/token

POST https://api.fypay.me/api/auth/token

Authenticate with the X.509 client certificate + credentials (clientId/clientSecret) and receive a JWT token. The token lifetime comes in the expires_in field (in seconds): use that value to renew the token before it expires, instead of assuming a fixed duration.

Authentication (mTLS)

This route requires mTLS: the client certificate issued by FyPay is presented in the TLS handshake, not in an HTTP header. Use the native client certificate mechanism of your HTTP library (for example, curl --cert client.crt --key client.key).

  • The certificate is PEM, RSA 2048, valid for 2 years and bound to your account.
  • mTLS is required only on this route. All other routes use Authorization: Bearer <token>, without a certificate.

Do not send the certificate in HTTP headers: that model is not accepted. Without the certificate in the handshake, the API responds 400 with PUB_CERT_HEADER_MISSING.

Request Body

FieldTypeRequiredDescription
clientIdstring (UUID v4)YesClient ID generated in the dashboard (https://banking.fypay.me), under Settings → Credentials
clientSecretstringYesClient secret generated together with the clientId. It is shown only once in the dashboard. Must not be empty
{
  "clientId": "6967c0a0-3566-48d0-8c13-717038b52279",
  "clientSecret": "YOUR_CLIENT_SECRET"
}

cURL Example

curl -X POST https://api.fypay.me/api/auth/token \
  --cert ./client.crt \
  --key ./client.key \
  -H "Content-Type: application/json" \
  -d '{
    "clientId": "YOUR_CLIENT_ID",
    "clientSecret": "YOUR_CLIENT_SECRET"
  }'

Code Examples

const https = require('https');
const fs = require('fs');
const axios = require('axios');

const httpsAgent = new https.Agent({
  cert: fs.readFileSync('./client.crt'),
  key: fs.readFileSync('./client.key'),
});

const response = await axios.post(
  'https://api.fypay.me/api/auth/token',
  {
    clientId: process.env.FYPAY_CLIENT_ID,
    clientSecret: process.env.FYPAY_CLIENT_SECRET,
  },
  { httpsAgent },
);

console.log('Token:', response.data.access_token);
console.log('Expires in:', response.data.expires_in, 'seconds');
import os
import requests

response = requests.post(
    'https://api.fypay.me/api/auth/token',
    json={
        'clientId': os.environ['FYPAY_CLIENT_ID'],
        'clientSecret': os.environ['FYPAY_CLIENT_SECRET'],
    },
    cert=('client.crt', 'client.key'),
)
response.raise_for_status()

data = response.json()
print(f"Token: {data['access_token']}")
print(f"Expires in: {data['expires_in']} seconds")
<?php
$ch = curl_init('https://api.fypay.me/api/auth/token');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSLCERT => __DIR__ . '/client.crt',
    CURLOPT_SSLKEY => __DIR__ . '/client.key',
    CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode([
        'clientId' => getenv('FYPAY_CLIENT_ID'),
        'clientSecret' => getenv('FYPAY_CLIENT_SECRET'),
    ]),
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
echo "Token: " . $data['access_token'] . "\n";
echo "Expires in: " . $data['expires_in'] . " seconds\n";
using System.Net.Http.Json;
using System.Security.Cryptography.X509Certificates;

var certificate = X509Certificate2.CreateFromPemFile("client.crt", "client.key");

var handler = new HttpClientHandler();
handler.ClientCertificates.Add(certificate);

using var client = new HttpClient(handler);
var response = await client.PostAsJsonAsync(
    "https://api.fypay.me/api/auth/token",
    new
    {
        clientId = Environment.GetEnvironmentVariable("FYPAY_CLIENT_ID"),
        clientSecret = Environment.GetEnvironmentVariable("FYPAY_CLIENT_SECRET"),
    });

response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
package main

import (
	"bytes"
	"crypto/tls"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func main() {
	cert, err := tls.LoadX509KeyPair("client.crt", "client.key")
	if err != nil {
		panic(err)
	}

	client := &http.Client{
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{Certificates: []tls.Certificate{cert}},
		},
	}

	body, _ := json.Marshal(map[string]string{
		"clientId":     os.Getenv("FYPAY_CLIENT_ID"),
		"clientSecret": os.Getenv("FYPAY_CLIENT_SECRET"),
	})

	resp, err := client.Post("https://api.fypay.me/api/auth/token", "application/json", bytes.NewReader(body))
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	var data map[string]any
	json.NewDecoder(resp.Body).Decode(&data)
	fmt.Println("Token:", data["access_token"])
	fmt.Println("Expires in:", data["expires_in"], "seconds")
}
import java.io.FileInputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.security.KeyStore;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;

char[] password = System.getenv("FYPAY_KEYSTORE_PASSWORD").toCharArray();

KeyStore keyStore = KeyStore.getInstance("PKCS12");
try (FileInputStream in = new FileInputStream("client.p12")) {
    keyStore.load(in, password);
}

KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(keyStore, password);

SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf.getKeyManagers(), null, null);

String body = String.format(
    "{\"clientId\":\"%s\",\"clientSecret\":\"%s\"}",
    System.getenv("FYPAY_CLIENT_ID"),
    System.getenv("FYPAY_CLIENT_SECRET")
);

HttpClient client = HttpClient.newBuilder().sslContext(sslContext).build();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.fypay.me/api/auth/token"))
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

FyPay delivers the certificate as PEM (client.crt + client.key). If your platform requires a .pfx/.p12 file (common in Java and some Windows/.NET environments), convert it locally:

openssl pkcs12 -export -in client.crt -inkey client.key -out client.p12

The conversion happens on your machine; FyPay does not provide PFX files.

Response (201)

FieldTypeDescription
access_tokenstringJWT token for the Authorization: Bearer <token> header
token_typestringAlways Bearer
expires_innumberToken lifetime in seconds. Renew before it expires based on this value
scopestringToken scope
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 600,
  "scope": "email profile"
}

Errors

StatusCodeDescription
400PUB_CERT_HEADER_MISSINGClient certificate not presented in the TLS handshake
400PUB_CERT_MALFORMED_PEMCertificate in invalid PEM format
400PUB_REQUEST_BODY_INVALIDInvalid body (e.g. clientId is not a UUID v4, empty clientSecret, extra fields). The offending fields are listed in details.violations
401PUB_INVALID_CREDENTIALSInvalid clientId/clientSecret
401PUB_CERT_NOT_VERIFIEDThe certificate could not be verified on the connection
401PUB_CERT_NOT_REGISTEREDCertificate not registered
401PUB_CERT_EXPIREDCertificate expired
401PUB_CERT_NOT_YET_VALIDCertificate is not yet within its validity period
403PUB_CERT_NOT_AUTHORIZED_FOR_ACCOUNTCertificate is not bound to the account of the credentials
502PUB_AUTH_UPSTREAM_ERRORUnexpected error in the authentication service
503PUB_AUTH_UPSTREAM_UNAVAILABLEAuthentication service temporarily unavailable. Try again
{
  "statusCode": 401,
  "timestamp": "2026-04-17T15:24:28.809Z",
  "path": "/api/auth/token",
  "method": "POST",
  "code": "PUB_INVALID_CREDENTIALS",
  "message": "Invalid credentials provided",
  "userMessage": "Invalid credentials.",
  "errorId": "75d7999d6d7656b737e83435ced86ec6"
}

For a complete authentication guide with token renewal patterns, see Authentication Guide.

On this page