Skip to content

Guides Engineering

How a Coding Agent Builds Your Own Unified API on Truto, End to End

A step-by-step walkthrough with the Truto CLI and agent skills, from an empty model to live calls, per-customer overrides and rollback.

Roopendra Talekar Roopendra Talekar · · 6 min read

Your team’s apps in Elaichi, from the team behind Truto, free for 14 days. Try Elaichi
How a Coding Agent Builds Your Own Unified API on Truto, End to End

This walkthrough builds a unified API of your own on Truto, with a coding agent such as Claude Code or Cursor doing the typing. The example is a small CRM model, my-crm, with an accounts resource, mapped to HubSpot and Salesforce. Every command comes from the Truto CLI docs.

Why build it on Truto rather than as code in your own product is a separate question. Your Own Unified API: Build It on Truto or Build the Whole Layer? answers it.

What you need

  • A Truto team with the Pro add-on, or the 30-day trial of Pro on the Free plan. Building your own unified models is part of Pro.
  • The integrations you want to map, each with proxy resources. A pre-built integration has them. For a new app, build the integration first with truto integrations build. See /build.
  • A connected test account for each integration, or the app's API docs.
  • An Anthropic API key for the build's agent loop (ANTHROPIC_API_KEY).

Step 1: Install the CLI and the agent skills

curl -fsSL https://cli.truto.one/install.sh | bash
truto login
truto skills install

truto skills install installs Truto's agent skills for the coding agents on your machine. Two of them matter here. truto-unified-mappings covers building and applying the mappings. truto-jsonata covers JSONata and Truto's own functions. You can also install the pack with npx skills add trutohq/truto-skills. See Setting up Truto with a coding agent and Truto Agent Skills.

Now the agent can run the rest from one prompt, such as "Build a unified CRM model called my-crm with an accounts resource, and map HubSpot and Salesforce to it."

Step 2: Create the model

The model holds the resources and a JSON schema for each one. The agent creates it with the CLI:

truto unified-models create -b '{"name":"my-crm","category":"crm","description":"Our CRM model","resources":{...}}'

resources holds each resource, such as accounts, with a JSON schema of its fields. Creating Unified APIs on Truto shows the resource format. You can do the same in the dashboard: Catalog, then Unified APIs, then Create Unified API. The name sets the path, so my-crm answers at /unified/my-crm. Pick a name that no installed unified API uses: Truto's own CRM unified API is crm. See Creating Unified APIs on Truto.

Step 3: Build the mappings for each integration

truto unified-mappings build hubspot my-crm --account <hubspot_account_id>
truto unified-mappings build salesforce my-crm --account <salesforce_account_id>

The build is an agent loop. For each method of each resource, such as accounts.list, it:

  1. Finds the Proxy API endpoint that serves it, including a different name, such as unified accounts to HubSpot companies.
  2. Gets a sample: a read-only call through the account, a documented example on the integration, or the docs you pass with --source-url.
  3. Writes the JSONata and checks each field against the sample and your model's schema.

No account yet? Build from the app's docs. Here acme stands for any integration:

truto unified-mappings build acme my-crm --source-url https://docs.acme.com/openapi.json --yes

Each build writes a mapping file, for example hubspot.my-crm.mappings.json, and a report you can read beside it. Nothing changes in Truto until Step 5.

Step 4: Answer the questions

A method waits on a question when the build has no sample, cannot tell which endpoint serves it, or does not know where a value comes from. The build does not guess. The agent, or you, answers with --continue:

truto unified-mappings build --continue hubspot.my-crm.mappings.json --answer q1="companies.list"

--continue rebuilds only the methods the answers name. Every other method stays as it was. Never paste a key or a token as an answer: the CLI refuses an answer that looks like a credential.

In a terminal you can also type a fix in plain English, such as "strip the trailing Z from start times", and the agent rebuilds that method.

Step 5: Validate, then apply

truto unified-mappings validate hubspot.my-crm.mappings.json
truto unified-mappings apply hubspot.my-crm.mappings.json --target base --dry-run
truto unified-mappings apply hubspot.my-crm.mappings.json --target base
  • validate checks each method against your model's schema. It makes no LLM calls and writes nothing.
  • apply checks every method again, compares it with the live version, and writes only what passes. --dry-run shows the change first.
  • With --test-account <id>, apply runs read tests on that account after the write. It never writes to the app.

When an agent runs apply with no terminal, apply writes nothing and exits 3 unless you pass --yes. For a person to approve first, run apply --prepare, then apply --plan <path>.plan.json --expect-digest <digest> after the approval. See Unified mappings build.

Step 6: Install the model and call it

Creating a unified API does not install it. Until the model is installed in an environment, every call to it returns 404. truto environments list shows your environment IDs, truto unified-models list shows the model's ID, and truto accounts list shows the connected accounts' IDs. Then install it:

truto env-unified-models create --environment-id <environment_id> --unified-model-id <unified_model_id>

Then call it for any connected account in that environment:

truto unified my-crm accounts -a <integrated_account_id>
curl "https://api.truto.one/unified/my-crm/accounts?integrated_account_id=<integrated_account_id>" \
  -H 'Authorization: Bearer <API token>'

The same call works for a HubSpot account and a Salesforce account. Truto refreshes each account's tokens. A list call returns the records with next_cursor for the next page. When the app returns a 429, Truto passes it back with ratelimit headers and, when it has one, Retry-After, and your code decides when to retry. See How a Unified API call flows and Rate limits.

You can install the same model in each environment, for example development and production. See Install a Unified API.

Step 7: Test and debug a mapping

  • truto unified test-mapping --model my-crm --resource accounts --integration hubspot --input sample.json runs the response mapping against a saved sample, with no call to HubSpot.
  • truto jsonata eval runs any expression with Truto's JSONata functions.
  • On a live call, add truto_response_format=debug to see the request Truto sent and HubSpot's raw response.
  • Truto logs every unified call. Read the logs in the dashboard or with truto logs. See Viewing logs.

See Test mapping locally.

Step 8: Change it for one environment or one customer

An enterprise customer keeps the account tier in a custom field. You have two choices:

  • Environment override: changes a mapping for every connected account in one environment. Build it with truto unified-mappings build hubspot my-crm --account <hubspot_account_id> --target env --environment-id <environment_id>, then apply it with --target env.
  • Integrated account override: changes a mapping for one connected account. Its expression runs on the same raw record as the base mapping, and Truto merges its result over the base result. So it returns only the new field.
truto accounts update <integrated_account_id> -b '{
  "unified_model_override": {
    "my-crm": {
      "accounts": {
        "list": { "response_mapping": "{ \"tier\": properties.account_tier }" }
      }
    }
  }
}'

Read the account's unified_model_override first and send it back whole: an update replaces the object, it does not merge it. An account override runs on the account's next call. A change to a base mapping or an environment override can take up to about 23 minutes to reach calls, because each connection caches mappings. truto accounts refresh-mapping-cache applies it sooner. See Overriding Unified API mappings and 3-Level API Mapping.

Step 9: Roll back a bad change

In the dashboard, History in the mapping editor compares and restores earlier versions of a mapping. The Version history menu item does the same for the whole unified API. Revert to original, under a field of an override, goes back to the base version of that field. See Overriding Unified API mappings.

What this does not cover

  • MCP tools. Your agents' MCP tools come from the Proxy API: on a per-account MCP server, each Proxy API method that has a description is a tool. Your unified model does not add tools. See /mcp.
  • Retries. Your code handles 429s, as in Step 6.

What it costs

Building your own unified models is part of the Pro add-on, $499 a month, with a 30-day trial on the Free plan. Unified calls cost the same as other API calls, $5 per 100,000, and connections are free. Calls on Truto's managed Google and QuickBooks apps are priced separately. See pricing.

FAQ

Can Claude Code or Cursor build a unified API on Truto?
Yes. Install the Truto CLI and Truto's agent skills. The truto-unified-mappings and truto-jsonata skills teach the agent to run truto unified-mappings build, validate and apply, and to write JSONata mappings with Truto's functions.
What does truto unified-mappings build read?
The integration's Proxy API and your unified model's schema. With a connected account, it makes read-only sample calls through the Proxy API. Without one, it reads the app's docs from --source-url. It writes a local mapping file and changes nothing in Truto until you run apply.
What happens when the build is not sure how to map a field?
The build asks a question instead of guessing. In a terminal it asks at the end of the run. From a script or an agent, answer later with truto unified-mappings build --continue and --answer.
Can an agent push mappings to Truto without a person?
Only with --yes. Without a terminal, apply writes nothing and exits 3 unless you pass --yes. The safer path is apply --prepare, then apply --plan with --expect-digest after a person approves the plan.
How do I add one customer's custom field to my own unified API?
Add an integrated account override. It is a JSONata expression that runs on the same raw record as the base mapping, and Truto merges its result over the base result. It applies on the account's next call.
Does Truto retry rate-limited calls on my unified API?
No. When the app returns a 429, Truto passes it back with ratelimit headers and, when it has one, Retry-After. Your code decides when to retry.

Blog

More from our Blog

Product Updates/Engineering

Introducing the Truto CLI

Manage integrations, query unified APIs, and configure per-account schema mappings from the terminal - with pass-through data flow and no persisted response payloads.

Roopendra Talekar 20 min read

Start free today. Pay only for the calls you make.

Connections are free. 25,000 calls a month on the Free plan, no card.