Run the workflow as a background process
Learn how to execute the workflow fully in the background, without displaying any user interface.
1
Set up the server
Create a Workflow Execution
const express = require('express');
const axios = require('axios');
const { v4: uuidv4 } = require('uuid');
const API_BASE = 'https://api.transactionlink.io';
// --- Recommended: organization token (tot_) ---
const ORG_TOKEN = process.env.ORG_TOKEN ?? 'tot_<your-organization-token>';
// --- Legacy: JWT — deprecated, will be removed in a future release ---
// const jwt = await axios.post(`${API_BASE}/auth/authorize`, { key, secret });
// const AUTH_HEADER = `Bearer ${jwt.data.accessToken}`;
const AUTH_HEADER = ORG_TOKEN; // recommended
const api = axios.create({ baseURL: API_BASE, headers: { Authorization: AUTH_HEADER } });
const app = express();
app.use(express.json());
app.post('/create-workflow-embedded', async (_req, res) => {
const { data } = await api.post('/token', {
recordId: uuidv4(),
workflowDefinitionId: uuidv4(),
});
res.json({ token: data.token });
});
app.get('/workflow-status', async (req, res) => {
const { data } = await api.get(`/workflows/${req.query.execution_id}`);
res.json({ status: data.status, executionId: data.id });
});
app.listen(8080, () => console.log('Running on port 8080'));Last updated