---
title: "How a Coding Agent Builds Your Own Unified API on Truto, End to End"
slug: coding-agent-builds-custom-unified-api-on-truto
date: 2026-12-03
author: Roopendra Talekar
categories: [Guides, Engineering]
excerpt: "A step-by-step walkthrough with the Truto CLI and agent skills, from an empty model to live calls, per-customer overrides and rollback."
tldr: "Your coding agent creates the model with truto unified-models create, maps each integration with truto unified-mappings build, checks the file with validate, pushes it with apply, installs the model per environment and calls /unified/your-model. Truto runs the mappings, so a change needs no deploy, and History restores any earlier version."
canonical: https://truto.one/blog/coding-agent-builds-custom-unified-api-on-truto/
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://truto.one/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# 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](https://truto.one/docs/cli/unified-mappings/).

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?](https://truto.one/blog/build-your-own-unified-api-on-truto-vs-in-house/) answers it.

## What you need

- A Truto team with the [Pro add-on](https://truto.one/pricing/), 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](https://truto.one/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

```bash
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](https://truto.one/docs/getting-started/#setting-up-truto-with-a-coding-agent) and [Truto Agent Skills](https://truto.one/blog/truto-agent-skills-stop-ai-hallucinations-when-building-integrations/).

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:

```bash
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](https://truto.one/docs/guides/unified-apis/creating-unified-apis/) 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](https://truto.one/docs/guides/unified-apis/creating-unified-apis/).

## Step 3: Build the mappings for each integration

```bash
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:

```bash
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`:

```bash
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

```bash
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](https://truto.one/docs/cli/unified-mappings/#apply).

## 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:

```bash
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:

```bash
truto unified my-crm accounts -a <integrated_account_id>
```

```bash
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](https://truto.one/docs/guides/unified-apis/unified-apis-flow/) and [Rate limits](https://truto.one/docs/api-reference/overview/rate-limits/).

You can install the same model in each environment, for example development and production. See [Install a Unified API](https://truto.one/docs/guides/unified-apis/installing-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](https://truto.one/docs/guides/logs/viewing-logs/).

See [Test mapping locally](https://truto.one/docs/cli/data-plane/#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.

```bash
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](https://truto.one/docs/guides/unified-apis/override/) and [3-Level API Mapping](https://truto.one/blog/3-level-api-mapping-per-customer-data-model-overrides-without-code/).

## 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](https://truto.one/docs/guides/unified-apis/override/).

## 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](https://truto.one/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](https://truto.one/pricing/), $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](https://truto.one/pricing/).
