Build your own Unified API in the dashboard: define its resources and schema, map each method to an integration's API, then install it and call it. This guide builds a CRM Unified API with an accounts resource backed by Salesforce.
Create Unified API asks for the basic information about your new API.
Name: Use lowercase letters with hyphens (kebab-case). Example:my-crm This sets the API path to /unified/my-crm.
Calls find a Unified API by name, so pick a name no installed Unified API uses. Truto's own CRM Unified API is already called crm.
Label: A friendly name for your API. Example:My CRM API
The schema defines the structure of the response data your Unified API will handle. It drives the API reference for the resource, and Truto also uses its field types at runtime, for example to cast column types for truto_super_query reads. Unified API responses are not validated against it.
Edit Schema:
In the Resources tab, select your newly added accounts resource.
Click on the Schema tab.
Click the edit (pencil) icon to modify the schema.
Define the Schema:
Fields: Specify each piece of data your API will manage.
Types: Indicate the type of data (e.g., string, integer).
Descriptions: Provide a brief explanation for each field.
You can add the schema using the Form or in JSON.
Save the Schema:
After entering all fields, click the Save button.
Note: This is how the schema will look like in JSON
The mapping modal groups its tabs: Resource, Mapping (Query mapping, Request body mapping, Response mapping, Error mapping), Headers (Request header mapping, Response header mapping) and Advanced (Before/After Steps, Notes).
On the Resource tab, Resource and Method are the integration's resource and method this unified method calls, for example Salesforce accounts / list. They come from the integration (here, Salesforce), and they can differ from the unified method: Truto's own Salesforce crm/accountslist calls the search resource when the caller passes search_term. See Advanced mapping options.
Translates query parameters in the Unified API call into the query supported by the underlying API.
Add a query mapping to every method that accepts filters. Truto sends the provider only what the query mapping returns, plus limit, next_cursor, truto_* parameters, the method's default query, and anything the caller passes in remote_query[...] (see Querying). A filter the mapping doesn't return never reaches the provider, and the call returns unfiltered results. Path placeholders such as {{query.customer_id}} are filled from the mapped query too. Request bodies work the other way: with no request body mapping, the body is sent as received.
Go to the query mapping:
Open Mapping → Query mapping.
Query Schema (YAML):
The Query Schema specifies what should be in the Query Parameters. Since the schema is defined in Resource Schema, you can just specify the fields from the schema that will be used in the Query and required, type, description will be automatically used from the Resource Schema. The Query Schema is specified in YAML.
A create or update method needs a request body mapping to turn the caller's body into the body the provider accepts. Add a create method to accounts as in Step 3 (Salesforce accounts / create), then open Mapping → Request body mapping.
Request Body Schema (YAML): list the body fields the method accepts, keyed by field name. Mark a field required: true to make it required:
name: required: truewebsite: {}
Request Body Mapping: map the caller's body to Salesforce's fields:
{ "Name": body.name, "Website": body.website}
With the Request Body Example{ "body": { "name": "Truto", "website": "truto.one" } }, Mapped Body (Result) shows { "Name": "Truto", "Website": "truto.one" }.
How the body reaches the provider:
Callers who pass truto_enforce_write_schema=true get a 400 listing missing required fields in truto_error_insight.missing_required_body_fields before anything is sent, including before steps; see Querying. Without that parameter, required isn't enforced.
A remote_data object in the caller's body is merged over the mapped body, so a caller can send provider fields the mapping doesn't cover. A body with remote_data also skips the required-field check.
With no request body mapping, the caller's body is merged over the method's default body and sent.
Truto also evaluates the mapping once with the method's default body as its whole input, so an unguarded $error() in the mapping fails every call.
After configuring how queries and bodies are handled, define how responses from the underlying API are transformed to fit your Unified API's structure.
Open Mapping → Response mapping for the list method.
Response Schema (YAML):
This defines the structure of the data your API will return to users. This is specified in YAML and autopopulated from the Resource Schema defined above.
type: object properties: id: type: string description: The account's unique identifier required: true owner: type: object description: The account's owner properties: id: type: string description: The owner's unique identifier name: type: string description: The account's name description: type: string description: The account's description industry: type: string description: The account's industry website: type: string description: The account's website number_of_employees: type: integer description: The account's number of employees addresses: type: array items: type: object properties: id: type: string description: The unique identifier of the address street_1: type: string description: Line 1 of the street address street_2: type: string description: Line 2 of the street address city: type: string description: The city state: type: string description: The state postal_code: type: string description: The postal code country: type: string description: The country type: type: string description: The address type phone_numbers: type: array items: type: object properties: id: type: string description: The unique identifier of the phone number number: type: string description: The phone number extension: type: string description: The extension of the phone number type: type: string description: The phone number type urls: type: array items: type: object properties: url: type: string description: The account's URL type: type: string description: The account's URL type description: The account's urls tags: type: array items: type: object properties: id: type: string description: The tag's unique identifier name: type: string description: The tag's name description: The contact's tags custom_fields: type: object description: All the custom fields present on the account additionalProperties: true last_activity_at: type: string description: The date and time of the account's last activity format: date-time updated_at: type: string description: The date and time of the account's last update format: date-time created_at: type: string description: The date and time of the account's creation format: date-time
Response Example:
Provide an example raw API response from Salesforce so that you can verify your mapping. It is the expression's whole input, so the record goes under response.
Transforms the raw Salesforce response into the structure defined by your Unified API's response schema. For a list, the mapping runs once per record and response is that record. Inside response.{ … }, reach other bindings from the root, for example $$.context.subdomain; see JSONata bindings.
owner: Extracts OwnerId from Salesforce and nests it under owner.id.
addresses: Combines billing and shipping addresses into a single array, distinguishing them by type.
phone_numbers: Includes both Phone and Fax numbers with their respective types.
custom_fields: Filters and includes only custom fields from Salesforce that end with __c and have valid values.
Check the Mapped Response (Result):
This is the result of your Response Example above transformed through the Response Mapping. Use it to verify that the mapping is correct. At runtime, Truto also adds the raw record to each mapped record as remote_data.
Click Save, review the changes, and confirm. This saves the Unified API mapping for the resource.
Info
A saved change to a mapping, an environment override or a Unified API's schema can take up to about 23 minutes to reach API calls, because each connection caches them. To apply it now, call POST /integrated-account/refresh-mapping-cache; pass integration_id when you changed one integration's mapping. It answers 202, and a region can keep serving the old mapping for up to about 6 more minutes. An integrated account's own unified_model_override applies on the next call.
In the dashboard. Each mapping tab has an example and a result. The example is the expression's whole input, so it holds the bindings by name: response for a response mapping, query for a query mapping, error for an error mapping. Add query, context or before keys next to response to test a mapping that reads them:
On your machine.truto unified test-mapping evaluates a response mapping against a sample response without calling the integration, and --with-overrides adds an environment's overrides. truto jsonata eval evaluates any expression against a JSON input. See Test mapping locally and JSONata in the CLI docs.
On a live call. Add truto_response_format=debug to see the request Truto sent and the provider's raw response; see See the raw remote response. A Unified API call's log has step_results, one entry per before and after step with its type, name, duration and whether it succeeded, was skipped or failed. Add truto_debug=true to the call to also record each step's resolved config.
Sometimes an endpoint always returns the same data, such as a fixed list of options. Static mapping returns a response you configure in the Unified API, without calling the provider.
Static mapping applies to list and get only; create, update and delete always call the provider. Truto returns the value you enter as result, as is: no response mapping, remote_data or before and after steps.
The error mapping returns an object with these keys:
message: The error message the caller receives.
metadata: Optional additional details about the error, such as the provider's own error code.
status: Optional HTTP status code for the caller, for example 422. If you return a status below 400, the Unified API treats the call as a success and returns that status with response as the result.
response: Optional. The result to return when status is below 400.
Callers never see the mapping's object itself. The mapping's status becomes the HTTP status and statusCode, and the body has Truto's error shape. For the example, the caller receives HTTP 422 with a body like this (other fields from the Errors page left out):
A status below 400 turns the call into a success that returns response. Related resources and the response mapping are skipped; after steps still run.
error is the provider's error body, as JSON or text. For integrations that declare an error expression, it is { "data": …, "headers": … } instead. The HTTP status code is not a binding.
The mapping doesn't run when the provider's error has an empty body, or when a before step fails.
You can define how your Unified API injects or transforms headers before sending them to the underlying API. The headers binding holds the headers Truto has prepared for that request; of the headers sent to the Unified API, only content-type is carried over, and only on writes, so custom headers on the Unified API call are not available here. Use context, query or body to source values instead.
The object you return is merged over the headers returned by the underlying API, and all header names are lowercased. Use it to add or overwrite headers; headers you leave out are still returned.
resource and method can be a list of selectors instead of a single name. Each selector names a resource (for method, the value key is method) and an optional condition: query_param (with an optional query_param_value) or body_field (with an optional body_field_value). Without a value, the condition matches when the parameter or field has a non-empty value; an empty string, 0 or false doesn't match. The first selector that matches wins, a selector with no condition always matches, and when none matches the call fails before anything is sent.
Truto's Salesforce crm/accountslist uses a list like this (shortened):
resource or method can also be an object with a JSONata expression and the allowed values in resources (or methods for method). The expression reads query, rawQuery, body and context, and must return one of the listed values.
related_resources calls other resources of the integration and attaches their results to the raw records before the response mapping runs. Use it when a resource needs data from a parent or child resource.
Response mapping method, under the response mapping, decides how a list mapping runs. Item, the default, runs the expression once per record. Array runs it once over the whole list.
Before steps are actions that run before the main request is made by the Unified API. Use them to fetch extra data, fill in missing fields, or add logic for specific conditions. Open Advanced → Before/After Steps to add them.
In form mode, ID, Query parameters and Request Body accept {{…}} placeholders over data, query, id, body, context and step, for example {{query.interview_id}}. It is text substitution, not JSONata.
For Request typeunified, the resource is a resource of the same Unified API. For proxy, it is a resource of the integration. The method can be any method, including custom ones.
A unified request starts with an empty query, and reuses the caller's body unless the step sets a body.
Delay (ms) waits that many milliseconds before the step runs.
A failing step fails the whole call with the step's error, and the method's error mapping doesn't run. A step skipped by Run If (JSONata) is recorded, not an error.
Step names become keys in step, so a name with spaces, such as Fetch Interview Details, needs backticks (step.`Fetch Interview Details` ). Use a short name such as interview.
For example, a form-mode request step with Resource to fetchinterviews, Method to callget and ID{{query.interview_id}} fetches the interview the caller named.
Use this step to call another Unified API resource and fetch additional data before the Unified API call.
When to use it:
If your request requires data from another resource, like fetching interview details before querying candidates.
Setup:
Name: Enter a name for the step.
Example: interview
Run it conditionally: Enable this to only run the step when needed.
Run If (JSONata): Add a JSONata expression to decide whether the step should run.
Example:
$exists(query.interview_id)
This step will run only if interview_id exists in the query.
Delay (ms): Optional. Wait this many milliseconds before the step runs.
JSONata expression: Enable this to specify a JSONata expression for the request.
You should specify the following attributes in the JSONata expression :
resource - The name of the resource to call
method - The method to call: get, list, create, update, delete, or a custom method
type - The type of the request, unified or proxy. Defaults to unified.
config - An object with the id, query and body to send with the request.
Return an array of these objects to make several requests in parallel. With two or more requests the step result is an array of their results, in the same order; an array with one request returns that request's result on its own.
Use this to compute new data with a JSONata expression. The result replaces the data passed to the next step.
Setup:
Name: Enter a name for the step.
Example: default_priority
Run it conditionally: Enable this to only run the step when needed.
Run If (JSONata): Provide a JSONata expression that returns true or false to determine whether the step should run.
Example:
$not($exists(query.priority))
This step will run only if the priority field is missing.
JSONata Expression: The expression whose result becomes the step's data. It receives data (the data so far; before steps start with an empty object), query, body and id from the request, context (the integrated account's context), and step (the result of each earlier step, by name). The result is passed to the next step and stored under this step's name, so a later Replace data step can use it. When the before steps finish, the mappings read the data as before.
Example:
After steps are actions that run after the main request is made by the Unified API. Use them to add data to the response, fill in missing fields, or add logic for specific conditions before the data is returned to the caller. They behave like request steps in before steps.
Use this step to call another Unified API resource and fetch additional data after the Unified API call.
When to use it:
For example, if the underlying API returns only the id of a record after an update, an after step can call get to fetch the full record and return it to the caller.
Setup:
Name: Enter a name for the step.
Example: interview
Run it conditionally: Enable this to only run the step when needed.
Run If (JSONata): Add a JSONata expression to decide whether the step should run.
Delay (ms): Optional. Wait this many milliseconds before the step runs.
JSONata expression: Enable this to specify a JSONata expression for the request.
You should specify the following attributes in the JSONata expression :
resource - The name of the resource to call
method - The method to call: get, list, create, update, delete, or a custom method
type - The type of the request, unified or proxy. Defaults to unified.
config - An object with the id, query and body to send with the request.
Return an array of these objects to make several requests in parallel. With two or more requests the step result is an array of their results, in the same order; an array with one request returns that request's result on its own.
Use this to compute new data with a JSONata expression. The result replaces the data passed to the next step, and the data left after the last step is the Unified API response.
Setup:
Name: Enter a name for the step.
Example: active_only
Run it conditionally: Enable this to only run the step when needed.
Run If (JSONata): Provide a JSONata expression that returns true or false to determine whether the step should run.
Example:
$not($exists(query.priority))
This step will run only if the priority field is missing.
JSONata Expression: The expression whose result becomes the step's data. It receives data (the data so far; after steps start with the Unified API response), query, body and id from the request, context (the integrated account's context), and step (the result of each earlier step, by name). The result is passed to the next step and stored under this step's name. When the after steps finish, the data is the Unified API response.
Example:
The Advanced → Notes tab is where the Truto team writes down details, limitations and pitfalls specific to this resource. You can add your own notes here too.
Key Characteristics:
Describe what makes this resource unique or any quirks it might have. This helps set expectations and provides context.
Usage Tips:
Share simple tips and best practices on how to use this resource effectively. For example, mention common pitfalls or suggest smoother ways to handle certain tasks.
Limitations:
Point out any known limitations or constraints. If the underlying API has restrictions that affect this resource, note them here in plain language.
Troubleshooting Advice:
Offer friendly guidance on what to do if things don't work as expected. This can include hints on where to look for errors or how to fix common issues.
Reminders and Warnings:
Add any reminders or gentle warnings that can help users avoid mistakes or understand important considerations when interacting with the resource.
General Observations:
Write down observations or thoughts that might be useful for anyone working with or maintaining this resource in the future.
Install a Unified API covers installing into more environments and uninstalling. To change a mapping for one environment or one integrated account without editing the Unified API itself, see Overriding Unified API mappings.
Navigation
Cookies
Cookie Settings
We use cookies and similar technologies to analyze site traffic, understand where our visitors come from, and improve your browsing experience. Read our Cookie Policy.
Customize
Your preferences
Choose which categories of cookies you allow. You can change this anytime.
Strictly necessaryAlways on
Required for the site to function. Cannot be disabled.
Analytics & marketing
Helps us understand traffic and improve the product (Google Tag Manager).