Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cloud.cdata.com/llms.txt

Use this file to discover all available pages before exploring further.

CData requires that a JWT is signed using the RSA 256 algorithm.

Creating a JWT

Follow these steps to create a JWT.
1
Create a JWT header with this format: {"alg": "RS256", "typ": "JWT"}
2
Base64url encode the JWT header.
3
Construct a JSON Claims Set for the JWT with the following parameters.
ParameterDescription
tokenTypepowered-by (This JWT token is type powered-by.)
iatThe time the JWT is issued, expressed as the number of seconds from 1970-01-01T0:0:0Z measured in UTC.
expThe date and time at which the token expires, expressed as the number of seconds from 1970-01-01T0:0:0Z measured in UTC.
issThe account Id of the parent account.
subThe account Id of the sub-account (optional for Create Account and List Connections).
connection_idsA JSON array containing a list of connection Ids accessible to the end user (required when calling the per-connection MCP endpoint; otherwise optional). Must be a JSON array of strings (such as ["id-1","id-2"]), not a JSON-encoded string. Passing a stringified array causes the per-connection MCP endpoint to return 403.

The following is an example JSON Claim Set for the JWT:

{
   "tokenType": "powered-by",
   "iat": current_time_seconds,
   "exp": expiration_time_seconds,
   "iss": "your_oem_account_id_here",
   "sub": "your_sub_account_id_here",
   "connection_ids": ["connection_id_1","connection_id_2"]
 }
4
Base64url encode the JSON Claims Set without any line breaks.
5
Create a string for the encoded JWT Header and the encoded JWT Claims Set in the following format:
Base64UrlEncode(JWT_header) + "." + Base64UrlEncode(JWT_Claims_Set)
6
Sign the token with your private key and format the token.
7
Register the public key certificate in Privacy-Enhanced Mail (PEM) format in the management account. Open a support ticket with Connect AI to register the public key.

Generating JWT Keys

A JWT requires a public and private key in PEM format. You sign the JWT with your private key and you register the public key with CData. There are several ways to generate JWT keys. The examples below use openssl.

Generating a Private Key

The following example shows how to generate the JWT private key using openssl:
openssl genrsa -out ./private.key 4096
Your current directory should now contain the private.key. Do not share this file with anyone!

Generating a Public Key

Use the private key to generate the public key. In openssl, the command is as follows:
openssl rsa -in private.key -pubout -outform PEM -out public.key
Your current directory should now contain the public.key, which you need to share with CData.

Code Samples

Click the relevant tab for the code sample for creating a JWT.
Creating a JWT in Java:Add the com.auth0:java-jwt dependency to your project (Maven: com.auth0:java-jwt:4.4.0, Gradle: implementation 'com.auth0:java-jwt:4.4.0').
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

import java.security.KeyFactory;
import java.security.interfaces.RSAPrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Arrays;
import java.util.Base64;
import java.util.Date;
import java.util.List;

public class JWTExample {

    public static void main(String[] args) throws Exception {

        String privateKeyPem = """
                your_secret_key_here
                """
            .replace("-----BEGIN PRIVATE KEY-----", "")
            .replaceAll("\\s+", "")
            .replace("-----END PRIVATE KEY-----", "");

        byte[] keyBytes = Base64.getDecoder().decode(privateKeyPem);
        RSAPrivateKey privateKey = (RSAPrivateKey) KeyFactory.getInstance("RSA")
            .generatePrivate(new PKCS8EncodedKeySpec(keyBytes));

        List<String> connectionIds = Arrays.asList(
            "your_connection_id_1_here",
            "your_connection_id_2_here"
        );

        long nowSeconds = System.currentTimeMillis() / 1000;

        String token = JWT.create()
            .withClaim("tokenType", "powered-by")
            .withIssuedAt(new Date(nowSeconds * 1000))
            .withExpiresAt(new Date((nowSeconds + 300) * 1000))
            .withIssuer("your_oem_account_id_here")
            .withSubject("your_sub_account_id_here")
            .withClaim("connection_ids", connectionIds)
            .sign(Algorithm.RSA256(null, privateKey));

        System.out.println(token);
    }
}