Building integrations in Cursor? Let a vendor run sign-in, token refresh and API changes (2026)
Cursor and Claude Code write integration code fast. The parts that break after launch are each customer's OAuth sign-in, token refresh, rate limits and vendor API changes. Here is who should run them, and how the code calls one API.
Uday Gajavalli
·
·
6 min read
Use Cursor in your own
Keep writing the integration logic in Cursor. Hand the parts that break after launch to a platform: each customer's OAuth sign-in, token refresh, vendor API changes and webhooks. Truto runs those for every connected account. Your Cursor code calls one API, and reads rate limits from one standard set of headers.
The rest of this post shows where that line falls, which vendors run the auth and upkeep part, and what the code looks like when Cursor or Claude Code writes it.
What does Cursor write well in an integration?
Cursor and Claude Code are good at the code you can see in one file:
- The request to the vendor's endpoint, with the right fields.
- The mapping from the vendor's record to your own data model.
- The business rules: which records to sync, what to create, what to skip.
- Tests for that logic, against sample responses.
For one vendor and one test account, that is often all you need. A coding agent can produce a working HubSpot or Jira call in minutes.
What still breaks after launch?
The trouble starts with the second customer, and gets worse with each new app. These are the jobs that do not live in one file. They run all day, for every account, and they fail when nobody is looking.
| Job | With Truto | Without a platform |
|---|---|---|
| Sign-in | Truto's approved OAuth apps, or your own | An OAuth app and app review per vendor |
| Token refresh | AES-256 at rest; refresh 60 to 180 s before expiry, one per account at a time | Encrypt tokens, refresh in time, stop two workers racing |
| Reconnect | Account marked needs_reauth; a webhook tells you |
Learn of a dead token from a failed call |
| Rate limits | One 429 with ratelimit-* headers; your code retries |
Learn each vendor's "slow down" |
| Pagination | Every list returns next_cursor |
One parser per vendor |
| API changes | Truto fixes the integration; no deploy | Find out from errors, fix, redeploy |
| Webhooks | Verified per vendor, sent as signed events | Keep an endpoint up, check each signature |
| Custom fields | Override the mapping for one account | Fork the mapping per customer |
Two notes on that table.
First, Truto does not retry a rate-limited call for you. It gives your code the same 429 and the same headers for every vendor, so one retry function covers all of them. The Truto Agent Skills teach Cursor to write that function.
Second, token refresh is where most home-built integrations fail in production. Race conditions, revoked tokens and vendors that do not return a new refresh token are common. Handling OAuth Token Refresh Failures in Production covers each case.
The full build-or-run comparison, with a cost model, is on Build integrations with AI.
Which vendors run sign-in and token refresh for you?
Several kinds of product run the auth and upkeep part. They differ in what your code calls.
- Unified API with a proxy: Truto. Call any app's own API through the Proxy API, or one schema per category through the unified APIs. Per-account MCP servers for agents. Missing apps are built from API docs with the Truto CLI.
- Sync-first unified API: Merge. A unified API for accounting, ATS, CRM, file storage, HR and ticketing, with passthrough requests for the vendor's own endpoints. Merge stores end-user data and credentials.
- Real-time unified API: Unified.to. Unified APIs with passthrough, webhooks and MCP. Its site says it keeps no customer records at rest.
- Embedded iPaaS: Paragon. Workflows embedded in your product, plus ActionKit tools for agents and Managed Sync.
- Code-first framework: Nango. You write each integration as code that runs on Nango's runtime, with auth, a proxy and MCP. It can be self-hosted.
- Managed auth and agent tools: Pipedream Connect. Managed auth, prebuilt actions and triggers, an API proxy and MCP for agents.
- Agent tools: Composio. MCP and tools for AI agents, priced per tool call.
Which one fits depends on what your code needs. If Cursor writes calls to many vendors' own endpoints, you want a proxy with managed auth. If your product reads the same kind of record from many apps, you want a unified API. If your customers build their own workflows, you want an embedded iPaaS. The embedded iPaaS vs unified API playbook goes deeper on that choice.
What does it look like from Cursor?
Here is a full loop: give Cursor the Truto context, ask for a feature, and check the code it writes.
1. Give Cursor the Truto context
Add the Truto skills once. In Cursor, open Settings, then Rules, then Add Rule. Choose Remote Rule (GitHub) and enter https://github.com/trutohq/truto-skills.
In Claude Code, run:
/plugin marketplace add trutohq/truto-skills
/plugin install truto@truto-skillsCodex, Windsurf and other agents that read SKILL.md files use npx skills add trutohq/truto-skills. Any MCP client can also use the docs MCP server at https://docs-mcp.truto.one/mcp. The skills stop the agent from guessing endpoints, auth flows and pagination.
2. Ask for the feature
A prompt like this one works:
Using the Truto skills, add CRM contact import. Add a backend route that mints a Truto link token for the current workspace. Then add a job that reads CRM contacts for each connected account through Truto's unified CRM API. Follow next_cursor to the end. On a 429, wait for Retry-After and try again. Keep TRUTO_API_TOKEN on the server.
3. Check the code
Cursor writes two parts. The first mints a link token, so your customer can connect their CRM through Truto's Connect UI:
// Server only: TRUTO_API_TOKEN never goes to the browser.
export async function createLinkToken(workspaceId: string) {
const res = 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({ tenant_id: workspaceId }),
});
if (!res.ok) throw new Error(`link-token failed: ${res.status}`);
return res.json();
}Your frontend passes that token to authenticate() from @truto/truto-link-sdk. The customer signs in to their CRM, and Truto sends integrated_account:active to your webhook. From then on, Truto keeps that account's token fresh.
The second part reads the contacts:
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
export async function listContacts(integratedAccountId: string) {
const contacts: unknown[] = [];
let cursor: string | null = null;
let attempts = 0;
while (true) {
const url = new URL('https://api.truto.one/unified/crm/contacts');
url.searchParams.set('integrated_account_id', integratedAccountId);
if (cursor) url.searchParams.set('next_cursor', cursor);
const res = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.TRUTO_API_TOKEN}` },
});
if (res.status === 429) {
// Every CRM's limit comes back as a 429 with the same ratelimit-*
// headers, and Retry-After when Truto has a value.
if (++attempts > 5) throw new Error('Rate limited 5 times in a row');
const wait = Number(res.headers.get('Retry-After')) || 10; // seconds; 10 if missing or a date
await sleep(wait * 1000);
continue; // retry the same page
}
if (!res.ok) throw new Error(`Truto returned ${res.status}`);
attempts = 0;
const page = await res.json();
contacts.push(...page.result);
cursor = page.next_cursor;
if (!cursor) break;
}
return contacts;
}Look at what the code does not have. It has no OAuth flow, no token table, no refresh job and no per-vendor paging. The same function reads HubSpot, Salesforce, Pipedrive or any other CRM in Truto's unified CRM API.
If you need a field that the unified model does not have, call the vendor's own endpoint through the Proxy API instead. The path changes to https://api.truto.one/proxy/contacts, and the response is the vendor's own record shape. Auth, refresh and paging stay the same.
4. When the app is not in the catalog
Ask Cursor to build it. The agent runs truto integrations build <api-docs-url>, reviews the integration file it writes, and runs truto integrations apply <file>. The integration is then live for every connected account, with no deploy of your app. The Build page shows each step, and the Truto CLI page lists every command.
How does a coding agent get a Truto account?
Today a person starts the account, and the agent does the rest:
- Sign up free at app.truto.one/signup. No card. The Free plan includes 25,000 API calls a month.
- In the Truto dashboard, open Settings, select API Tokens and click Create API Token. Choose the environment you build in; each token sees one environment only. The API token guide has every field.
- Give the token to the agent. It runs
truto login --token <your-api-token>, or readsTRUTO_API_TOKENfrom the environment. - Install the Truto skills, as in Give Cursor the Truto context.
After that, the agent can list integrations, connect a test account, make calls and build missing integrations from the terminal. Keep the token in your environment, not in the code.
FAQ
- Can Cursor build a production integration by itself?
- Cursor writes the code fast, but the code is the small part. A production integration also needs an OAuth app per vendor, encrypted tokens, refresh before expiry, a reconnect flow, rate-limit handling and a fix every time the vendor changes its API. A platform such as Truto runs that part for every customer account.
- Who refreshes OAuth tokens when my code calls Truto?
- Truto does. Truto refreshes each connected account's access token 60 to 180 seconds before it expires. When a refresh fails for good, Truto marks the account needs_reauth and sends an integrated_account:authentication_error webhook, so your product can ask the customer to sign in again.
- Does Truto retry rate-limited calls for me?
- No. Truto returns every vendor rate limit as a standard 429 with ratelimit-limit, ratelimit-remaining and ratelimit-reset headers, and Retry-After when the vendor gives one. Your code reads one set of headers for every app and decides when to retry.
- What happens when a vendor changes its API?
- Truto changes the integration definition, not your code. A change to an integration applies to every connected account with no deploy of your app. If you built the integration yourself with the Truto CLI, you change the integration file and apply it again.
- How do I give Cursor the Truto context it needs?
- Add the Truto skills as a remote rule. In Cursor, open Settings, then Rules, then Add Rule, choose Remote Rule (GitHub) and enter https://github.com/trutohq/truto-skills. Claude Code, Codex and other agents install the same skills, and any MCP client can use the Truto docs MCP server.