A NetSuite API mock for testing finance agents.
A local NetSuite API for your agent’s tests. Bills, payments and invoices it writes stay in the books, so a test can check what it approved or paid.
Oakes Fleet Services
billing@oakes-fleet.example
- Bill INV 001426$13,202.75
Paid by ACH-30249, 64 days ago
- Bill INV-001426$13,202.75
Pending approval
Agent printed
Left INV-001426 pending: it duplicates bill INV 001426.
An agent approved a bill that was already paid
Jasper, the controller at Ostrander Flow Controls, asked the agent to approve bill INV-001426 from Oakes Fleet Services for Friday’s payment run. Oakes had billed the same $13,202.75 three months earlier, keyed in as INV 001426, and that bill was paid. The agent looked for another bill with the same invoice number, found none, and approved the duplicate.
The test checks the agent’s calls and the books: it must look up the vendor’s other bills and must change no bill or payment.
| Check | Original agent | Fixed agent |
|---|---|---|
| Looked up the vendor’s other bills | 3 of 3 | 3 of 3 |
| Changed no bill or payment | 0 of 3 | 3 of 3 |
Scripted agent, no model. Recorded with CLI 0.4.74.
The one-line fix
- const duplicate = others.find(other => other.tranid === bill.tranId);+ const duplicate = others.find(other => other.tranid.replace(/\W/g, '') === bill.tranId.replace(/\W/g, ''));Run it yourself
Save agent.mjs and scene.yaml in an empty directory. You need Node.js 24.
npm install -g @ancha-labs/cli
ancha init --agent "node agent.mjs"
ancha run scene.yaml --local -n 3
ancha baseline save before
# change other.tranid === bill.tranId to other.tranid.replace(/\W/g, '') === bill.tranId.replace(/\W/g, '') in agent.mjs
ancha run scene.yaml --local -n 3 --compare beforeConnect your agent to the NetSuite mock
When ancha runs your agent, it sets:
NETSUITE_API_URLNETSUITE_RECORD_URLNETSUITE_SUITEQL_URLNETSUITE_ACCOUNT_IDNETSUITE_CONSUMER_KEYNETSUITE_CONSUMER_SECRETNETSUITE_TOKEN_IDNETSUITE_TOKEN_SECRETNETSUITE_ACCESS_TOKENNETSUITE_TOKEN_URLNETSUITE_CLIENT_IDNETSUITE_CLIENT_SECRETNETSUITE_CERTIFICATE_IDNETSUITE_PRIVATE_KEY
Point the client you already use at them.
const headers = { Authorization: 'Bearer ' + process.env.NETSUITE_ACCESS_TOKEN, 'Content-Type': 'application/json' };
const invoice = await (await fetch(process.env.NETSUITE_RECORD_URL + '/invoice/1002', { headers })).json();
const { items } = await (await fetch(process.env.NETSUITE_SUITEQL_URL!, { method: 'POST', headers: { ...headers, Prefer: 'transient' }, body: JSON.stringify({ q: 'SELECT id, tranid FROM transaction WHERE id = 1002' }) })).json();Locally, ancha runs your agent as an ordinary process, so keep real NetSuite credentials out of its environment.
See all 23 endpoints
app
/app/login/oauth2/authorize.nlservices
/services/mcp/v1/all/services/mcp/v1/suiteapp/com.netsuite.mcpstandardtools/services/rest/async/v1/job/:id/services/rest/async/v1/job/:id/task/services/rest/async/v1/job/:id/task/:task/services/rest/async/v1/job/:id/task/:task/request/services/rest/async/v1/job/:id/task/:task/result/services/rest/auth/oauth2/v1/keys/services/rest/auth/oauth2/v1/revoke/services/rest/auth/oauth2/v1/token/services/rest/query/v1/suiteql/services/rest/record/v1/:type/services/rest/record/v1/:type/services/rest/record/v1/:type (Prefer: respond-async)/services/rest/record/v1/:type/:externalId/services/rest/record/v1/:type/:id/services/rest/record/v1/:type/:id/services/rest/record/v1/:type/:id/services/rest/record/v1/:type/:id/:sublist/services/rest/record/v1/:type/:id/:sublist/:line/services/rest/record/v1/:type/:id/!transform/:target/services/rest/record/v1/metadata-catalogMore payments and commerce tools
All 43 toolsNetSuite API mock FAQ
Can an agent bill part of a NetSuite sales order?
Send item.items entries with orderLine and quantity to POST /. The mock bills up to each line’s remaining quantity. The order stays Pending Billing while any line has quantity left to bill and becomes Billed when none does.
Does the NetSuite mock accept token-based authentication?
Yes. Sign each request with OAuth 1.0a and HMAC-SHA256 over the method and the full URL, with realm set to NETSUITE_ACCOUNT_ID and the consumer and token variables Ancha sets. A bad signature or a reused nonce gets 401 with INVALID_LOGIN. A bearer token in NETSUITE_ACCESS_TOKEN works too.
Can an agent that calls NetSuite through Composio use the mock?
Yes, and it keeps its Composio code. ancha init finds Composio in the project and sets netsuite: composio under agent.routes in ancha.yaml, with COMPOSIO_API_KEY under agent.pass_env. In each cloud attempt, NETSUITE_RUN_SUITEQL_QUERY through session.execute or tools.execute runs against the mock's books, and one session can name QuickBooks too.
Can my agent query NetSuite records with SuiteQL in a test?
Send POST / with Prefer: transient and the query in q. SuiteQL reads the same books your agent writes through REST, across customer, vendor, item, account, transaction, transactionline and more, and pages with limit, offset and hasMore.
What happens when an agent applies more than an invoice’s amount due?
The mock answers 400 with USER_ERROR and names the invoice and its amount due in o:errorDetails. Applied amounts must fit both the invoice’s amount due and the payment total.
How can an agent create or update a NetSuite customer by external ID?
Send PUT / with the customer’s fields. The mock creates the customer when the external ID is new and updates it when one exists. External IDs match without regard to case.
Run the example on your machine.
Ancha is not affiliated with NetSuite.