").deidentifyText(deidentifyTextRequest);
+
+ // Step 5: Print the response
+ System.out.println("Deidentify text Response: " + deidentifyTextResponse);
+ }
+}
+
+```
+
+## An [example](https://github.com/skyflowapi/skyflow-java/blob/main/samples/src/main/java/com/example/detect/DeidentifyTextExample.java) of deidentify text:
+```java
+import java.util.ArrayList;
+import java.util.List;
+
+import com.skyflow.enums.DetectEntities;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.detect.DateTransformation;
+import com.skyflow.vault.detect.DeidentifyTextRequest;
+import com.skyflow.vault.detect.DeidentifyTextResponse;
+import com.skyflow.vault.detect.TokenFormat;
+import com.skyflow.vault.detect.Transformations;
+
+/**
+ * Skyflow Deidentify Text Example
+ *
+ * This example demonstrates how to use the Skyflow SDK to deidentify text data
+ * across multiple vaults. It includes:
+ * 1. Setting up credentials and vault configurations.
+ * 2. Creating a Skyflow client with multiple vaults.
+ * 3. Performing deidentify of text with various options.
+ * 4. Handling responses and errors.
+ */
+
+public class DeidentifyTextExample {
+ public static void main(String[] args) throws SkyflowException {
+
+ // Step 1: Initialise the Skyflow client by configuring the credentials & vault config.
+
+ // Step 2: Configuring the different options for deidentify
+
+ // Replace with the entity you want to detect
+ List detectEntitiesList = new ArrayList<>();
+ detectEntitiesList.add(DetectEntities.SSN);
+ detectEntitiesList.add(DetectEntities.CREDIT_CARD);
+
+ // Replace with the entity you want to detect with vault token
+ List vaultTokenList = new ArrayList<>();
+ vaultTokenList.add(DetectEntities.SSN);
+ vaultTokenList.add(DetectEntities.CREDIT_CARD);
+
+ // Configure Token Format
+ TokenFormat tokenFormat = TokenFormat.builder()
+ .vaultToken(vaultTokenList)
+ .build();
+
+ // Configure Transformation for deidentified entities
+ List detectEntitiesTransformationList = new ArrayList<>();
+ detectEntitiesTransformationList.add(DetectEntities.DOB); // Replace with the entity you want to transform
+
+ DateTransformation dateTransformation = new DateTransformation(20, 5, detectEntitiesTransformationList);
+ Transformations transformations = new Transformations(dateTransformation);
+
+ // Step 3: invoking Deidentify text on the vault
+ try {
+ // Create a deidentify text request for the vault
+ DeidentifyTextRequest deidentifyTextRequest = DeidentifyTextRequest.builder()
+ .text("My SSN is 123-45-6789 and my card is 4111 1111 1111 1111.") // Replace with your deidentify text
+ .entities(detectEntitiesList)
+ .tokenFormat(tokenFormat)
+ .transformations(transformations)
+ .build();
+ // Replace `9f27764a10f7946fe56b3258e117` with the acutal vault id
+ DeidentifyTextResponse deidentifyTextResponse = skyflowClient.detect("9f27764a10f7946fe56b3258e117").deidentifyText(deidentifyTextRequest);
+
+ System.out.println("Deidentify text Response: " + deidentifyTextResponse);
+ } catch (SkyflowException e) {
+ System.err.println("Error occurred during deidentify: ");
+ e.printStackTrace(); // Print the exception for debugging purposes
+ }
+ }
+}
+```
+
+Sample Response:
+```json
+{
+ "processedText": "My SSN is [SSN_IWdexZe] and my card is [CREDIT_CARD_rUzMjdQ].",
+ "entities": [
+ {
+ "token": "SSN_IWdexZe",
+ "value": "123-45-6789",
+ "textIndex": {
+ "start": 10,
+ "end": 21
+ },
+ "processedIndex": {
+ "start": 10,
+ "end": 23
+ },
+ "entity": "SSN",
+ "scores": {
+ "SSN": 0.9384
+ }
+ },
+ {
+ "token": "CREDIT_CARD_rUzMjdQ",
+ "value": "4111 1111 1111 1111",
+ "textIndex": {
+ "start": 37,
+ "end": 56
+ },
+ "processedIndex": {
+ "start": 39,
+ "end": 60
+ },
+ "entity": "CREDIT_CARD",
+ "scores": {
+ "CREDIT_CARD": 0.9051
+ }
+ }
+ ],
+ "wordCount": 9,
+ "charCount": 57
+}
+```
+
+## Reidentify Text
+To reidentify text, use the `reidentifyText` method. The `ReidentifyTextRequest` class creates a reidentify text request, which includes the redacted or deidentified text to be reidentified. Additionally, you can provide optional parameters using the ReidentifyTextOptions class to control how specific entities are returned (as redacted, masked, or plain text).
+
+### Construct an reidentify text request
+
+```java
+import com.skyflow.enums.DetectEntities;
+import com.skyflow.vault.detect.ReidentifyTextRequest;
+import com.skyflow.vault.detect.ReidentifyTextResponse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This example demonstrates how to build a reidentify text request.
+ */
+public class ReidentifyTextSchema {
+ public static void main(String[] args) {
+ // Step 1: Initialise the Skyflow client by configuring the credentials & vault config.
+
+ // Step 2: Configuring the different options for reidentify
+ List maskedEntity = new ArrayList<>();
+ maskedEntity.add(DetectEntities.CREDIT_CARD); // Replace with the entity you want to mask
+
+ List plainTextEntity = new ArrayList<>();
+ plainTextEntity.add(DetectEntities.SSN); // Replace with the entity you want to keep in plain text
+
+ // List redactedEntity = new ArrayList<>();
+ // redactedEntity.add(DetectEntities.SSN); // Replace with the entity you want to redact
+
+
+ // Step 3: Create a reidentify text request with the configured entities
+ ReidentifyTextRequest reidentifyTextRequest = ReidentifyTextRequest.builder()
+ .text("My SSN is [SSN_IWdexZe] and my card is [CREDIT_CARD_rUzMjdQ].") // Replace with your deidentify text
+ .maskedEntities(maskedEntity)
+// .redactedEntities(redactedEntity)
+ .plainTextEntities(plainTextEntity)
+ .build();
+
+ // Step 4: Invoke reidentify text on the vault
+ ReidentifyTextResponse reidentifyTextResponse = skyflowClient.detect("").reidentifyText(reidentifyTextRequest);
+ System.out.println("Reidentify text Response: " + reidentifyTextResponse);
+ }
+}
+```
+
+## An [example](https://github.com/skyflowapi/skyflow-java/blob/main/samples/src/main/java/com/example/detect/ReidentifyTextExample.java) of Reidentify text
+
+```java
+import com.skyflow.enums.DetectEntities;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.detect.ReidentifyTextRequest;
+import com.skyflow.vault.detect.ReidentifyTextResponse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Skyflow Reidentify Text Example
+ *
+ * This example demonstrates how to use the Skyflow SDK to reidentify text data
+ * across multiple vaults. It includes:
+ * 1. Setting up credentials and vault configurations.
+ * 2. Creating a Skyflow client with multiple vaults.
+ * 3. Performing reidentify of text with various options.
+ * 4. Handling responses and errors.
+ */
+
+public class ReidentifyTextExample {
+ public static void main(String[] args) throws SkyflowException {
+ // Step 1: Initialise the Skyflow client by configuring the credentials & vault config.
+
+ // Step 2: Configuring the different options for reidentify
+ List maskedEntity = new ArrayList<>();
+ maskedEntity.add(DetectEntities.CREDIT_CARD); // Replace with the entity you want to mask
+
+ List plainTextEntity = new ArrayList<>();
+ plainTextEntity.add(DetectEntities.SSN); // Replace with the entity you want to keep in plain text
+
+ try {
+ // Step 3: Create a reidentify text request with the configured options
+ ReidentifyTextRequest reidentifyTextRequest = ReidentifyTextRequest.builder()
+ .text("My SSN is [SSN_IWdexZe] and my card is [CREDIT_CARD_rUzMjdQ].") // Replace with your deidentify text
+ .maskedEntities(maskedEntity)
+ .plainTextEntities(plainTextEntity)
+ .build();
+
+ // Step 4: Invoke Reidentify text on the vault
+ // Replace `9f27764a10f7946fe56b3258e117` with the acutal vault id
+ ReidentifyTextResponse reidentifyTextResponse = skyflowClient.detect("9f27764a10f7946fe56b3258e117").reidentifyText(reidentifyTextRequest);
+
+ // Handle the response from the reidentify text request
+ System.out.println("Reidentify text Response: " + reidentifyTextResponse);
+ } catch (SkyflowException e) {
+ System.err.println("Error occurred during reidentify : ");
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+Sample Response:
+
+```json
+{
+ "processedText":"My SSN is 123-45-6789 and my card is XXXXX1111."
+}
+```
+
+## Deidentify file
+To deidentify files, use the `deidentifyFile` method. The `DeidentifyFileRequest` class creates a deidentify file request, which includes the file to be deidentified (such as images, PDFs, audio, documents, spreadsheets, or presentations). Additionally, you can provide optional parameters using the DeidentifyFileOptions class to control how entities are detected and deidentified, as well as how the output is generated for different file types.
+
+### Construct an deidentify file request
+
+```java
+import com.skyflow.config.Credentials;
+import com.skyflow.config.VaultConfig;
+import com.skyflow.enums.Env;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.enums.MaskingMethod;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.detect.DeidentifyFileRequest;
+import com.skyflow.vault.detect.DeidentifyFileResponse;
+
+import java.io.File;
+
+/**
+ * This example demonstrates how to build a deidentify file request.
+ */
+
+public class DeidentifyFileSchema {
+
+ public static void main(String[] args) {
+ // Step 1: Initialise the Skyflow client by configuring the credentials & vault config.
+
+ // Step 2: Create a deidentify file request with all options
+
+ // Create file object
+ File file = new File(""); // Replace with the path to the file you want to deidentify
+
+ // Create file input using the file object
+ FileInput fileInput = FileInput.builder()
+ .file(file)
+ // .filePath("") // Alternatively, you can use .filePath()
+ .build();
+
+ // Output configuration
+ String outputDirectory = ""; // Replace with the desired output directory to save the deidentified file
+
+ // Entities to detect
+ // List detectEntities = new ArrayList<>();
+ // detectEntities.add(DetectEntities.IP_ADDRESS); // Replace with the entities you want to detect
+
+ // Image-specific options
+ // Boolean outputProcessedImage = true; // Include processed image in output
+ // Boolean outputOcrText = true; // Include OCR text in output
+ MaskingMethod maskingMethod = MaskingMethod.BLACKBOX; // Masking method for images
+
+ // PDF-specific options
+ // Integer pixelDensity = 15; // Pixel density for PDF processing
+ // Integer maxResolution = 2000; // Max resolution for PDF
+
+ // Audio-specific options
+ // Boolean outputProcessedAudio = true; // Include processed audio
+ // DetectOutputTranscriptions outputTanscription = DetectOutputTranscriptions.PLAINTEXT_TRANSCRIPTION; // Transcription type
+
+ // Audio bleep configuration
+ // AudioBleep audioBleep = AudioBleep.builder()
+ // .frequency(5D) // Pitch in Hz
+ // .startPadding(7D) // Padding at start (seconds)
+ // .stopPadding(8D) // Padding at end (seconds)
+ // .build();
+
+ Integer waitTime = 20; // Max wait time for response (max 64 seconds)
+
+ DeidentifyFileRequest deidentifyFileRequest = DeidentifyFileRequest.builder()
+ .file(fileInput)
+ .waitTime(waitTime)
+ .entities(detectEntities)
+ .outputDirectory(outputDirectory)
+ .maskingMethod(maskingMethod)
+ // .outputProcessedImage(outputProcessedImage)
+ // .outputOcrText(outputOcrText)
+ // .pixelDensity(pixelDensity)
+ // .maxResolution(maxResolution)
+ // .outputProcessedAudio(outputProcessedAudio)
+ // .outputTranscription(outputTanscription)
+ // .bleep(audioBleep)
+ .build();
+
+
+ DeidentifyFileResponse deidentifyFileResponse = skyflowClient.detect("").deidentifyFile(deidentifyFileRequest);
+ System.out.println("Deidentify file response: " + deidentifyFileResponse.toString());
+ }
+}
+```
+
+## An [example](https://github.com/skyflowapi/skyflow-java/blob/main/samples/src/main/java/com/example/detect/DeidentifyFileExample.java) of Deidentify file
+
+```java
+import java.io.File;
+
+import com.skyflow.enums.MaskingMethod;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.detect.DeidentifyFileRequest;
+import com.skyflow.vault.detect.DeidentifyFileResponse;
+
+/**
+ * Skyflow Deidentify File Example
+ *
+ * This example demonstrates how to use the Skyflow SDK to deidentify file
+ * It has all available options for deidentifying files.
+ * Supported file types: images (jpg, png, etc.), pdf, audio (mp3, wav), documents, spreadsheets, presentations, structured text.
+ * It includes:
+ * 1. Configure credentials
+ * 2. Set up vault configuration
+ * 3. Create a deidentify file request with all options
+ * 4. Call deidentifyFile to deidentify file.
+ * 5. Handle response and errors
+ */
+public class DeidentifyFileExample {
+
+ public static void main(String[] args) throws SkyflowException {
+ // Step 1: Initialise the Skyflow client by configuring the credentials & vault config.
+ try {
+ // Step 2: Create a deidentify file request with all options
+
+
+ // Create file object
+ File file = new File("sensitive-folder/personal-info.txt"); // Replace with the path to the file you want to deidentify
+
+ // Create file input using the file object
+ FileInput fileInput = FileInput.builder()
+ .file(file)
+ // .filePath("") // Alternatively, you can use .filePath()
+ .build();
+
+ // Output configuration
+ String outputDirectory = "deidentified-file/"; // Replace with the desired output directory to save the deidentified file
+
+ // Entities to detect
+ // List detectEntities = new ArrayList<>();
+ // detectEntities.add(DetectEntities.IP_ADDRESS); // Replace with the entities you want to detect
+
+ // Image-specific options
+ // Boolean outputProcessedImage = true; // Include processed image in output
+ // Boolean outputOcrText = true; // Include OCR text in output
+ MaskingMethod maskingMethod = MaskingMethod.BLACKBOX; // Masking method for images
+
+ Integer waitTime = 20; // Max wait time for response (max 64 seconds)
+
+ DeidentifyFileRequest deidentifyFileRequest = DeidentifyFileRequest.builder()
+ .file(fileInput)
+ .waitTime(waitTime)
+ .outputDirectory(outputDirectory)
+ .maskingMethod(maskingMethod)
+ .build();
+
+ // Step 3: Invoking deidentifyFile
+ // Replace `9f27764a10f7946fe56b3258e117` with the actual vault id
+ DeidentifyFileResponse deidentifyFileResponse = skyflowClient.detect("9f27764a10f7946fe56b3258e117").deidentifyFile(deidentifyFileRequest);
+ System.out.println("Deidentify file response: " + deidentifyFileResponse.toString());
+ } catch (SkyflowException e) {
+ System.err.println("Error occurred during deidentify file: ");
+ e.printStackTrace();
+ }
+ }
+}
+
+```
+
+Sample response:
+
+```json
+{
+ "file": {
+ "name": "deidentified.txt",
+ "size": 33,
+ "type": "",
+ "lastModified": 1751355183039
+ },
+ "fileBase64": "bXkgY2FyZCBudW1iZXIgaXMgW0NSRURJVF",
+ "type": "redacted_file",
+ "extension": "txt",
+ "wordCount": 11,
+ "charCount": 61,
+ "sizeInKb": 0,
+ "entities": [
+ {
+ "file": "bmFtZTogW05BTUVfMV0gCm==",
+ "type": "entities",
+ "extension": "json"
+ }
+ ],
+ "runId": "undefined",
+ "status": "success"
+}
+
+```
+
+**Supported file types:**
+- Documents: `doc`, `docx`, `pdf`
+- PDFs: `pdf`
+- Images: `bmp`, `jpeg`, `jpg`, `png`, `tif`, `tiff`
+- Structured text: `json`, `xml`
+- Spreadsheets: `csv`, `xls`, `xlsx`
+- Presentations: `ppt`, `pptx`
+- Audio: `mp3`, `wav`
+
+**Note:**
+- Transformations cannot be applied to Documents, Images, or PDFs file formats.
+
+- The `waitTime` option must be ≤ 64 seconds; otherwise, an error is thrown.
+
+- If the API takes more than 64 seconds to process the file, it will return only the run ID in the response.
+
+Sample response (when the API takes more than 64 seconds):
+```json
+{
+ "file": null,
+ "fileBase64": null,
+ "type": null,
+ "extension": null,
+ "wordCount": null,
+ "charCount": null,
+ "sizeInKb": null,
+ "durationInSeconds": null,
+ "pageCount": null,
+ "slideCount": null,
+ "entities": null,
+ "runId": "1273a8c6-c498-4293-a9d6-389864cd3a44",
+ "status": "IN_PROGRESS",
+ "errors": null
+}
+```
+
+## Get run:
+To retrieve the results of a previously started file `deidentification operation`, use the `getDetectRun` method.
+The `GetDetectRunRequest` class is initialized with the `runId` returned from a prior deidentifyFile call.
+This method allows you to fetch the final results of the file processing operation once they are available.
+
+### Construct an get run request
+
+```java
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.detect.DeidentifyFileResponse;
+import com.skyflow.vault.detect.GetDetectRunRequest;
+
+/**
+ * Skyflow Get Detect Run Example
+ */
+
+public class GetDetectRunSchema {
+
+ public static void main(String[] args) {
+ try {
+ // Step 1: Initialise the Skyflow client by configuring the credentials & vault config.
+
+ // Step 2: Create a get detect run request
+ GetDetectRunRequest getDetectRunRequest = GetDetectRunRequest.builder()
+ .runId("") // Replace with the runId from deidentifyFile call
+ .build();
+
+ // Step 3: Call getDetectRun to poll for file processing results
+ // Replace with your actual vault ID
+ DeidentifyFileResponse deidentifyFileResponse = skyflowClient.detect("").getDetectRun(getDetectRunRequest);
+ System.out.println("Get Detect Run Response: " + deidentifyFileResponse);
+ } catch (SkyflowException e) {
+ System.err.println("Error occurred during get detect run: ");
+ e.printStackTrace();
+ }
+ }
+}
+
+```
+
+## An [example](https://github.com/skyflowapi/skyflow-java/blob/main/samples/src/main/java/com/example/detect/GetDetectRunExample.java) of get run
+```java
+import com.skyflow.config.Credentials;
+import com.skyflow.config.VaultConfig;
+import com.skyflow.enums.Env;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.detect.DeidentifyFileResponse;
+import com.skyflow.vault.detect.GetDetectRunRequest;
+
+/**
+ * Skyflow Get Detect Run Example
+ *
+ * This example demonstrates how to:
+ * 1. Configure credentials
+ * 2. Set up vault configuration
+ * 3. Create a get detect run request
+ * 4. Call getDetectRun to poll for file processing results
+ * 5. Handle response and errors
+ */
+public class GetDetectRunExample {
+ public static void main(String[] args) throws SkyflowException {
+ // Step 1: Initialise the Skyflow client by configuring the credentials & vault config.
+ try {
+
+ // Step 2: Create a get detect run request
+ GetDetectRunRequest getDetectRunRequest = GetDetectRunRequest.builder()
+ .runId("e0038196-4a20-422b-bad7-e0477117f9bb") // Replace with the runId from deidentifyFile call
+ .build();
+
+ // Step 3: Call getDetectRun to poll for file processing results
+ // Replace `9f27764a10f7946fe56b3258e117` with the acutal vault id
+ DeidentifyFileResponse deidentifyFileResponse = skyflowClient.detect("9f27764a10f7946fe56b3258e117").getDetectRun(getDetectRunRequest);
+ System.out.println("Get Detect Run Response: " + deidentifyFileResponse);
+ } catch (SkyflowException e) {
+ System.err.println("Error occurred during get detect run: ");
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+Sample Response:
+
+```json
+{
+ "file": "bmFtZTogW05BTET0JfMV0K",
+ "type": "redacted_file",
+ "extension": "txt",
+ "wordCount": 11,
+ "charCount": 61,
+ "sizeInKb": 0.0,
+ "entities": [
+ {
+ "file": "gW05BTUVfMV0gCmNhcmQ0K",
+ "type": "entities",
+ "extension": "json"
+ }
+ ],
+ "runId": "e0038196-4a20-422b-bad7-e0477117f9bb",
+ "status": "success"
+}
+
+```
+
+# Connections
+
+Skyflow Connections is a gateway service that uses tokenization to securely send and receive data between your systems and first- or third-party services. The [connections](https://github.com/skyflowapi/skyflow-java/tree/main/src/main/java/com/skyflow/vault/connection) module invokes both inbound and/or outbound connections.
+
+- **Inbound connections**: Act as intermediaries between your client and server, tokenizing sensitive data before it reaches your backend, ensuring downstream services handle only tokenized data.
+- **Outbound connections**: Enable secure extraction of data from the vault and transfer it to third-party services via your backend server, such as processing checkout or card issuance flows.
+
+## Invoke a connection
+
+To invoke a connection, use the `invoke` method of the Skyflow client.
+
+### Construct an invoke connection request
+
+```java
+import com.skyflow.enums.RequestMethod;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.connection.InvokeConnectionRequest;
+import com.skyflow.vault.connection.InvokeConnectionResponse;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This example demonstrates how to invoke an external connection using the Skyflow SDK, along with corresponding InvokeConnectionRequest schema.
+ *
+ */
+public class InvokeConnectionSchema {
+ public static void main(String[] args) {
+ try {
+ // Initialize Skyflow client
+ // Step 1: Define the request body parameters
+ // These are the values you want to send in the request body
+ Map requestBody = new HashMap<>();
+ requestBody.put("", "");
+ requestBody.put("", "");
+
+ // Step 2: Define the request headers
+ // Add any required headers that need to be sent with the request
+ Map requestHeaders = new HashMap<>();
+ requestHeaders.put("", "");
+ requestHeaders.put("", "");
+
+ // Step 3: Define the path parameters
+ // Path parameters are part of the URL and typically used in RESTful APIs
+ Map pathParams = new HashMap<>();
+ pathParams.put("", "");
+ pathParams.put("", "");
+
+ // Step 4: Define the query parameters
+ // Query parameters are included in the URL after a '?' and are used to filter or modify the response
+ Map queryParams = new HashMap<>();
+ queryParams.put("", "");
+ queryParams.put("", "");
+
+ // Step 5: Build the InvokeConnectionRequest using the provided parameters
+ InvokeConnectionRequest invokeConnectionRequest = InvokeConnectionRequest.builder()
+ .method(RequestMethod.POST) // The HTTP method to use for the request (POST in this case)
+ .requestBody(requestBody) // The body of the request
+ .requestHeaders(requestHeaders) // The headers to include in the request
+ .pathParams(pathParams) // The path parameters for the URL
+ .queryParams(queryParams) // The query parameters to append to the URL
+ .build();
+
+ // Step 6: Invoke the connection using the request
+ // Replace "" with the actual connection ID you are using
+ InvokeConnectionResponse invokeConnectionResponse = skyflowClient.connection("").invoke(invokeConnectionRequest);
+
+ // Step 7: Print the response from the invoked connection
+ // This response contains the result of the request sent to the external system
+ System.out.println(invokeConnectionResponse);
+
+ } catch (SkyflowException e) {
+ // Step 8: Handle any exceptions that occur during the connection invocation
+ System.out.println("Error occurred: ");
+ e.printStackTrace(); // Print the exception stack trace for debugging
+ }
+ }
+}
+```
+
+`method` supports the following methods:
+
+- GET
+- POST
+- PUT
+- PATCH
+- DELETE
+
+**pathParams, queryParams, requestHeader, requestBody** are the JSON objects represented as HashMaps, that will be sent through the connection integration url.
+
+### An [example](https://github.com/skyflowapi/skyflow-java/blob/main/samples/src/main/java/com/example/connection/InvokeConnectionExample.java) of invokeConnection
+
+```java
+import com.skyflow.Skyflow;
+import com.skyflow.config.ConnectionConfig;
+import com.skyflow.config.Credentials;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.enums.RequestMethod;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.connection.InvokeConnectionRequest;
+import com.skyflow.vault.connection.InvokeConnectionResponse;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This example demonstrates how to invoke an external connection using the Skyflow SDK.
+ * It configures a connection, sets up the request, and sends a POST request to the external service.
+ *
+ * 1. Initialize Skyflow client with connection details.
+ * 2. Define the request body, headers, and method.
+ * 3. Execute the connection request.
+ * 4. Print the response from the invoked connection.
+ */
+public class InvokeConnectionExample {
+ public static void main(String[] args) {
+ try {
+ // Initialize Skyflow client
+ // Step 1: Set up credentials and connection configuration
+ // Load credentials from a JSON file (you need to provide the correct path)
+ Credentials credentials = new Credentials();
+ credentials.setPath("/path/to/credentials.json");
+
+ // Define the connection configuration (URL and credentials)
+ ConnectionConfig connectionConfig = new ConnectionConfig();
+ connectionConfig.setConnectionId(""); // Replace with actual connection ID
+ connectionConfig.setConnectionUrl("https://connection.url.com"); // Replace with actual connection URL
+ connectionConfig.setCredentials(credentials); // Set credentials for the connection
+
+ // Initialize the Skyflow client with the connection configuration
+ Skyflow skyflowClient = Skyflow.builder()
+ .setLogLevel(LogLevel.DEBUG) // Set log level to DEBUG for detailed logs
+ .addConnectionConfig(connectionConfig) // Add connection configuration to client
+ .build(); // Build the Skyflow client instance
+
+ // Step 2: Define the request body and headers
+ // Map for request body parameters
+ Map requestBody = new HashMap<>();
+ requestBody.put("card_number", "4337-1696-5866-0865"); // Example card number
+ requestBody.put("ssn", "524-41-4248"); // Example SSN
+
+ // Map for request headers
+ Map requestHeaders = new HashMap<>();
+ requestHeaders.put("Content-Type", "application/json"); // Set content type for the request
+
+ // Step 3: Build the InvokeConnectionRequest with required parameters
+ // Set HTTP method to POST, include the request body and headers
+ InvokeConnectionRequest invokeConnectionRequest = InvokeConnectionRequest.builder()
+ .method(RequestMethod.POST) // HTTP POST method
+ .requestBody(requestBody) // Add request body parameters
+ .requestHeaders(requestHeaders) // Add headers
+ .build(); // Build the request
+
+ // Step 4: Invoke the connection and capture the response
+ // Replace "" with the actual connection ID
+ InvokeConnectionResponse invokeConnectionResponse = skyflowClient.connection("").invoke(invokeConnectionRequest);
+
+ // Step 5: Print the response from the connection invocation
+ System.out.println(invokeConnectionResponse); // Print the response to the console
+
+ } catch (SkyflowException e) {
+ // Step 6: Handle any exceptions that occur during the connection invocation
+ System.out.println("Error occurred: ");
+ e.printStackTrace(); // Print the exception stack trace for debugging
+ }
+ }
+}
+```
+
+Sample response:
+
+```json
+{
+ "data": {
+ "card_number": "4337-1696-5866-0865",
+ "ssn": "524-41-4248"
+ },
+ "metadata": {
+ "requestId": "4a3453b5-7aa4-4373-98d7-cf102b1f6f97"
+ }
+}
+```
+
+# Authenticate with bearer tokens
+
+This section covers methods for generating and managing tokens to authenticate API calls:
+
+- **Generate a bearer token**:
+ Enable the creation of bearer tokens using service account credentials. These tokens, valid for 60 minutes, provide secure access to Vault services and management APIs based on the service account's permissions. Use this for general API calls when you only need basic authentication without additional context or role-based restrictions.
+- **Generate a bearer token with context**:
+ Support embedding context values into bearer tokens, enabling dynamic access control and the ability to track end-user identity. These tokens include context claims and allow flexible authorization for Vault services. Use this when policies depend on specific contextual attributes or when tracking end-user identity is required.
+- **Generate a scoped bearer token**:
+ Facilitate the creation of bearer tokens with role-specific access, ensuring permissions are limited to the operations allowed by the designated role. This is particularly useful for service accounts with multiple roles. Use this to enforce fine-grained role-based access control, ensuring tokens only grant permissions for a specific role.
+- **Generate signed data tokens**:
+ Add an extra layer of security by digitally signing data tokens with the service account's private key. These signed tokens can be securely detokenized, provided the necessary bearer token and permissions are available. Use this to add cryptographic protection to sensitive data, enabling secure detokenization with verified integrity and authenticity.
+
+## Generate a bearer token
+
+The [Service Account](https://github.com/skyflowapi/skyflow-java/tree/main/src/main/java/com/skyflow/serviceaccount/util) Java module generates service account tokens using a service account credentials file, which is provided when a service account is created. The tokens generated by this module are valid for 60 minutes and can be used to make API calls to the [Data](https://docs.skyflow.com/record/) and [Management](https://docs.skyflow.com/management/) APIs, depending on the permissions assigned to the service account.
+
+The `BearerToken` utility class generates bearer tokens using a credentials JSON file. Alternatively, you can pass the credentials as a string.
+
+[Example](https://github.com/skyflowapi/skyflow-java/blob/main/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationExample.java):
+
+```java
+/**
+ * Example program to generate a Bearer Token using Skyflow's BearerToken utility.
+ * The token can be generated in two ways:
+ * 1. Using the file path to a credentials.json file.
+ * 2. Using the JSON content of the credentials file as a string.
+ */
+public class BearerTokenGenerationExample {
+ public static void main(String[] args) {
+ // Variable to store the generated token
+ String token = null;
+
+ // Example 1: Generate Bearer Token using a credentials.json file
+ try {
+ // Specify the full file path to the credentials.json file
+ String filePath = "";
+
+ // Check if the token is either not initialized or has expired
+ if (Token.isExpired(token)) {
+ // Create a BearerToken object using the credentials file
+ BearerToken bearerToken = BearerToken.builder()
+ .setCredentials(new File(filePath)) // Set credentials from the file path
+ .build();
+
+ // Generate a new Bearer Token
+ token = bearerToken.getBearerToken();
+ }
+
+ // Print the generated Bearer Token to the console
+ System.out.println("Generated Bearer Token (from file): " + token);
+ } catch (SkyflowException e) {
+ // Handle any exceptions encountered during the token generation process
+ e.printStackTrace();
+ }
+
+ // Example 2: Generate Bearer Token using the credentials JSON as a string
+ try {
+ // Provide the credentials JSON content as a string
+ String fileContents = "";
+
+ // Check if the token is either not initialized or has expired
+ if (Token.isExpired(token)) {
+ // Create a BearerToken object using the credentials string
+ BearerToken bearerToken = BearerToken.builder()
+ .setCredentials(fileContents) // Set credentials from the string
+ .build();
+
+ // Generate a new Bearer Token
+ token = bearerToken.getBearerToken();
+ }
+
+ // Print the generated Bearer Token to the console
+ System.out.println("Generated Bearer Token (from string): " + token);
+ } catch (SkyflowException e) {
+ // Handle any exceptions encountered during the token generation process
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+## Generate bearer tokens with context
+
+**Context-aware authorization** embeds context values into a bearer token during its generation and so you can reference those values in your policies. This enables more flexible access controls, such as helping you track end-user identity when making API calls using service accounts, and facilitates using signed data tokens during detokenization. .
+
+A service account with the `context_id` identifier generates bearer tokens containing context information, represented as a JWT claim in a Skyflow-generated bearer token. Tokens generated from such service accounts include a `context_identifier` claim, are valid for 60 minutes, and can be used to make API calls to the Data and Management APIs, depending on the service account's permissions.
+
+[Example](https://github.com/skyflowapi/skyflow-java/blob/main/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationWithContextExample.java):
+
+```java
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.serviceaccount.util.BearerToken;
+
+import java.io.File;
+
+/**
+ * Example program to generate a Bearer Token using Skyflow's BearerToken utility.
+ * The token is generated using two approaches:
+ * 1. By providing the credentials.json file path.
+ * 2. By providing the contents of credentials.json as a string.
+ */
+public class BearerTokenGenerationWithContextExample {
+ public static void main(String[] args) {
+ // Variable to store the generated Bearer Token
+ String bearerToken = null;
+
+ // Approach 1: Generate Bearer Token by specifying the path to the credentials.json file
+ try {
+ // Replace with the full path to your credentials.json file
+ String filePath = "";
+
+ // Create a BearerToken object using the file path
+ BearerToken token = BearerToken.builder()
+ .setCredentials(new File(filePath)) // Set credentials using a File object
+ .setCtx("abc") // Set context string (example: "abc")
+ .build(); // Build the BearerToken object
+
+ // Retrieve the Bearer Token as a string
+ bearerToken = token.getBearerToken();
+
+ // Print the generated Bearer Token to the console
+ System.out.println(bearerToken);
+ } catch (SkyflowException e) {
+ // Handle exceptions specific to Skyflow operations
+ e.printStackTrace();
+ }
+
+ // Approach 2: Generate Bearer Token by specifying the contents of credentials.json as a string
+ try {
+ // Replace with the actual contents of your credentials.json file
+ String fileContents = "";
+
+ // Create a BearerToken object using the file contents as a string
+ BearerToken token = BearerToken.builder()
+ .setCredentials(fileContents) // Set credentials using a string representation of the file
+ .setCtx("abc") // Set context string (example: "abc")
+ .build(); // Build the BearerToken object
+
+ // Retrieve the Bearer Token as a string
+ bearerToken = token.getBearerToken();
+
+ // Print the generated Bearer Token to the console
+ System.out.println(bearerToken);
+ } catch (SkyflowException e) {
+ // Handle exceptions specific to Skyflow operations
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+## Generate scoped bearer tokens
+
+A service account with multiple roles can generate bearer tokens with access limited to a specific role by specifying the appropriate `roleID`. This can be used to limit access to specific roles for services with multiple responsibilities, such as segregating access for billing and analytics. The generated bearer tokens are valid for 60 minutes and can only execute operations permitted by the permissions associated with the designated role.
+
+[Example](https://github.com/skyflowapi/skyflow-java/blob/main/samples/src/main/java/com/example/serviceaccount/ScopedTokenGenerationExample.java):
+
+```java
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.serviceaccount.util.BearerToken;
+
+import java.io.File;
+import java.util.ArrayList;
+
+/**
+ * Example program to generate a Scoped Token using Skyflow's BearerToken utility.
+ * The token is generated by providing the file path to the credentials.json file
+ * and specifying roles associated with the token.
+ */
+public class ScopedTokenGenerationExample {
+ public static void main(String[] args) {
+ // Variable to store the generated scoped token
+ String scopedToken = null;
+
+ // Example: Generate Scoped Token by specifying the credentials.json file path
+ try {
+ // Create a list of roles that the generated token will be scoped to
+ ArrayList roles = new ArrayList<>();
+ roles.add("ROLE_ID"); // Add a specific role to the list (e.g., "ROLE_ID")
+
+ // Specify the full file path to the service account's credentials.json file
+ String filePath = "";
+
+ // Create a BearerToken object using the credentials file and associated roles
+ BearerToken bearerToken = BearerToken.builder()
+ .setCredentials(new File(filePath)) // Set credentials using the credentials.json file
+ .setRoles(roles) // Set the roles that the token should be scoped to
+ .build(); // Build the BearerToken object
+
+ // Retrieve the generated scoped token
+ scopedToken = bearerToken.getBearerToken();
+
+ // Print the generated scoped token to the console
+ System.out.println(scopedToken);
+ } catch (SkyflowException e) {
+ // Handle exceptions that may occur during token generation
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+Notes:
+
+- You can pass either the file path of a service account key credentials file or the service account key credentials as a string to the `setCredentials` method of the `BearerTokenBuilder` class.
+- If both a file path and a string are provided, the last method used takes precedence.
+- To generate multiple bearer tokens concurrently using threads, refer to the following [example](https://github.com/skyflowapi/skyflow-java/blob/main/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationUsingThreadsExample.java).
+
+## Generate Signed Data Tokens
+
+Skyflow generates data tokens when sensitive data is inserted into the vault. These data tokens can be digitally signed
+with the private key of the service account credentials, which adds an additional layer of protection. Signed tokens can
+be detokenized by passing the signed data token and a bearer token generated from service account credentials. The
+service account must have appropriate permissions and context to detokenize the signed data tokens.
+
+[Example](https://github.com/skyflowapi/skyflow-java/blob/main/samples/src/main/java/com/example/serviceaccount/SignedTokenGenerationExample.java):
+
+```java
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.serviceaccount.util.SignedDataTokenResponse;
+import com.skyflow.serviceaccount.util.SignedDataTokens;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SignedTokenGenerationExample {
+ public static void main(String[] args) {
+ List signedTokenValues;
+ // Generate Signed data token with context by specifying credentials.json file path
+ try {
+ String filePath = "