---
title: "Connect Unleashed to AI Agents: Sync Products, BOMs and Purchases"
slug: connect-unleashed-to-ai-agents-sync-products-boms-and-purchases
date: 2026-10-19
author: Nachi Raman
categories: ["AI & Agents"]
excerpt: "Learn how to connect Unleashed to AI Agents using Truto's /tools endpoint. Build autonomous workflows for inventory, assemblies, and purchasing."
tldr: "Connect Unleashed to AI frameworks like LangChain and CrewAI using Truto. This guide covers bypassing Unleashed API quirks, handling rate limits, and orchestrating multi-step supply chain workflows."
canonical: https://truto.one/blog/connect-unleashed-to-ai-agents-sync-products-boms-and-purchases/
---

# Connect Unleashed to AI Agents: Sync Products, BOMs and Purchases


You want to connect Unleashed to an AI agent so your system can independently monitor stock levels, assemble bill of materials (BOM), and dispatch purchase orders based on historical sales context. Here is exactly how to do it using Truto's `/tools` endpoint and SDK, bypassing the need to build a custom Unleashed integration from scratch.

Giving a Large Language Model (LLM) read and write access to your inventory management system is an engineering headache. You either spend sprints mapping complex inventory relationships, dealing with legacy date formats, and maintaining auth tokens, or you use an infrastructure layer that handles the boilerplate. If your team uses ChatGPT, check out our guide on [connecting Unleashed to ChatGPT](https://truto.one/connect-unleashed-to-chatgpt-manage-stock-orders-and-assemblies/), or if you are building on Anthropic's models, read our guide on [connecting Unleashed to Claude](https://truto.one/connect-unleashed-to-claude-handle-sales-shipments-and-returns/). For developers building custom autonomous workflows, you need a programmatic way to fetch these tools and bind them to your agent framework.

This guide breaks down exactly how to fetch AI-ready tools for Unleashed, bind them natively to an LLM using frameworks like LangChain, LangGraph, CrewAI, or the Vercel AI SDK, and execute complex supply chain operations. For a deeper look at the architecture behind this approach, refer to our research on [architecting AI agents and the SaaS integration bottleneck](https://truto.one/architecting-ai-agents-langgraph-langchain-and-the-saas-integration-bottleneck/).

## The Engineering Reality of the Unleashed API

Giving an LLM access to an inventory management API sounds simple in a prototype. You write a Node.js function that makes a fetch request and wrap it in an `@tool` decorator. In production against a strict ERP or inventory system like Unleashed, this approach collapses. 

If you hardcode these interactions into your agent, you will spend your sprints writing defensive integration code instead of improving your model's reasoning. Unleashed introduces several specific integration challenges that break standard LLM assumptions.

### The Legacy Date Format Trap

LLMs default to standard ISO 8601 date strings (`2026-05-14`). When fetching records from Unleashed, the API responds with legacy Microsoft WCF/OData date strings formatted like `/Date(1620000000000)/`. 

If an agent reads a record, makes a change, and sends the exact same date format back in a `PUT` request, Unleashed will reject it. The API demands ISO format (`YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SS`) on input, despite returning epoch strings on output. Custom tool layers must enforce schema boundaries that force the LLM to output clean ISO strings, shielding the upstream API from invalid dates.

### Strict Financial Integrity Constraints

When an LLM generates a purchase order or a sales order, it cannot approximate numbers. Unleashed enforces strict double-entry accounting rules on its API layer. If an agent calls the endpoint to create a purchase order, the `Currency` must perfectly match the supplier's default currency, and there must be an active exchange rate logged on the Currency Rates settings page.

Furthermore, the `TaxCode`, `TaxRate`, `SubTotal`, `TaxTotal`, and `Total` must calculate flawlessly. If the sum of the `LineTaxCode` fields on the `PurchaseOrderLines` array diverges from the master `TaxTotal` by a single cent, the API throws a 400 Bad Request. LLMs are notoriously bad at arbitrary math, meaning your tool descriptions must mandate that the agent utilizes a calculator tool or strictly validates totals before submission.

### State-Dependent Transitions and Ghost Deletions

Inventory systems are highly stateful. You cannot delete an assembly that is marked `Completed`; you can only delete `Parked` assemblies. If an agent tries to mark a product as obsolete, the API will reject it if there is any stock on hand across any warehouse.

Unleashed also has unique endpoint quirks. For example, if you command the API to delete a customer contact, the API successfully deletes the contact but frequently returns an HTTP 500 internal server error stating: `The only supported IsolationLevel is IsolationLevel.Serializable`. If your agent interprets the 500 error as a failure and attempts to retry, it will enter an infinite loop trying to delete a contact that no longer exists.

## Why a Unified Tool Layer Matters for Agent Safety

Before writing a line of integration code, decide what layer your agent talks to. Truto resolves the integration bottleneck through two primary levels of abstraction: [Proxy APIs and Unified APIs](https://truto.one/best-unified-api-for-llm-function-calling-ai-agent-tools-2026/).

Every integration on Truto maps to a comprehensive JSON object that represents how the underlying product's API behaves. Integrations have `Resources` mapping to endpoints, and `Methods` defined on those resources (e.g., standard CRUD operations like List, Get, Create, Update, Delete).

These methods are provided as Proxy APIs. Truto handles all the messy authentication, OAuth lifecycle management, and query parameter processing. Unified APIs are built on top of Proxy APIs, transforming data to normalize structures across an entire software category. 

However, when solving problems agentically, Proxy APIs are highly effective. The agent is intelligent enough to handle the raw data from the underlying product's API, provided the schema is clean. Truto takes the descriptions and schemas for all methods on an integration and generates tools via the `/tools` endpoint. 

This gives you concrete safety wins:
1. **Deterministic input validation.** Every tool has a strict JSON schema. If the agent invents a parameter for a purchase order, the schema validation rejects it before it hits the Unleashed API.
2. **Reduced attack surface.** The LLM only sees the stable function names provided by the `/tools` endpoint, preventing it from hallucinating direct HTTP calls.

## Building Multi-Step Workflows

An AI agent managing an Unleashed instance rarely executes a single command. It needs to read stock levels, query suppliers, generate an order, and verify the result. This requires fetching tools dynamically and binding them to the agent.

### Fetching Tools and Binding to LangChain

Truto provides a seamless way to load these operations. Below is a framework-agnostic pattern shown using TypeScript and the Truto Langchain.js SDK.

```typescript
import { ChatOpenAI } from "@langchain/openai";
import { TrutoToolManager } from "truto-langchainjs-toolset";
import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";

async function runUnleashedAgent() {
  // 1. Initialize the LLM
  const llm = new ChatOpenAI({
    modelName: "gpt-4o",
    temperature: 0,
  });

  // 2. Fetch the Unleashed Proxy API tools via Truto
  const toolManager = new TrutoToolManager({
    trutoApiKey: process.env.TRUTO_API_KEY,
    integratedAccountId: "your_unleashed_account_id"
  });

  // Filter for specific methods to reduce context window bloat
  const tools = await toolManager.getTools({ 
    methods: ["read", "write", "custom"] 
  });

  // 3. Create the agent prompt
  const prompt = ChatPromptTemplate.fromMessages([
    ["system", "You are a supply chain assistant. You manage Unleashed inventory. Always format dates as YYYY-MM-DD. Ensure all purchase order totals exactly match the sum of their lines. If a request is rate limited, wait and retry."],
    ["human", "{input}"],
    ["placeholder", "{agent_scratchpad}"],
  ]);

  // 4. Bind and execute
  const agent = createToolCallingAgent({
    llm,
    tools,
    prompt,
  });

  const executor = new AgentExecutor({
    agent,
    tools,
    maxIterations: 10,
  });

  const result = await executor.invoke({
    input: "Check the stock on hand for product code 'WIDGET-A' across all warehouses. If available quantity is below 50, create a purchase order for 100 more from supplier 'SUP-001'.",
  });

  console.log(result.output);
}
```

### The Reality of Rate Limits

When your agent chains multiple reads and writes, it will inevitably [hit API rate limits](https://truto.one/best-practices-for-handling-api-rate-limits-and-retries-across-multiple-third-party-apis/). 

**A factual note on rate limits:** Truto does *not* automatically retry, throttle, or apply backoff on rate limit errors. When the upstream Unleashed API returns an HTTP 429 (Too Many Requests), Truto passes that exact error back to the caller. Truto normalizes the upstream rate limit information into standardized IETF headers (`ratelimit-limit`, `ratelimit-remaining`, `ratelimit-reset`). 

The caller (your agent framework) is fully responsible for reading the `ratelimit-reset` header, [initiating a backoff, and retrying](https://truto.one/best-practices-for-handling-api-rate-limits-and-retries-across-multiple-third-party-apis/). This is an architectural advantage: it prevents hidden latency spikes in proxy layers and gives your agent explicit control over execution timing.

```mermaid
sequenceDiagram
    participant Agent as AI Agent
    participant Truto as Truto Proxy API
    participant Unleashed as Unleashed API

    Agent->>Truto: Call list_all_unleashed_stock_on_hands
    Truto->>Unleashed: GET /StockOnHand
    alt Rate Limit Exceeded
        Unleashed-->>Truto: HTTP 429 Too Many Requests
        Truto-->>Agent: Error 429 + ratelimit-reset header
        Note over Agent: Agent parses header,<br>pauses execution
        Agent->>Agent: Wait (e.g., 60 seconds)
        Agent->>Truto: Retry list_all_unleashed_stock_on_hands
        Truto->>Unleashed: GET /StockOnHand
        Unleashed-->>Truto: HTTP 200 OK
        Truto-->>Agent: JSON Response
    else Success
        Unleashed-->>Truto: HTTP 200 OK
        Truto-->>Agent: JSON Response
    end
```

## Hero Tools for Unleashed AI Agents Integration

Instead of dumping fifty endpoints into the LLM context, restrict the agent to high-leverage operations. Here are the hero tools available for Unleashed via Truto.

### List All Unleashed Products
`list_all_unleashed_products`

Retrieves the core product catalog. The agent uses this to find the unique `Guid`, default prices, and unit of measure required for building orders or assemblies.

> "Fetch the full product catalog and find the Guid and DefaultPurchasePrice for the product code 'COFFEE-BEANS-1KG'."

### Get Stock On Hand Across All Warehouses
`list_all_unleashed_all_warehouses`

Retrieves the stock on hand for a specific product across every warehouse. The agent requires the `product_guid` to execute this. Crucial for triggering replenishment workflows.

> "Check the available quantity for product Guid 'abc-123-def' across all warehouses. Tell me which warehouse holds the most stock."

### Create a Purchase Order
`create_a_unleashed_purchase_order`

Generates a new purchase order for a supplier. The agent must strictly validate that the `Currency` matches the supplier, calculate the `Total`, and ensure dates are sent as ISO strings.

> "Create a purchase order for supplier 'SUP-05' for 50 units of product 'WIDGET-A' at $10 each. Calculate the subtotal and total accurately. Set the delivery date to next Friday formatted as YYYY-MM-DD."

### Create an Assembly
`create_a_unleashed_assembly`

Triggers a manufacturing run based on a Bill of Materials. The agent supplies `AssemblyLines` denoting the components consumed to create the finished product.

> "Create a new assembly run for product 'PREMIUM-BIKE'. Add assembly lines for 1 frame and 2 wheels. Mark the assembly status as 'Parked'."

### List Sales Orders
`list_all_unleashed_sales_orders`

Fetches outbound sales data. The agent can filter by customer, warehouse, status, or date to determine fulfillment priorities or calculate required stock.

> "List all sales orders created in the last 7 days that currently have the status 'Placed'. Summarize the total revenue from these orders."

### Create a Supplier Return
`create_a_unleashed_supplier_return`

Initiates reverse logistics by referencing an existing Purchase Order. The agent must provide the `PurchaseOrder` data to tie the return to historical costs.

> "Create a supplier return for purchase order 'PO-00123' returning 5 damaged units of product 'WIDGET-A'. Provide a reason in the return lines."

For the complete tool inventory and granular JSON schema details, visit the [Unleashed integration page](https://truto.one/integrations/detail/unleashed).

## Workflows in Action

When these tools are chained together via an autonomous loop, the agent transforms from a chatbot into a digital supply chain operator.

### Scenario 1: Autonomous Stock Replenishment
**Persona:** Procurement Manager

> "Review our current stock for all products in the 'Electronics' group. If any product has an available quantity below 20, find its default supplier and generate a parked purchase order to bring the stock back up to 100 units."

**Execution Steps:**
1. The agent calls `list_all_unleashed_product_groups` to find the Guid for 'Electronics'.
2. It calls `list_all_unleashed_products` filtering by the group Guid.
3. For each product, it calls `list_all_unleashed_all_warehouses` to sum the available stock.
4. Identifying a shortage, it calls `get_single_unleashed_product_by_id` to retrieve the default supplier Guid and cost.
5. It calls `get_single_unleashed_supplier_by_id` to confirm the supplier's currency and tax settings.
6. Finally, it executes `create_a_unleashed_purchase_order`, meticulously calculating the line totals, and returns a confirmation to the user with the new PO number.

### Scenario 2: Just-In-Time Assembly Orchestration
**Persona:** Production Planner

> "Look at all Placed sales orders from today containing 'Custom Gift Basket'. Check if we have enough stock. If we don't, create an assembly to build the exact shortfall using the required components."

**Execution Steps:**
1. The agent calls `list_all_unleashed_sales_orders` filtering for today's date and 'Placed' status.
2. It parses the `SalesOrderLines` to count the required volume of 'Custom Gift Basket'.
3. It calls `get_single_unleashed_stock_on_hand_by_id` for the basket product. 
4. Realizing there is a deficit of 15 baskets, the agent calls `get_single_unleashed_bill_of_material_by_id` to find the recipe for the basket.
5. It calculates the required components (e.g., 15 boxes, 45 chocolates) and executes `create_a_unleashed_assembly` with the calculated `AssemblyLines`.
6. It informs the planner that the assembly is parked and ready for completion on the warehouse floor.

## Moving Supply Chains to Agentic Operations

Connecting Unleashed to AI agents fundamentally changes how revenue operations and supply chain management function. Instead of humans exporting CSVs to calculate shortfalls, an agent orchestrates the entire workflow in real time.

By leveraging Truto's `/tools` endpoint, you bypass the friction of normalizing legacy date formats, writing custom OAuth flows, and manually mapping fifty complex ERP schemas. You give your agent clean, standardized Proxy APIs, allowing your engineering team to focus on prompt architecture and framework logic rather than integration maintenance.

> Ready to give your AI agents secure, read-and-write access to Unleashed and 100+ other SaaS platforms? Get a demo of Truto's auto-generated tools and Unified APIs.
>
> [Talk to us](https://truto.one/book-a-demo/)
