Skip to content

Install an integration, connect a HubSpot account, mint a link token from your backend, open the Connect UI from your frontend, and make your first Unified API call.

Info

On Windows, install the CLI with PowerShell instead: irm https://cli.truto.one/install.ps1 | iex, then truto login --token $env:TRUTO_API_TOKEN.

Setting up Truto with a coding agent

If you're using Cursor, Claude Code, or any other agent that supports the Agent Skills convention, install the Truto skills pack and the Truto CLI once — the agent then knows how to wire Truto into your codebase from a single prompt.

Before you prompt: install HubSpot and the crm Unified API from the Catalog in the environment your API token belongs to. The steps are under Setting up Truto by hand.

1. Install the Truto skills pack

npx skills add trutohq/truto-skills

This installs eight skills your agent can call into:

Skill What it covers
truto Application code that calls the Truto API — link-token routes, Unified, Proxy and Custom API calls, webhook handlers
truto-link-sdk Embedding the Connect UI in a frontend with @truto/truto-link-sdk
truto-cli Driving the Truto CLI for setup, exploration, and debugging in the terminal
truto-jsonata Writing JSONata for Unified API mappings, sync jobs, workflows, RapidForms
truto-api-conventions Truto API base URL, auth header, URL patterns, pagination, idempotency
truto-integrations-build Building a new integration definition from a vendor's API docs with the CLI
truto-unified-mappings Building and applying the mappings that connect one integration to a unified model
truto-operator Debugging and operating your live Truto environments from the in-dashboard Platform Assistant

2. Install the Truto CLI

Linux / macOS:

curl -fsSL https://cli.truto.one/install.sh | bash
truto login --token "$TRUTO_API_TOKEN"
truto whoami -o json

Windows (PowerShell):

irm https://cli.truto.one/install.ps1 | iex
truto login --token $env:TRUTO_API_TOKEN
truto whoami -o json

The installer drops the truto binary in ~/.truto/bin (macOS/Linux) or %USERPROFILE%\.truto\bin (Windows). TRUTO_API_TOKEN is an API token created in the Truto dashboard — see Generating an API token.

truto whoami -o json prints your team. If you see your team name, the agent and the CLI are ready. Run truto environments list to see the token's environment.

3. Prompts to drop into your agent

Once the skills and CLI are in place, paste any of these into your agent. Each one uses skills installed in step 1 and is enough on its own.

Set up Truto in this codebase. Add a POST /api/truto/link-token route on the
backend that mints a link token for a given tenantId (and reconnects an
existing integratedAccountId), returning the API's own status and body when
the mint is refused, and a button in the frontend that opens the Connect UI
with @truto/truto-link-sdk. Use the truto and truto-link-sdk skills.
Add a webhook handler at POST /webhooks/truto. Verify the X-Truto-Signature
header against the webhook's secret before parsing the body. Switch on the
`event` field. When it is integrated_account:active, mark the tenant's
connection as ready and store payload.id as the integrated account ID. Handle
integrated_account:post_install_error and integrated_account:validation_error
too. Use the truto skill.
Add a server-side helper that lists CRM contacts for a given
integrated_account_id by calling GET /unified/crm/contacts on api.truto.one,
then walks pages with next_cursor. Use the truto skill.

Your coding agent can also search these docs while it works: add the Truto Docs MCP server to its config, as shown in Ask the docs with AI.


Setting up Truto by hand

The rest of this page is the same flow without an agent — install integrations from the dashboard, generate an API token, mint a link token from your backend, and call the Unified API yourself. Use it as a step-by-step walkthrough on its own, or as a reference for what the agent prompts above are doing.

Install your first integration

Integrations are what enable you to connect your customer's apps to Truto.

Your Truto account by default doesn't come with any Integrations installed and any integration you need to use needs to be installed manually before connecting an account for it.

You can head on over to the Catalog to see the integrations available for installation under the Integrations tab.

In this guide, we'll install the HubSpot integration. Find it in the Catalog and click Install.

HubSpot in the Catalog

Pick the environments you want it in and click Install.

Install HubSpot integration modal

Info

Environments are logical grouping of resources in your Truto account. They help you try out things in isolation without affecting your production data.

Install the Unified API for CRMs

After installing HubSpot, we will install the Unified API for CRMs which will enable us to query the HubSpot API and get responses in a unified format. This Unified API can also be used with other CRMs.

In the same Catalog, switch to the Unified APIs tab and install the crm Unified API. Installing a Unified API works the same way as installing an integration.

CRM Unified API in the Catalog

Install Unified API modal

Generate an API token

You can follow our guide to generate an API token here.

Connect your first HubSpot account

Via the dashboard

Go to the Integrated Accounts tab and click Connect Account in the top-right corner.

Integrated accounts tab

Fill in the Tenant ID — your own identifier for the customer this account belongs to, so you can match accounts back to them later. This creates (or reuses) a tenant in the environment; the same ID always refers to the same tenant, so every account this customer connects will roll up under it. Pick the Environment and Region, then click Get connection link. Region is where Truto places the account: Western North America (wnam, the default), Eastern North America (enam), European Union (eu) or Asia Pacific (apac). From your backend, pass region on POST /link-token; it applies only when the link creates a new account.

Connect an account modal

Truto returns a connection link. Copy it and open it yourself, or share it with the customer.

Connection link to share

On that page, select HubSpot and complete the OAuth flow.

Select HubSpot to connect

Back in the dashboard, click Done to close the modal. The new account now shows on the Integrated Accounts tab.

From your own app

Connecting an account from your own app is two steps:

  1. Backend: mint a link token by POSTing to https://api.truto.one/link-token with your API token.
  2. Frontend: open the Connect UI with @truto/truto-link-sdk and that link token.

Step 1. Mint a link token from your backend

TRUTO_API_TOKEN is a server-side secret. Read it from an env var; never ship it to the browser.

Truto auto-creates a tenant the first time a given tenant_id connects an account. If you'd rather pre-create the tenant (to attach metadata like tier or region before the customer connects), call POST /tenant first — see Creating tenants.

curl --location 'https://api.truto.one/link-token' \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TRUTO_API_TOKEN" \
  --data '{
    "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!,
});
 
// New connection
const { link_token } = await truto.linkToken.createForNewIntegration({
  tenant_id: 'acme-1',
});
 
// Reconnect an existing account. The SDK doesn't send persist_previous_context,
// so the account's variables are replaced; call POST /link-token directly to keep them.
const reconnect = await truto.linkToken.createForExistingIntegratedAccount({
  integrated_account_id: 'existing-account-id',
});
# pip install truto-python-sdk
import asyncio, os
from truto_python_sdk import TrutoApi
 
async def main():
    truto = TrutoApi(token=os.environ["TRUTO_API_TOKEN"])
 
    # New connection
    new_token = await truto.link_tokens.create({"tenant_id": "acme-1"})
 
    # Reconnect an existing account
    reconnect_token = await truto.link_tokens.create({
        "integrated_account_id": "existing-account-id",
        "persist_previous_context": True,
    })
 
    print(new_token, reconnect_token)
 
asyncio.run(main())

Response:

{
  "link_token": "e73c7b9b-2e4d-47d1-b5d2-83441fd24e4c"
}

Wrap the call in a backend route for your frontend to call. The same route handles new connections (tenant_id) and reconnections (integrated_account_id) — wiring both from the start prevents users from creating duplicate accounts when an existing connection fails. When Truto refuses the mint, the route passes Truto's status and body through, so the caller sees the real reason.

// Express route handler
import express from 'express';
 
const app = express();
app.use(express.json());
 
app.post('/api/truto/link-token', async (req, res) => {
  const { tenantId, integratedAccountId } = req.body;
 
  const body = integratedAccountId
    ? { integrated_account_id: integratedAccountId, persist_previous_context: true }
    : { tenant_id: tenantId };
 
  const response = await fetch('https://api.truto.one/link-token', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.TRUTO_API_TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(body),
  });
 
  if (!response.ok) {
    // Pass Truto's refusal through so the caller sees the real status and reason
    return res.status(response.status).json(await response.json());
  }
 
  const { link_token } = await response.json();
  res.json({ linkToken: link_token });
});
# Flask route handler
import os
import requests
from flask import Flask, request, jsonify
 
app = Flask(__name__)
 
@app.post("/api/truto/link-token")
def link_token():
    payload = request.get_json() or {}
    tenant_id = payload.get("tenantId")
    integrated_account_id = payload.get("integratedAccountId")
 
    body = (
        {"integrated_account_id": integrated_account_id, "persist_previous_context": True}
        if integrated_account_id
        else {"tenant_id": tenant_id}
    )
 
    response = requests.post(
        "https://api.truto.one/link-token",
        headers={
            "Authorization": f"Bearer {os.environ['TRUTO_API_TOKEN']}",
            "Content-Type": "application/json",
        },
        json=body,
        timeout=10,
    )
    if not response.ok:
        # Pass Truto's refusal through so the caller sees the real status and reason
        return response.json(), response.status_code
    return jsonify(linkToken=response.json()["link_token"])

The same route as a Next.js route handler:

// Next.js route handler: app/api/truto/link-token/route.ts
export async function POST(req: Request) {
  const { tenantId, integratedAccountId } = await req.json();
 
  const body = integratedAccountId
    ? { integrated_account_id: integratedAccountId, persist_previous_context: true }
    : { tenant_id: tenantId };
 
  const response = await fetch('https://api.truto.one/link-token', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.TRUTO_API_TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(body),
  });
 
  if (!response.ok) {
    // Pass Truto's refusal through so the caller sees the real status and reason
    return Response.json(await response.json(), { status: response.status });
  }
 
  const { link_token } = await response.json();
  return Response.json({ linkToken: link_token });
}

And as a Hono route:

// Hono route handler
import { Hono } from 'hono';
 
type Env = { TRUTO_API_TOKEN: string };
const app = new Hono<{ Bindings: Env }>();
 
app.post('/api/truto/link-token', async (c) => {
  const { tenantId, integratedAccountId } = await c.req.json();
 
  const body = integratedAccountId
    ? { integrated_account_id: integratedAccountId, persist_previous_context: true }
    : { tenant_id: tenantId };
 
  const response = await fetch('https://api.truto.one/link-token', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${c.env.TRUTO_API_TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(body),
  });
 
  if (!response.ok) {
    // Pass Truto's refusal through so the caller sees the real status and reason
    return new Response(await response.text(), {
      status: response.status,
      headers: { 'Content-Type': 'application/json' },
    });
  }
 
  const { link_token } = await response.json();
  return c.json({ linkToken: link_token });
});
 
export default app;
Warning

TRUTO_API_TOKEN must stay on the server. Never expose it to the browser, and never hardcode it in client bundles. Link tokens are safe for the frontend — each one expires after 7 days and is used up once a connection completes with it; the API token isn't.

Step 2. Open the Connect UI from your frontend

Install the SDK:

npm install @truto/truto-link-sdk

Call your backend route to get a link token, then hand it to authenticate(). The same call works for new connections and reconnections — the difference is in the body your backend posts.

import authenticate from '@truto/truto-link-sdk';
 
async function getLinkToken(body: Record<string, string>) {
  const res = await fetch('/api/truto/link-token', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
  });
  const { linkToken } = await res.json();
  return linkToken;
}
 
async function openTrutoLink(linkToken: string) {
  try {
    const result = await authenticate(linkToken);
    console.log('Connected:', result);
    // { result: 'success', integration: 'hubspot', integrated_account_id: '...' }
    return result;
  } catch (err) {
    if (err === 'closed') {
      console.log('User closed the connection dialog');
    } else {
      console.error('Connection failed:', err);
    }
    throw err;
  }
}
 
// New connection
const linkToken = await getLinkToken({ tenantId: 'acme-1' });
await openTrutoLink(linkToken);
 
// Reconnect an existing account
const reconnectToken = await getLinkToken({ integratedAccountId: 'existing-account-id' });
await openTrutoLink(reconnectToken);

If you'd rather not embed the SDK, you can open the hosted Connect UI with the link token directly:

https://app.truto.one/connect-account?link_token=<link-token-from-previous-step>

See Embedding the Truto Link SDK for popup, iframe, and same-window options, and the full request schema for POST /link-token.

Make your first API request

Open the newly connected HubSpot account's detail page and switch to the Unified API tab. This opens a playground where you can pick a resource (like crm/contacts) and method, call the API, and see the unified response — a quick way to try calls before wiring them into your code.

Try the Unified API for an integrated account

To make the same call from your code, use your API token in the Authorization: Bearer header. The API reference page for the CRM Unified API lists every available resource and method.

curl "https://api.truto.one/unified/crm/contacts?integrated_account_id=<integrated_account_id>" \
  -H "Authorization: Bearer $TRUTO_API_TOKEN"
truto unified crm contacts -a <integrated_account_id>
import TrutoApi from '@truto/truto-ts-sdk';
 
const truto = new TrutoApi({ token: process.env.TRUTO_API_TOKEN! });
 
const contacts = truto.unifiedApi.list({
  unified_model: 'crm',
  resource: 'contacts',
  integrated_account_id: '<integrated_account_id>',
});
for await (const contact of contacts) {
  console.log(contact);
}
import asyncio, os
from truto_python_sdk import TrutoApi
 
async def main():
    truto = TrutoApi(token=os.environ["TRUTO_API_TOKEN"])
    async for contact in truto.unified_api.list(
        "crm", "contacts", {"integrated_account_id": "<integrated_account_id>"}
    ):
        print(contact)
 
asyncio.run(main())

Next

The API reference overview covers authentication, pagination, query parameters, rate limits and errors for every call. To know when an account finishes connecting, listen for integrated_account:active with a webhook.