Skip to content

This page traces one Unified API request, a Salesforce crm/accounts list call, through every step Truto runs, from the account checks to the response.

Skip the reading — fast path for coding agents
CLI
truto unified crm accounts -a <integrated_account_id> -q name=Truto
Skill
View truto skill on GitHub Cursor / Claude Code: /skill truto

Unified API request flow

  1. Unified API Request
    • What Happens Here?
      The process starts when your application calls a Unified API endpoint for an integrated account. For example:
      • Request: GET /unified/crm/accounts?integrated_account_id=<integrated_account_id>&name=Truto&city=Bangalore

  1. Check the integrated account
    • What Happens Here?
      Before anything else runs, Truto refuses a call for an integrated account that is paused as stale with 401 and truto_error_code: integrated_account_needs_reauth, and a call for a blocked account with 503. A call to a Unified API that isn't installed in the account's environment returns 404.

  1. Is it a list or get call with static mapping?
    • What Does This Mean?
      Checks if the Unified API call is a list or get call. If it is, and Static Mapping is enabled, the API call isn't made and the Static Response configured is returned.

  1. Check the request body
    • What Happens Here?
      On a create, update or custom method call with truto_enforce_write_schema=true, Truto checks the body against the method's request body schema. If a required field is missing, the call returns 400 and nothing else runs. See Unified API parameters.

  1. Are before steps configured?
    • What Does This Mean?
      Checks if there are any "before steps" configured for preprocessing the request. These steps are optional but can enhance or validate the request or fetch additional data which will be used in the Unified API call.

  1. Run before steps (if configured)
    • What Happens Here?
      If before steps exist, they are executed.

  1. Request Query Mapping
    • What Happens Here?
      Maps or converts query parameters to match the requirements of the API (e.g., Salesforce).
    • Example:
      • Unified API Query:
        {
          "name": "Truto",
          "city": "Bangalore"
        }
      • Mapped Query for Salesforce (Truto's Salesforce mapping selects more fields; the list is shortened here):
        {
          "q": "SELECT Id, Name, BillingCity FROM Account WHERE Name LIKE '%Truto%' AND BillingCity LIKE '%Bangalore%'"
        }

  1. Pick the integration resource and method
    • What Happens Here?
      Truto works out which of the integration's resources and methods to call from the mapping's Resource and Method. A mapping can pick them per call, from a query parameter, a body field or a JSONata expression. Truto's Salesforce crm/accounts mapping calls the search resource when the request has search_term, and the accounts resource otherwise, as in this example. See Advanced mapping options.

  1. Request Body Mapping
    • What Happens Here?
      Adjusts or transforms the request body before sending it to the API. If the caller's body has a remote_data object, Truto merges it over the mapped body, so a caller can send provider fields the mapping doesn't cover.
    • Example:
      • Unified API Body:
        {
          "name": "Acme Business",
          "website": "www.acme.example"
        }
      • Salesforce Mapped Body:
        {
          "Name": "Acme Business",
          "Website": "www.acme.example"
        }

  1. Request Headers Mapping
    • What Happens Here?
      Ensures required headers are included and formatted correctly.

  1. Request Path Mapping
    • What Happens Here?
      Maps the API path from the Unified API to the provider API’s endpoint.

  1. Does the query have truto_skip_api_call set to true?
    • What Happens Here?
      Checks if the request includes a flag to skip the actual API call. When it is set, Truto calls neither the provider API nor any related resources, and runs the response mapping on an empty response (response is an empty string). The response mapping decides what is returned, for example a result built from context.before, query or context.
    • Example:
      • Input: GET /unified/crm/accounts?integrated_account_id=<integrated_account_id>&truto_skip_api_call=true.
      • Output: Skips the Salesforce API call and related resources; the response mapping runs with an empty response.

  1. Call the Proxy API configured in the resource and method
    • What Happens Here?
      Sends the actual request to the provider API (e.g., Salesforce).
    • Example:
      • Translates:
        • Unified API: GET /unified/crm/accounts.
        • API: GET /services/data/v57.0/query, with the mapped query as its q parameter.

  1. Is there an error?
    • What Happens Here?
      Checks if the API returned an error (e.g., 404 Not Found or 500 Internal Server Error).

  1. Error Mapping (if there's an error)
    • What Happens Here?
      Converts errors into a standardized format.
    • Example:
      • Salesforce Error:
        {
          "errorCode": "INVALID_FIELD",
          "message": "The field 'xyz' is not valid"
        }
      • What the error mapping returns:
        {
          "status": 400,
          "message": "Invalid request. The field 'xyz' is not supported."
        }

  1. Return the error (if there's an error)
    • What Happens Here?
      If the error mapping returned a status of 400 or more, Truto returns the error. A lower status returns response as a success. The caller gets the mapped status as the HTTP status and as statusCode, with the mapped message, in Truto's error shape.

  1. Fetch Related Resources
    • What Happens Here?
      If the mapping has related resources, Truto calls other resources of the integration and attaches their results to the raw records before the response mapping runs. Usually this is used when the resource being fetched has parent-child relationship with another resource. For example, in Asana, workspace_id is needed to get the projects of that Workspace. See Advanced mapping options.

  1. Response Mapping
    • What Happens Here?
      Converts the provider response into the Unified API’s format. For a list call, the mapping runs once per record, and Truto adds the raw record to each mapped record as remote_data.
    • Example:
      • Salesforce Response:
        {
          "Id": "0012w000024KwDeAAK",
          "Name": "Truto",
          "BillingCity": "Bangalore"
        }
      • Unified API Response:
        {
          "id": "0012w000024KwDeAAK",
          "name": "Truto",
          "city": "Bangalore"
        }

  1. Response Header Mapping
    • What Happens Here?
      Adds or modifies response headers for the Unified API. Truto sets the ratelimit-limit, ratelimit-remaining and ratelimit-reset headers itself, from the integration's rate-limit settings, so a mapping doesn't need to (see Rate limits).
    • Example:
      • Copies Salesforce's API usage header to a header of your own:
        {
          "sforce-limit-info": "api-usage=25/15000",
          "x-api-usage": "api-usage=25/15000"
        }

  1. Are after steps configured?
    • What Happens Here?
      Checks if any "after steps" are configured for postprocessing the response.

  1. Run after steps (if configured)
    • What Happens Here?
      Runs the configured after steps in order: request steps that call another Unified or Proxy API, state steps that compute a value with JSONata, and replace_data steps that set the data to an earlier step's result.
    • Example: After an update that returns only the record id, a request step calls get to fetch the full record.

  1. Set result of after steps as Response
    • What Happens Here?
      Updates the response with the output from the after steps (if any).

  1. Return the Response
    • What Happens Here?
      Sends the final, processed response back to the user. A list call returns the records in result, with next_cursor for the next page.
    • Example Final Response:
      {
        "result": [
          {
            "id": "0012w000024KwDeAAK",
            "name": "Truto",
            "city": "Bangalore",
            "remote_data": {
              "Id": "0012w000024KwDeAAK",
              "Name": "Truto",
              "BillingCity": "Bangalore"
            }
          }
        ],
        "next_cursor": null,
        "result_count": 1
      }

Next

Creating Unified APIs shows how to configure each mapping and step on this page. Send the example request yourself:

curl "https://api.truto.one/unified/crm/accounts?integrated_account_id=<integrated_account_id>&name=Truto&city=Bangalore" \
  -H 'Authorization: Bearer <API token>'
truto unified crm accounts -a <integrated_account_id> -q name=Truto -q city=Bangalore