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.

See the example
Ostrander Flow ControlsPending Approval

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.

The vendor’s bills after the fixed agent runs: the duplicate still waits for approval. Starting data and checks from scene.yaml.

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.

Approval check3 trials / version
CheckOriginal agentFixed agent
Looked up the vendor’s other bills3 of 33 of 3
Changed no bill or payment0 of 33 of 3

Scripted agent, no model. Recorded with CLI 0.4.74.

The one-line fix

agent.mjs
- 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 before

Connect your agent to the NetSuite mock

When ancha runs your agent, it sets:

  • NETSUITE_API_URL
  • NETSUITE_RECORD_URL
  • NETSUITE_SUITEQL_URL
  • NETSUITE_ACCOUNT_ID
  • NETSUITE_CONSUMER_KEY
  • NETSUITE_CONSUMER_SECRET
  • NETSUITE_TOKEN_ID
  • NETSUITE_TOKEN_SECRET
  • NETSUITE_ACCESS_TOKEN
  • NETSUITE_TOKEN_URL
  • NETSUITE_CLIENT_ID
  • NETSUITE_CLIENT_SECRET
  • NETSUITE_CERTIFICATE_ID
  • NETSUITE_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

GET/app/login/oauth2/authorize.nl

services

POST/services/mcp/v1/all
POST/services/mcp/v1/suiteapp/com.netsuite.mcpstandardtools
GET/services/rest/async/v1/job/:id
GET/services/rest/async/v1/job/:id/task
GET/services/rest/async/v1/job/:id/task/:task
GET/services/rest/async/v1/job/:id/task/:task/request
GET/services/rest/async/v1/job/:id/task/:task/result
GET/services/rest/auth/oauth2/v1/keys
POST/services/rest/auth/oauth2/v1/revoke
POST/services/rest/auth/oauth2/v1/token
POST/services/rest/query/v1/suiteql
GET/services/rest/record/v1/:type
POST/services/rest/record/v1/:type
POST/services/rest/record/v1/:type (Prefer: respond-async)
PUT/services/rest/record/v1/:type/:externalId
GET/services/rest/record/v1/:type/:id
PATCH/services/rest/record/v1/:type/:id
DELETE/services/rest/record/v1/:type/:id
GET/services/rest/record/v1/:type/:id/:sublist
GET/services/rest/record/v1/:type/:id/:sublist/:line
POST/services/rest/record/v1/:type/:id/!transform/:target
GET/services/rest/record/v1/metadata-catalog

More payments and commerce tools

All 43 tools

NetSuite API mock FAQ

Can an agent bill part of a NetSuite sales order?

Send item.items entries with orderLine and quantity to POST /services/rest/record/v1/salesOrder/{id}/!transform/invoice. 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 /services/rest/query/v1/suiteql 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 /services/rest/record/v1/customer/eid:<externalId> 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.

Book a demo

Ancha is not affiliated with NetSuite.