Skip to content

Open Truto's Connect UI in your own page with authenticate() from @truto/truto-link-sdk, so your customer connects an app without leaving your product.

Skip the reading — fast path for coding agents
CLI
truto link-tokens create --tenant-id <tenant_id>
Skill
View truto-link-sdk skill on GitHub Cursor / Claude Code: /skill truto-link-sdk

The SDK needs a link token for the customer's tenant. Create it on your backend with your API token; never call POST /link-token from the browser. See the Create Link Token API reference for every field.

curl -X POST https://api.truto.one/link-token \
  -H "Authorization: Bearer $TRUTO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tenant_id": "acme-1"}'
truto link-tokens create --tenant-id acme-1
// npm install @truto/truto-ts-sdk
import TrutoApi from '@truto/truto-ts-sdk'
 
const truto = new TrutoApi({ token: process.env.TRUTO_API_TOKEN! })
 
const { link_token } = await truto.linkToken.createForNewIntegration({
  tenant_id: 'acme-1',
})
# pip install truto-python-sdk
import asyncio
import os
 
from truto_python_sdk import TrutoApi
 
async def main():
    truto = TrutoApi(token=os.environ["TRUTO_API_TOKEN"])
    response = await truto.link_tokens.create({"tenant_id": "acme-1"})
    print(response["link_token"])
 
asyncio.run(main())

Return the link_token to your frontend. A link token works for 7 days, or until an account is created or updated with it. A failure before the account is created, such as cancelling on the consent screen, leaves the token usable: your customer can retry with the same token. After a post_install_error or validation_error, the token is already used up; create a new one to retry. To reconnect an existing account, create the token with its integrated_account_id instead; see Reauthorizing connections.

2. Install the SDK

npm install @truto/truto-link-sdk

3. Open the Connect UI and handle the result

authenticate opens the Connect UI as a full-screen overlay (an iframe) on top of your page. Pass { iframe: false } to open it in a popup window instead, or { integration: '<integration name>' } to skip the integration list. The Link SDK reference lists every option. Leave redirect_uri off the link token here: in the overlay or popup, the Connect UI goes to it when the flow ends and the promise never settles (see Return to your app with redirect_uri).

import authenticate from '@truto/truto-link-sdk';
 
// The link token your backend returned in step 1
const linkToken = '<link_token>';
 
try {
  const response = await authenticate(linkToken);
  // { result: 'success', integration: 'copper', integrated_account_id: '...', post_connect_form: '{}' }
  console.log('Connected', response.integration, response.integrated_account_id);
} catch (error) {
  if (error === 'closed') {
    // The customer closed the overlay without finishing
  } else if (error === 'blocked') {
    // The browser blocked the popup (only with iframe: false)
  } else {
    // { result: 'error', error, error_type, integration, integrated_account_id? }
    console.error(error.error_type, error.error);
  }
}

The promise resolves once the account is connected. It rejects with the string "closed" when the customer closes the overlay or popup, and with an object carrying error_type when the connection fails, for example post_install_error or validation_error after the account was created. The error table lists every error_type.

4. Confirm the connection on your backend

Don't rely on the browser alone: the customer can close the tab before your page hears back. Save the integrated_account_id when Truto sends integrated_account:active to your webhook, and use that ID for every API call on the account. Connection flow lists the events Truto sends while an account connects, including the failures.

You don't have to embed the SDK. Get a connection link from Integrated Accounts → Connect Account in the dashboard, or build one from a link token as https://app.truto.one/connect-account?link_token=<link_token>, and send it to your customer; they connect without your app embedding anything. See Connect an account.

Next

The Link SDK reference covers every authenticate option and RapidForm. To give each customer a page that lists and manages all their connections, embed the connections widget.