For developers

Connect Custom AI Agents to QuickBooks with an API Key

Build a QuickBooks AI agent on DeepLedger's hosted MCP server: create an API key, connect from Node.js, pick the company and run a first report.

Published by DeepLedgerUpdated 11 min read

A custom QuickBooks AI agent connects to QuickBooks Online through DeepLedger's hosted MCP server, using a DeepLedger API key sent as a bearer token. You connect the company in DeepLedger once, create a key under Settings → API keys, and point your agent's MCP client at https://mcp.deepledger.ai/mcp. This guide is for developers and finance teams building their own accounting AI agent; it includes a working Node.js test and the rules your agent needs to follow before it writes.

Connection settingValue
Server URLhttps://mcp.deepledger.ai/mcp
TransportStreamable HTTP
Authentication headerAuthorization
Header valueBearer <your DeepLedger API key>

If you use a framework, the LangChain and LangGraph guide and the CrewAI guide show the framework-specific configuration. The example below uses the MCP SDK directly, so you can reuse the connection inside any agent loop. Chat apps such as Claude or ChatGPT don't need a key: they sign in with OAuth.

What are you connecting?

Two separate authorizations sit behind every QuickBooks AI agent:

  1. QuickBooks Online to DeepLedger. An admin connects the company once through Intuit's own sign-in. DeepLedger holds that connection.
  2. Your agent to DeepLedger. Your process sends a DeepLedger API key to the QuickBooks MCP server over HTTPS and gets accounting tools back.

Your agent never sees an Intuit token. The DeepLedger key is different from an Intuit access token and from your model provider's API key.

The tools cover QuickBooks work (qbBill, qbInvoice, qbExpense, qbJournalEntry, qbReports, qbFetchTransactions and more) and DeepLedger's platform: bankFeed, documents, tasks, agentMemory for the company's AI Brain, skills for Company Skills, and closeRun and reconciliation for month-end close. The same address, https://mcp.deepledger.ai/mcp, serves Xero and Stripe (read only, for reporting) for companies that connect them; see the Xero MCP guide.

It also serves BILL for companies that connect it with your own BILL credentials.

Before you start

  • A DeepLedger account with access to the intended QuickBooks Online company.
  • Node.js 22 or newer for the test script.
  • A demo or sandbox company for the first runs. Don't send private client reports to a model provider your organization hasn't approved.

How do I connect a custom AI agent to QuickBooks?

Step 1: Connect the QuickBooks company

  1. In DeepLedger, open Companies, select the company and open its Connections tab.
  2. Choose Connect to QuickBooks and complete Intuit's sign-in.

You do not need a separate Intuit developer app for this hosted setup.

Step 2: Create a DeepLedger API key

Any team member can create a key for themselves.

  1. Open Settings → API keys and choose Create key.
  2. Enter a Name that says which agent uses it, such as "AP agent, staging".
  3. Pick an Expiration: 30 days, 90 days, 1 year or Never.
  4. Under Companies, choose All my companies (the default) or One company.
  5. Copy the key. It starts with dl_live_ and is shown once.

A DeepLedger API key acts as the person who created it, with that person's access. It never reaches a company that person can't open. A One company key works only in that company and can't switch. There is no separate read-only switch on a key. You revoke a key on the same page; owners and admins can see and revoke every key in the firm.

Step 3: Store the key in an environment variable

Put the key in an environment variable or your runtime's secret manager, never in source code. For the local example, use a .env file that is listed in .gitignore:

DEEPLEDGER_API_KEY=dl_live_...

Keep the key out of browser code, prompts and logs. The secret belongs to the process that makes the MCP request, not to the model's conversation.

Step 4: Test the connection with Node.js

Install the SDK version this example was written against:

npm init -y
npm install @modelcontextprotocol/sdk@1.30.0 zod@4

The imports follow the MCP TypeScript SDK's v1 client API. Its Streamable HTTP transport accepts custom headers through requestInit. Save this as connect-deepledger.mjs:

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

const apiKey = process.env.DEEPLEDGER_API_KEY;
if (!apiKey) throw new Error("Set DEEPLEDGER_API_KEY before running.");

const client = new Client({ name: "custom-bookkeeping-agent", version: "1.0.0" });
const transport = new StreamableHTTPClientTransport(
  new URL("https://mcp.deepledger.ai/mcp"),
  { requestInit: { headers: { Authorization: `Bearer ${apiKey}` } } },
);

try {
  await client.connect(transport);

  const tools = [];
  let cursor;
  do {
    const page = await client.listTools(cursor ? { cursor } : {});
    tools.push(...page.tools);
    cursor = page.nextCursor;
  } while (cursor);

  if (!tools.some((tool) => tool.name === "qbCompanyProfile")) {
    throw new Error("The company-profile tool was not returned.");
  }

  const result = await client.callTool({
    name: "qbCompanyProfile",
    arguments: { operation: "current" },
  });
  if (result.isError) {
    throw new Error("Company check failed. Review the connection and active company.");
  }

  const text = result.content.find((item) => item.type === "text");
  const profile = result.structuredContent ?? JSON.parse(text?.text ?? "{}");
  if (profile.success !== true) {
    throw new Error(
      `${profile.errorCode ?? "PROFILE_FAILED"}: ${profile.message ?? "Check your active company and QuickBooks connection."}`,
    );
  }

  console.log(JSON.stringify(profile, null, 2));
} finally {
  await client.close();
}

Run the script with the key in the environment and check that it prints the company you expected.

node --env-file=.env connect-deepledger.mjs

The script discovers the tools and reads the active company's profile. It does not ask a model to decide anything and does not change QuickBooks. The output contains company information, so keep it private.

Step 5: Wire the tools into your agent loop

An MCP connection alone is not an agent loop. Your host application connects the model's tool requests to MCP:

  1. Discover the tools with listTools(). Each tool has a name, a description and an inputSchema.
  2. Give your model only the tools needed for its current task. For a first reporting agent, start with qbCompanyProfile and qbReports.
  3. Validate the tool name and arguments the model asks for, then dispatch with client.callTool({ name, arguments }).
  4. Return the tool result to the model in your provider's tool-result format. Keep errors: a failed call is not an empty report.
  5. Close the client when the run finishes.

The MCP client concepts page explains the split between the host application and its MCP client.

Which credential should your agent use?

CredentialReachesCompany switchingBest for
API key, All my companiesEvery company the creator can accessYes, with qbCompanyProfileOne agent that works across clients, one job at a time
API key, One companyOne companyNoAn agent dedicated to one client's books
OAuth sign-inEvery company the person can accessYesClaude, ChatGPT, Cursor and other interactive apps

Every option acts as a real person. DeepLedger has no shared or system key for custom agents.

How does the agent pick the right QuickBooks company?

With an All my companies key, call qbCompanyProfile with operation: "list", choose the organizationId from the result, then call it with operation: "switch" and that ID. Read the profile again to confirm.

A switch moves the person's active company across all their connected AI clients. Two jobs using keys from the same person share that one active company. For parallel jobs, use a One company key per job, or send an X-Organization-Id header with the company's ID on every request; DeepLedger checks it against the person's access. The multiple-company guide covers the details.

Every write must carry the company it is meant for (companyId). If companyId is missing or differs from the active company, DeepLedger refuses the call with COMPANY_REQUIRED or COMPANY_MISMATCH and nothing is written. Reads and switching are not affected. Treat either error as a stop: have the agent confirm the company, not retry with a guess.

What can an AI agent for bookkeeping do in QuickBooks?

JobTools
Check the company and its settingsqbCompanyProfile
Run P&L, balance sheet, aging, general ledgerqbReports, customReports
Look up transactions, vendors, customers, accountsqbFetchTransactions, qbMasterData
Record bills, expenses, invoices, deposits, journal entriesqbBill, qbExpense, qbInvoice, qbDeposit, qbJournalEntry
Follow the client's rulesagentMemory (AI Brain), skills
Hand uncertain work to a persontasks
Prepare month-end close and reconciliationscloseRun, closeTemplate, reconciliation

DeepLedger works when you ask: the agent acts only when your code calls a tool. It does not read the AI Brain automatically. Tell it to, for example: "Read the company's AI Brain and skills, then code last week's bank transactions." A capitalisation rule such as "capitalise equipment over $2,500" then shapes the entries it proposes.

Is it safe to give an accounting AI agent write access?

Only with review built in. DeepLedger supplies these guardrails:

  • Deletes need confirmation, and a delete of a posted transaction is refused on or before the company's closing date.
  • Voids need confirmation and keep the record for the audit trail.
  • Duplicate and open-document checks on supported recording paths.
  • Company write guard: a write without the right companyId is refused.
  • Tasks for uncertain work, so a person decides. Sending work there is an instruction your agent follows, not a server lock.
  • Revocation: revoke the key under Settings → API keys, or disconnect the company on its Connections tab.

A tool filter in your code narrows what the agent can choose; it does not reduce the key's access. Before adding writes, build your own review step for each operation and test in a demo company. Read AI write access to QuickBooks, safely first.

If you run the agent on a schedule, that schedule is yours. A cron job that starts your agent is your code acting as the key's owner; DeepLedger does not start anything on its own.

Next step: verify one company and one report

After the Node.js test, have your agent run one bounded report:

Using DeepLedger for [confirmed company], retrieve the profit and loss for September 1 through September 30, 2026, on an accrual basis. Show the returned company name and identifier, dates, basis, currency, income, expenses and net income. Do not create or change accounting records.

In QuickBooks Online → Reports → Profit and Loss, run the same company, dates and basis. Compare income, expenses and net income. If totals differ, fix the context and rerun before relying on the agent. Follow the P&L analysis and verification workflow for what to compare.

Troubleshooting

401 Unauthorized. The key is incomplete, expired or revoked, or the header lost its Bearer prefix. Don't send an Intuit token or a model-provider key to the DeepLedger endpoint.

NO_ACTIVE_COMPANY. List the companies, switch explicitly, and read the profile again.

COMPANY_REQUIRED or COMPANY_MISMATCH on a write. The call had no companyId, or it named a different company from the active one. Nothing was written. Confirm the company, then send the write again with the right companyId.

QuickBooks connection error. An admin reconnects the company on its Connections tab in DeepLedger. Changing your MCP configuration will not repair an Intuit authorization.

The host asks for a local command instead of a URL. Use its remote HTTP option. DeepLedger is a hosted Streamable HTTP server, not a local stdio process.

The company changed mid-run. Another client using the same person's access switched it. Creating another key for that person does not isolate the selection; use a One company key or X-Organization-Id.

Frequently asked questions

How do I connect a custom AI agent to QuickBooks Online?

Connect the QuickBooks Online company in DeepLedger, create a DeepLedger API key under Settings, API keys, and point your agent's MCP client at https://mcp.deepledger.ai/mcp with the header Authorization: Bearer followed by the key. The agent then discovers DeepLedger's QuickBooks tools with listTools and calls them like any other MCP tools.

Who can create a DeepLedger API key?

Any team member can create a key under Settings, API keys, Create key. The key acts as the person who created it, with that person's access, and never reaches more companies than they can. Owners and admins can see and revoke every key in the firm; everyone else sees and revokes their own.

Can I make a DeepLedger API key read-only?

No. A DeepLedger API key has no separate read-only switch; it carries the access of the person who created it. Filtering the tool list in your agent limits what that agent can choose, but it does not change what the key can do. Keep the key in an environment variable or secret manager and revoke it when the agent is retired.

Do I need an Intuit developer account to build a QuickBooks AI agent?

No. DeepLedger holds the QuickBooks Online connection that your company authorized through Intuit's sign-in. Your agent authenticates to DeepLedger with a DeepLedger API key, so there is no Intuit app, client secret or token refresh to maintain.

How does the agent know which QuickBooks company to write to?

A key created for All my companies follows the person's active company, which the agent changes with qbCompanyProfile and operation switch. A key created for One company works only in that company. Every write must also carry the company in companyId; if it is missing or differs from the active company, DeepLedger refuses with COMPANY_REQUIRED or COMPANY_MISMATCH and nothing is written.

Can my AI agent for bookkeeping run on a schedule?

Yes, if you schedule it yourself. A cron job or job runner that starts your agent is your own code acting as the key's owner. DeepLedger does not start anything on its own; it only answers the requests your agent sends.

Browse all AI platforms and integrations.

Ready to get started?

Connect QuickBooks and try your first task with an AI agent.

Start free trial

With your permission, Google Analytics measures visits to our public website and blog. Essential cookies work either way. Change your choice in Cookie settings. Privacy policy