Run the workflow inside your application
Learn how to render the workflow directly inside your application using an iframe for a seamless user experience.
You’ll build a simple integration where the user completes a workflow directly inside your app.
The example includes both client- and server-side code, and shows how to create a workflow execution and render the interface using the embedded mode. The workflow UI is securely loaded in an <iframe>, allowing you to fully integrate the process into your product without redirecting the user to an external page.
This setup is ideal for cases where you want full control over the user experience and visual consistency with your product.
Use this approach when:
The workflow is part of an onboarding, verification, or registration flow
You want to avoid any external redirection
You need to match the look & feel of your existing UI
You're building internal tooling or back-office processes with light user input
Set up the server
Create a Workflow Execution
Add an endpoint on your server that creates a Workflow Execution.
The response includes a token, which is used on the client side to initialize and mount the widget.
Return the token in your response so it can be passed to the widget in the frontend.
const express = require('express');
const axios = require('axios');
const API_BASE = process.env.API_BASE ?? 'https://api.transactionlink.io';
// --- Recommended: organization token (tot_) ---
const ORG_TOKEN = process.env.ORG_TOKEN ?? 'tot_<your-organization-token>';
// --- Legacy: workspace credentials (JWT) — deprecated, will be removed in a future release ---
const KEY = process.env.KEY ?? '<your-key>';
const SECRET = process.env.SECRET ?? '<your-secret>';
const WF_DEF_ID = process.env.WF_DEF_ID ?? '<your-workflow-definition-id>';
const api = axios.create({ baseURL: API_BASE });
const app = express();
app.use(express.json());
// Legacy: obtain a JWT access token using workspace credentials.
// Deprecated in favor of organization tokens (tot_).
async function authorizeWithJwt() {
const { data } = await api.post('/auth/authorize', { key: KEY, secret: SECRET });
return data.accessToken;
}
// Returns the Authorization header value for the current auth strategy.
// Switch to the legacy option below if you haven't migrated to organization tokens yet.
function getAuthHeader() {
// Recommended: pass the organization token directly (no Bearer prefix)
return ORG_TOKEN;
// Legacy (deprecated): obtain a JWT and pass it as a Bearer token
// const jwt = await authorizeWithJwt();
// return `Bearer ${jwt}`;
}
app.post('/create-workflow', async (_req, res) => {
const payload = {
workflowDefinitionId: WF_DEF_ID,
expiresAt: new Date(Date.now() + 61 * 60 * 1000).toISOString(),
locale: 'en',
};
const { data } = await api.post('/workflows', payload, {
headers: { Authorization: getAuthHeader() },
});
res.json({ token: data.token, workflowId: data.id });
});
app.get('/workflow-status', async (req, res) => {
const workflowId = req.query.workflowId;
const { data } = await api.get(`/workflows/${workflowId}`, {
headers: { Authorization: getAuthHeader() },
}).catch(reason => console.log(reason));
res.json({ status: data.status, workflowId: data.id });
});
app.listen(8080, () => console.log('Running on port 8080'));Set the workflow to execute
workflowDefinitionId – UUID (required)
The ID of the workflow you want to execute. This refers to a predefined flow configured in your TransactionLink Dashboard.
📌 You can find the workflowDefinitionId in the Dashboard by viewing the workflow’s details.
Set an expiration time
expiresAt – ISO 8601 timestamp
Defines when the workflow execution becomes invalid.
Must be between 30 minutes and 30 days from creation.
If omitted, defaults to 1 hour.
🔐 Use this to enforce time-limited actions (e.g. document upload, identity verification) and avoid stale sessions.
Set the interface language
locale: language code (for example en, pl, de)
Controls the language of the user-facing interface.
If left blank, we detect the user's browser language.
Use a code from Supported languages. The API rejects other values, for example
en-US.
Build your page
Create HTML element for widget
Add an HTML on your page that will be replaced with an embedded Transactionlink widget.
Place either <transactionlink-widget />or <div id="transactionlink-widget" /> element
<transactionlink-widget />Obtain an ID and a token
Use an API created on your server in previous step to receive an execution ID and token for your workflow. You can trigger an HTTP call for the token when your application needs to launch the widget - on a button click, page load, or in any other scenario that is specific to your use case.
async function createWorkflowExecution() {
try {
const response = await fetch('/workflow-execution', { method: 'POST' });
const data = await response.json()
return data;
} catch (err) {
console.error(err);
throw err;
}
}Initialize widget
Append the widget script to the page and define a callback function as window.transactionlink_ready. It will be executed when the script is ready, so that you can pass the previously obtained token and launch the widget.
Await for workflow status (optional)
If you want your app to be notified when the workflow has been completed, you can poll for workflow status. It may be useful to close the Transactionlink widget and update your UI.
Update your launchWidget function as follows:
Get notified about workflow status
There are two ways to notify your backend when something happens in the workflow
1. Webhook Task
You can add a Webhook Task directly in your workflow. This lets you send a custom HTTP POST request to your server at any point during the flow — with a payload you fully control.
Use it when:
You want to notify your backend during a specific step in the process
You need to trigger external logic or update another system
You want to send dynamic data collected earlier in the flow
You want to notify your server when the process is completed — with your own payload
Both options can be used together or independently — depending on your use case.
2. Polling the API (Long polling)
As an alternative, you can implement long polling from your backend. This involves periodically calling the TransactionLink API to check the status of a specific workflow execution.
While not real-time, long polling can be useful when:
You cannot expose a public webhook endpoint
Your infrastructure requires strict control over incoming connections
You need fallback logic when webhooks are unavailable or blocked
Last updated