twins: [quickbooks] in a scene or --tools quickbooks when creating a world. Inspect its API coverage and connection code:
Connect
Ancha supplies these variables to your agent:
These are the snippets
ancha connect quickbooks --lang ts and --lang py print:
QUICKBOOKS_API_URL and QUICKBOOKS_REALM_ID. Send JSON bodies with Content-Type: application/json. Responses are JSON; send Accept: application/xml for XML. The snippets set minorversion=75.
OAuth 2.0
Send a form-encodedPOST to QUICKBOOKS_TOKEN_URL with grant_type=refresh_token and refresh_token. Authenticate with HTTP Basic using QUICKBOOKS_CLIENT_ID and QUICKBOOKS_CLIENT_SECRET, or send them as form fields client_id and client_secret.
Access tokens last 3,600 seconds on the world’s clock. Refresh tokens last 8,726,400 seconds (101 days). A refresh token at least 24 hours old produces a new refresh token. Store the returned access_token and refresh_token. The response also includes token_type, expires_in and x_refresh_token_expires_in. An earlier refresh token remains valid until expiry or revocation.
To revoke a token, send POST to QUICKBOOKS_API_URL plus /oauth2/v1/tokens/revoke or /v2/oauth2/tokens/revoke with JSON {"token":"<token>"}. Revoking a refresh token also revokes access tokens issued from it. A successful revoke returns 200 with an empty body.
Through Composio
An agent that runs QuickBooks tools through Composio keeps that path in cloud runs: the agent calls Composio, and Composio’s servers call the world’s QuickBooks.ancha init detects the Composio client and QuickBooks toolkit names or tool slugs, writes the route and adds COMPOSIO_API_KEY to agent.pass_env, keeping your existing settings:
ancha.yaml
ancha login first. Routed tests run in the cloud.
Each test’s world decides which routed tools answer there. QuickBooks-only and NetSuite-only tests can use the same agent configuration. A call to a routed tool the world lacks returns 403 COMPOSIO_ROUTE_REFUSED with reason NO_WORLD and a fix to add the tool to the world or run the call in a test whose world has it. The attempt is graded as usual.
In a world with QuickBooks, the agent keeps its Composio code: direct executions, Tool Router sessions and the session’s MCP endpoint all reach the world. Every attempt sets four variables:
-
Direct executions (
composio.tools.execute) reach the world whatever user ID, connected account orcustom_auth_paramsthe agent names: the gateway supplies the world’s address and credentials on each call. -
Sessions (
composio.create) reach the world through a QuickBooks connection that the attempt creates in your Composio project for its own user (ancha-…). Each session is pinned to that connection. When the attempt ends, it deletes the sessions, the connection and its auth config. -
MCP: the session’s MCP URL points at the attempt’s gateway, so an MCP client in the agent’s process reaches the same session with
COMPOSIO_API_KEY. MCP clients such as Claude Code connect as they do to Composio: their tool calls reach the world, and every other request goes to Composio as sent. -
Before the agent starts, the attempt checks that
QUICKBOOKS_PUBLIC_URLanswers from outside. -
An agent that reads its Composio user from a variable of its own, such as
QUICKBOOKS_USER_ID, gets it fromancha init, which adds it underagent.envwith any value.ancha agent uploadnames such a variable, with the lines to add, before it uploads. -
An agent that pins its connected account, such as
QUICKBOOKS_CONNECTED_ACCOUNT_ID, maps it to the attempt’s own connection underagent.env:The attempt then creates its connection before the agent starts, so an agent that checks its account finds itACTIVE, and every call it makes with that account reaches the world.ancha initadds the mapping when the agent reads such a variable, moving it out ofpass_envwhen it is listed there, andancha agent uploadnames one that is unset or comes throughpass_env. -
The gateway keeps every call on the world. A call that names a toolkit outside the declared routes, changes a session’s connection, proxies a request or reaches another attempt’s session gets
403 COMPOSIO_ROUTE_REFUSEDwith areason, and the attempt is invalid withROUTE_REFUSED, so every result rests on calls inside the world. -
Composio’s calls reach the world like the agent’s own: the world’s trace and the checks see them. An execution with no request reaching the world makes the attempt invalid with
ROUTE_NOT_REACHED. -
The run’s summary counts the route under
routes.quickbooks: executions by path (via.direct,via.session,via.mcp), how many reached the world, refusals, sessions, and the test connection’sconnectionandcleanup.
Start with the QuickBooks examples
For an agent that uses QuickBooks, in a project with no tests and no traces,ancha init writes Pellmont Building Services’ 2025 books. This fictional facilities company has 14 vendors, 8 customers, 42 invoices and 71 bills.
--data none leaves these examples out. For a routed agent, init also writes a starter test that reads from each routed tool. Store COMPOSIO_API_KEY, upload the agent and run the tests with the commands above.
An agent that writes to QuickBooks only behind a flag runs the merge from a second configuration that adds the flag to agent.command:
Endpoints
Paths below are relative toQUICKBOOKS_API_URL. Replace {realmId} with QUICKBOOKS_REALM_ID.
Use lowercase entity names in resource paths, such as
invoice or customer. Responses and query entity names use Invoice and Customer. Numeric fields take JSON numbers or numeric strings such as "25.00".
For an update, include the current Id and SyncToken. Set sparse: true to merge supplied top-level fields; supplied nested objects and arrays replace their previous values. Without sparse: true, the update replaces the record: writable fields it leaves out are cleared. A stale SyncToken returns code 5010.
Set operation=delete to delete a transaction. Set operation=void to void an Invoice, Payment, SalesReceipt or BillPayment. For the latter three, operation=update&include=void also voids the transaction. Change a list record’s availability with Active. A requestid query parameter replays the first response stored for that ID within the company.
Entities
Use these names in queries and checks:
Create tax agencies with
POST /taxagency and tax codes with their rates through POST /taxservice/taxcode. Update CompanyInfo with a full or sparse update and Preferences with sparse: true. Transactions update account balances and the general ledger. Apply payments and credits through Line[].LinkedTxn entries that name the related TxnId and TxnType.
Currencies
A company keeps its books in its home currency,Preferences.CurrencyPrefs.HomeCurrency. With MultiCurrencyEnabled: true, customers, vendors and accounts can carry another currency in CurrencyRef, and their transactions follow it:
- A transaction without
CurrencyReftakes its customer’s or vendor’s currency. WithoutExchangeRate, it takes the world’s latest rate dated on or before itsTxnDate. The rate stays with the transaction once it is written. - Totals and balances are in the transaction’s currency;
HomeTotalAmtandHomeBalancegive the home amounts. - Receivables and payables in another currency post to an A/R or A/P account in that currency, created on first use as
Accounts Receivable (A/R) - EURorAccounts Payable (A/P) - EUR. - A payment settles each invoice or bill at the rate it was written at, and the difference posts to Exchange Gain or Loss.
- Reports are in the home currency.
exchangeRates:
Inventory
An item withType: Inventory tracks its quantity and cost. It names an income account, a Cost of Goods Sold account in ExpenseAccountRef and an Other Current Asset account in AssetAccountRef, and starts with QtyOnHand at PurchaseCost on InvStartDate. Inventory needs ForSales, ForPurchase, QuantityWithPriceAndRate and QuantityOnHand turned on in ProductAndServicesPrefs.
- The opening quantity posts to the asset account and to Opening Balance Equity.
- Bills and purchases add cost layers in the home currency. Invoices and sales receipts take cost first in, first out: Cost of Goods Sold is debited and the asset account credited.
- Credit memos and refund receipts restock at the unit cost of the item’s latest earlier sale, or at its
PurchaseCostwhen it has none. Vendor credits take their units out at layer cost, and the difference from the credit posts to Cost of Goods Sold. InventoryAdjustmentwithQtyDiffchanges quantity on itsTxnDateagainst itsAdjustAccountRef. An item update with a newQtyOnHandrecords the change against the item’s Cost of Goods Sold account, on theInvStartDateit sends or on the company’s current date.Item.QtyOnHandreads the quantity after every transaction.InventoryValuationSummaryandInventoryValuationDetailgive quantity and value on any date.- A line for an inventory item needs
Qty, and a transaction dated before the item’sInvStartDategets error 6270.
Query
Send a query withGET /v3/company/{realmId}/query?query=... or as the text body of POST /v3/company/{realmId}/query.
Queries default to
STARTPOSITION 1 and MAXRESULTS 100. Request up to 1,000 results per page. Ordering defaults to numeric Id; equal sort values also use numeric Id. List queries select active records by default. Use WHERE Active IN (true, false) to include inactive records.
Use MetaData.CreateTime and MetaData.LastUpdatedTime in selections, conditions and ordering; field names match in any case. Filter a reference such as CustomerRef by its ID. A field projection returns the selected fields plus Id and sparse: true.
Results appear in QueryResponse.<Entity> with startPosition and maxResults. An empty result has QueryResponse: {}. COUNT(*) returns QueryResponse.totalCount.
Reports
ReadGET /v3/company/{realmId}/reports/{report}. JSON responses contain Header, Columns and Rows at the top level.
Reports use accrual accounting by default and the company’s time zone. Their totals follow the same transactions, applications and ledger as entity reads.
ProfitAndLoss and GeneralLedger default to This Fiscal Year-to-date. Aging defaults to current, 1–30, 31–60, 61–90 and 91 days or more. Use the aging parameters with the aged reports.
Change data capture
SendGET /v3/company/{realmId}/cdc with comma-separated entities and an ISO date or datetime in changedSince. For example, set entities=Invoice,Payment. Choose a time within the last 30 days on the world’s clock. Dates and datetimes without an offset use the company’s time zone.
The response contains CDCResponse[].QueryResponse[], one entry per requested entity type. It returns the current body once per changed ID, newest change first, including changes caused by payment applications. Deleted records carry status: "Deleted", Id and MetaData.LastUpdatedTime. Each type returns up to 1,000 records; totalCount gives its full changed-record count. The change history starts after seeding.
Batch
SendPOST /v3/company/{realmId}/batch with a BatchItemRequest array of 1–30 items. Give each item a unique, nonempty string bId.
An entity item contains operation: "create", "update" or "delete" and one entity body. A query item contains Query with query text. Responses appear in BatchItemResponse, with the same bId and either the result or a Fault.
Items execute in order. Each successful write commits independently, and later queries see it. An item fault leaves earlier successful writes in place. Use requestid on the batch URL to replay the whole response.
Sending
SendPOST /v3/company/{realmId}/{entity}/{id}/send for an Invoice, Estimate, SalesReceipt, CreditMemo or PurchaseOrder. Supply sendTo as a query parameter or set BillEmail.Address on the record.
A send sets EmailStatus to EmailSent, records DeliveryInfo and adds a send event with the entity, recipient, document number and world time. Use quickbooks.sent to check that event.
Attachments
Upload files withPOST /v3/company/{realmId}/upload as multipart/form-data. Send each file as a pair of parts: file_metadata_0 holds the Attachable JSON, with AttachableRef naming the entity it belongs to, and file_content_0 holds the bytes. Number further files _1, _2 and so on. The response lists each new Attachable under AttachableResponse.
An Attachable read or query returns TempDownloadUri, a signed link to the file that stays valid for five minutes of world time. Query a record’s attachments with WHERE AttachableRef.EntityRef.Type = 'Invoice' AND AttachableRef.EntityRef.Value = '2'.
Starter data
Inspect the starter records and the fields you can use in a scene:9341458206001234, with USD books and the America/Los_Angeles time zone.
Starter balances are 10,000 USD in Operating bank, 400 USD in Undeposited Funds, 2,700 USD receivable and 750 USD payable. Across all starter transactions, revenue is 3,100 USD, expenses are 750 USD and net income is 2,350 USD.
Errors
Accounting validation errors return400 with Fault.type: "ValidationFault" and a Fault.Error array. Each entry has code, Message and Detail, plus element when a field is identified.
JSON authentication errors use lowercase fault.type: "AUTHENTICATION" and fault.error entries with code, message, detail and element. Their top-level time is the world time in milliseconds. XML authentication errors use Fault and Error.
Token endpoint errors use
{"error":"<code>"}: invalid_client returns 401; invalid_grant and unsupported_grant_type return 400. A malformed revoke request returns 400 with invalid_request.