> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ancha.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These docs describe the Ancha CLI, npm package @ancha-labs/cli, and the hosted workspace at app.ancha.io. Coding agents should start at https://docs.ancha.io/coding-agents. Run the CLI as `ancha` after `npm install -g @ancha-labs/cli`, or as `npx -y @ancha-labs/cli` without installing. Pass --json for machine-readable output, or set ANCHA_JSON=1. Every command ends with a `next:` line naming the next command. Exit codes: 0 pass, 1 a check failed or a comparison regressed, 2 usage, config or authentication error, 3 infrastructure error, 4 unimplemented endpoint with --strict.

# Connect your agent to the NetSuite mock

> Work with NetSuite records, the general ledger and SuiteQL through SuiteTalk REST or Oracle's 25 MCP Standard Tools, with TBA or OAuth 2.0.

Use SuiteTalk REST, SuiteQL or the MCP Standard Tools to work with one account's books. Your agent can move from sales order to invoice, payment and credit memo, or from purchase order to receipt, vendor bill and bill payment. Transactions update balances, inventory and the general ledger inside the world.

The [NetSuite API mock page](https://ancha.io/tools/netsuite) has a scene and checks you can copy.

Select this tool with `twins: [netsuite]` in a scene or `--tools netsuite` when creating a world. Inspect its API coverage and connection code:

```bash theme={null}
ancha twins coverage netsuite
ancha connect netsuite --lang ts
```

## Connect

| Variable | Value |
| - | - |
| `NETSUITE_API_URL` | Service root, replacing `https://<account>.suitetalk.api.netsuite.com`. |
| `NETSUITE_RECORD_URL` | Record API base URL, ending in `/services/rest/record/v1`. Append a record type and ID. |
| `NETSUITE_SUITEQL_URL` | SuiteQL endpoint, ending in `/services/rest/query/v1/suiteql`. Send queries here with `POST`. |
| `NETSUITE_ACCOUNT_ID` | Account ID in realm form, such as `7654321`. Use it as the OAuth `realm`. |
| `NETSUITE_CONSUMER_KEY` | Fake TBA integration consumer key (`oauth_consumer_key`). |
| `NETSUITE_CONSUMER_SECRET` | Fake TBA integration consumer secret, used to sign requests. |
| `NETSUITE_TOKEN_ID` | Fake TBA token ID (`oauth_token`). |
| `NETSUITE_TOKEN_SECRET` | Fake TBA token secret, used to sign requests. |
| `NETSUITE_ACCESS_TOKEN` | Fake bearer access token. Send `Authorization: Bearer <token>`. |
| `NETSUITE_TOKEN_URL` | OAuth 2.0 token endpoint, ending in `/services/rest/auth/oauth2/v1/token`. |
| `NETSUITE_CLIENT_ID` | Fake OAuth 2.0 client ID, the same value as `NETSUITE_CONSUMER_KEY`. |
| `NETSUITE_CLIENT_SECRET` | Fake OAuth 2.0 client secret, the same value as `NETSUITE_CONSUMER_SECRET`. |
| `NETSUITE_CERTIFICATE_ID` | Certificate ID for the client credentials JWT's `kid` header. |
| `NETSUITE_PRIVATE_KEY` | Fake EC P-256 private key for signing a client credentials JWT. |

You can authenticate with Token-based Authentication (OAuth 1.0a) or a bearer token. For TBA, use the four consumer and token variables above with `HMAC-SHA256` and set `realm` to `NETSUITE_ACCOUNT_ID`. Sign the HTTP method and the full URL your client calls, including query parameters. Send the OAuth parameters in the `Authorization` header with a fresh nonce and a Unix timestamp in seconds.

The snippets use the bearer token:

```ts Node theme={null}
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();
```

```python Python theme={null}
import os, requests
headers = {'Authorization': 'Bearer ' + os.environ['NETSUITE_ACCESS_TOKEN'], 'Content-Type': 'application/json'}
invoice = requests.get(os.environ['NETSUITE_RECORD_URL'] + '/invoice/1002', headers=headers).json()
items = requests.post(os.environ['NETSUITE_SUITEQL_URL'], headers={**headers, 'Prefer': 'transient'}, json={'q': 'SELECT id, tranid FROM transaction WHERE id = 1002'}).json()['items']
```

These are the snippets `ancha connect netsuite --lang ts` and `--lang py` print.

An agent that reads NetSuite under its own names, such as `NS_ACCOUNT_ID` or `NETSUITE_BASE_URL`, gets them in `agent.env`: [`ancha init`](https://docs.ancha.io/cli/init#name-the-agent’s-tools) maps each one to its value, such as `NS_ACCOUNT_ID: "{{netsuite.account_id}}"`.

## Through Composio

An agent that uses NetSuite through Composio keeps its client code in [cloud runs](https://docs.ancha.io/cli/run.md#run-in-the-cloud). [`ancha init`](https://docs.ancha.io/cli/init#detect-composio-agents) detects the client and NetSuite toolkit names or tool slugs, writes the route and adds `COMPOSIO_API_KEY` to `agent.pass_env`, keeping your existing settings:

```yaml ancha.yaml theme={null}
agent:
  command: python agent.py
  routes:
    netsuite: composio
  pass_env: [COMPOSIO_API_KEY]
```

```bash theme={null}
ancha secrets set COMPOSIO_API_KEY
ancha agent upload
ancha run
```

The secret's value comes from your shell. Signed out, run `ancha login` first. Configure your Composio client to read its API URL from `COMPOSIO_BASE_URL`.

Call `NETSUITE_RUN_SUITEQL_QUERY` through `session.execute` or `tools.execute`, with the query in `q` and optional paging arguments. Each attempt runs it against the world's NetSuite and answers in Composio's response format, with the SuiteQL REST body in `data`.

An agent that reaches its tools through the session's MCP URL (`session.mcp.url`), as Claude Code, the OpenAI Agents SDK and LangGraph's MCP adapters do, runs the same query through `COMPOSIO_MULTI_EXECUTE_TOOL`, or calls `NETSUITE_RUN_SUITEQL_QUERY` directly when the session preloads it. `initialize`, `tools/list`, `COMPOSIO_SEARCH_TOOLS` and `COMPOSIO_GET_TOOL_SCHEMAS` answer as Composio's MCP server does, `tools/list` following the session's `search`, `execute.enable_multi_execute` and `tools` settings, and each query counts as one tool call in the report. The MCP client sends `Accept: application/json, text/event-stream`, as Composio requires.

One session can name both `quickbooks` and `netsuite`. In a world with both, that session answers for both: `tools/list`, `COMPOSIO_SEARCH_TOOLS` and `COMPOSIO_GET_TOOL_SCHEMAS` cover both tools, and one `COMPOSIO_MULTI_EXECUTE_TOOL` call can mix QuickBooks and NetSuite tools, with the results in the order you sent them. Declare both under `agent.routes` to use them in the same agent configuration; QuickBooks-only and NetSuite-only tests can share that configuration.

The [upload check](https://docs.ancha.io/cli/agent.md#composio-route-evidence) shows the executions that reached the world. [Composio route errors](https://docs.ancha.io/reference/errors.md#composio-route-errors) lists each refusal reason with its fix.

## OAuth 2.0

Use the world's OAuth endpoints to exercise your client's token flow. Set redirect URIs, `publicClient` and `refreshTokenHours` in `seed.netsuite.integration`.

| Flow | Request |
| - | - |
| Authorization code with PKCE | Open `NETSUITE_API_URL` plus `/app/login/oauth2/authorize.nl` with `response_type=code`, `client_id`, a registered `redirect_uri`, `scope`, `state`, `code_challenge` and `code_challenge_method=S256`. Exchange the returned code at `NETSUITE_TOKEN_URL` with `grant_type=authorization_code`, `code`, `redirect_uri` and `code_verifier`. Confidential clients authenticate with HTTP Basic using the client ID and secret; public clients send `client_id`. |
| Refresh token | Send a form-encoded `grant_type=refresh_token` and `refresh_token` to `NETSUITE_TOKEN_URL` with the same client authentication. Public clients receive a new refresh token with each refresh. |
| Client credentials | Send form-encoded `grant_type=client_credentials`, `client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer` and `client_assertion` to `NETSUITE_TOKEN_URL`. Sign the JWT with `NETSUITE_PRIVATE_KEY` using `ES256`; set `typ: JWT`, `kid: NETSUITE_CERTIFICATE_ID`, `iss: NETSUITE_CLIENT_ID`, `aud: NETSUITE_TOKEN_URL`, `scope: ["rest_webservices"]`, `iat` and `exp`. Give the assertion a lifetime under one hour. |

For REST calls, request `rest_webservices`. Access tokens last 60 minutes. Refresh tokens default to 168 hours for confidential clients and 48 hours for public clients. `refreshTokenHours` accepts 1–720.

For MCP, use the authorization code flow with the `mcp` scope alone and PKCE `S256`. The grant uses the **AI Connector** role. REST tokens carry `rest_webservices`; MCP tokens carry `mcp`.

| Method | Path on `NETSUITE_API_URL` | Use |
| - | - | - |
| `GET` | `/app/login/oauth2/authorize.nl` | Redirect to your registered callback with the code and state. Use 22–1024 printable ASCII characters for `state`. |
| `POST` | `/services/rest/auth/oauth2/v1/token` | Exchange a code, refresh a token or submit a signed client assertion. |
| `POST` | `/services/rest/auth/oauth2/v1/revoke` | Revoke a refresh token and its access tokens. Send the refresh token as form field `token`. |
| `GET` | `/services/rest/auth/oauth2/v1/keys` | Read the JWK set for verifying issued access tokens. |

## MCP Standard Tools

Connect your MCP client to `NETSUITE_API_URL` plus either path:

| Method | Path |
| - | - |
| `POST` | `/services/mcp/v1/all` |
| `POST` | `/services/mcp/v1/suiteapp/com.netsuite.mcpstandardtools` |

Both expose Oracle's 25 MCP Standard Tools over streamable HTTP. Send `Authorization: Bearer <token>` with `NETSUITE_ACCESS_TOKEN` or an OAuth 2.0 token issued for `mcp`. Discover tool schemas with `tools/list` and call them with `tools/call`.

| Work | Tools |
| - | - |
| Records and metadata | `ns_createRecord`, `ns_getRecord`, `ns_updateRecord`, `ns_transformRecord`, `ns_getRecordTypeMetadata`, `ns_getRecordTransformMetadata` |
| Record actions | `ns_getRecordActionMetadata`, `ns_executeRecordAction` |
| Reports and accounting setup | `ns_listAllReports`, `ns_runReport`, `ns_getAccountingBooks`, `ns_getAccountingContexts`, `ns_getNexusIds`, `ns_getSubsidiaries` |
| Saved searches | `ns_listSavedSearches`, `ns_runSavedSearch` |
| SuiteQL | `ns_getSuiteQLMetadata`, `ns_runCustomSuiteQL` |
| File Cabinet | `ns_getFolderByPath`, `ns_getIdFromPath`, `ns_getPathFromId`, `ns_searchFiles`, `ns_attachFile`, `ns_detachFile` |
| Session | `ns_getSessionInfo` |

Reports include trial balance, income statement, balance sheet, A/R and A/P aging, general ledger, sales by customer and item, and purchases by vendor. Record tools use the same validation and state as REST. Results contain JSON text and `structuredContent`; tool errors set `isError`.

For a world started with [`ancha world up`](https://docs.ancha.io/cli/world-lifecycle), generate the same catalog's client configuration:

```bash theme={null}
ancha mcp config --env '<envId>' --tool netsuite --json
```

Use the world's ID in place of `<envId>`. The generated entry is `ancha-netsuite`, at `/e/<envId>/mcp/netsuite`, with its own attempt token. Runs also supply `ANCHA_MCP_NETSUITE_URL` and `ANCHA_MCP_NETSUITE_TOKEN`. See [ancha mcp](https://docs.ancha.io/cli/mcp.md) for HTTP client configurations and the stdio bridge.

## Endpoints

| Method | Path | Notes |
| - | - | - |
| `GET` | `/services/rest/record/v1/:type` | List record IDs and links with `q` filters, `limit` and `offset`. |
| `POST` | `/services/rest/record/v1/:type` | Create a record. Returns `204` with the record URL in `Location`. |
| `GET` | `/services/rest/record/v1/:type/:id` | Read by internal ID or `eid:` external ID. Use `fields` to select fields and `expandSubResources=true` for sublist contents. |
| `PATCH` | `/services/rest/record/v1/:type/:id` | Update fields and merge sublist lines by key. Use `replace=<sublist>` to replace a whole sublist. |
| `PUT` | `/services/rest/record/v1/:type/:externalId` | Create or update a record at `eid:<externalId>`. Returns `204` with `Location`. |
| `DELETE` | `/services/rest/record/v1/:type/:id` | Delete a customer, vendor or transaction. Dependent records must be removed first. |
| `GET` | `/services/rest/record/v1/:type/:id/:sublist` | Read `item`, `expense`, `line` or `apply` links. Add `expandSubResources=true` for line contents. |
| `GET` | `/services/rest/record/v1/:type/:id/:sublist/:line` | Read a sublist line. An application uses the key `doc=<id>,line=0`. |
| `POST` | `/services/rest/record/v1/:type/:id/!transform/:target` | Turn a sales order into an invoice, an invoice into a payment or credit memo, or a vendor bill into a bill payment. |
| `POST` | `/services/rest/query/v1/suiteql` | Query the account's records with `Prefer: transient`, `limit` and `offset`. |
| `GET` | `/services/rest/record/v1/metadata-catalog` | List record types. Append a type for its JSON Schema or request `application/swagger+json` for OpenAPI. |

## Records

Use these record type names in the record URL:

| Records | Types | Working with them |
| - | - | - |
| People and companies | `customer`, `vendor`, `contact`, `employee` | Read and write entity records, addresses and custom fields. Customer and vendor balances follow transactions and applications. |
| Sales and receivables | `estimate`, `salesOrder`, `itemFulfillment`, `invoice`, `cashSale`, `creditMemo`, `customerPayment`, `customerDeposit`, `depositApplication`, `customerRefund`, `returnAuthorization` | Quote, order, ship, bill, collect, credit and refund. Item lines set totals; invoice due dates follow terms. |
| Purchasing and payables | `purchaseOrder`, `itemReceipt`, `vendorBill`, `vendorCredit`, `vendorPayment`, `vendorReturnAuthorization` | Order, receive, bill, pay and return. Bills carry item or expense lines and an approval status. |
| Journals and expenses | `journalEntry`, `expenseReport` | Post balanced journals and approve employee expenses. Journal entries need at least two lines with equal debit and credit totals. |
| Items | `serviceSaleItem`, `servicePurchaseItem`, `serviceResaleItem`, `nonInventorySaleItem`, `nonInventoryPurchaseItem`, `nonInventoryResaleItem`, `otherChargeSaleItem`, `otherChargePurchaseItem`, `otherChargeResaleItem`, `inventoryItem` | Read and write items for sales, purchases and resale. Inventory quantities and moving average cost follow transactions. |
| Lists and accounting setup | `account`, `subsidiary`, `currency`, `term`, `department`, `location`, `classification`, `accountingPeriod`, `accountingBook`, `currencyRate`, `expenseCategory` | Inspect the chart of accounts, organizational lists, periods, books, rates and expense categories. |

Other record types, such as custom record types and `project`, are served as the seed gives them, through record URLs, SuiteQL tables named after the type and the metadata catalog. Fields beyond a modeled record's own go in its `extra` and come back with the record.

Each transaction is in its own subsidiary and currency and posts to the general ledger in the base currency at its exchange rate. A new transaction without `exchangeRate` takes its currency's rate in effect on its date.

Sublist writes use an object with an `items` array. `PATCH` merges by `line`, or by `doc` for applications. Add `replace=<sublist>` to replace a whole sublist. Record collections accept `q` filters on top-level fields and return `count`, `hasMore`, `offset` and `totalResults` with paging links.

## External IDs and upsert

Set `externalId` when creating a record, then address it as `eid:<externalId>` in place of an internal ID. External ID values match without regard to case. Customers and vendors share one external ID space; transactions share another.

Use `PUT` at a URL such as `NETSUITE_RECORD_URL + '/customer/eid:ridgeway-billing'` with a body such as `{"companyName":"Ridgeway Robotics"}`. It creates the customer if the external ID is new and updates the customer if it exists.

## Transforms

Send `POST` to the source record's `!transform/<target>` path with a JSON body. The response is `204` with the new record's URL in `Location`.

| Source → target | Result |
| - | - |
| `salesOrder` → `invoice` | Bills the open order lines and carries the order's terms. To choose lines and quantities, send `item.items` entries with `orderLine` and `quantity`. Each order line can appear once per request, up to its remaining quantity. |
| `invoice` → `customerPayment` | Applies a payment to the invoice's remaining balance. Set `payment` to choose the payment amount. |
| `invoice` → `creditMemo` | Copies the invoice's item lines and amounts and applies the credit to its open balance. You can set `item` and `apply` in the request. |
| `vendorBill` → `vendorPayment` | Pays the approved bill's open balance. You can set `apply` in the request. |

For example, send `{"item":{"items":[{"orderLine":1,"quantity":1}]}}` to `/services/rest/record/v1/salesOrder/1001/!transform/invoice` to bill one more week from the starter order.

## Applying payments

Customer payments and credit memos apply to the customer's open invoices. Bill payments apply to the vendor's approved, open bills. Each `apply.items` entry names a document and an amount:

```json theme={null}
{
  "customer": { "id": "101" },
  "payment": 200,
  "apply": {
    "items": [{ "doc": { "id": "1002" }, "apply": true, "amount": 200 }]
  }
}
```

Send this body to `POST /services/rest/record/v1/customerPayment`. The application reduces the invoice's remaining balance. Set `apply: false` or `amount: 0` on an application to release it. `replace=apply` releases applications left out of the new list. Applied amounts must fit both the document's amount due and the payment or credit total.

New vendor bills in the starter world wait for approval. Set `approvalStatus` to `2` to approve a bill before paying it. The starter integration role can approve bills.

## SuiteQL

Send `POST` to `NETSUITE_SUITEQL_URL` with `Prefer: transient` and a JSON body such as `{"q":"SELECT id, tranid FROM transaction WHERE id = 1002"}`.

Query entities, items, accounts, organizational lists, accounting periods, transactions, `transactionline`, `transactionaccountingline` and the File Cabinet. These tables reflect the same records you write through REST. Use `BUILTIN.DF` to read display values for references and coded columns.

Query `systemnote` for record changes. `previoustransactionlinelink` and `nexttransactionlinelink` connect purchase orders, item receipts and vendor bills at the line level. Entity records include `dateCreated`; set it in an entity seed to place creation before its first transaction.

Write queries in Oracle's dialect: joins, subqueries, `WITH`, `CASE`, set operations, aggregates and analytic functions such as `ROW_NUMBER() OVER (...)`. Use `NVL`, `DECODE`, `TO_DATE`, `TO_CHAR` and `REGEXP_LIKE` for Oracle expressions. A `params` array binds the query's `?` markers in order.

Set `limit` and `offset` as URL query parameters for SuiteQL and record collections. `limit` accepts 1–1000 and defaults to 1000; `offset` defaults to 0 and must be a multiple of `limit`. Follow the response's `next` link while `hasMore` is true. SuiteQL returns values as strings, dates as `M/D/YYYY` and booleans as `T` or `F`. `subsidiary.currency` is the subsidiary's base currency, and `currency.isbasecurrency` marks it with `T`.

## General ledger and accounting periods

Transactions post debits and credits to the general ledger. Read them through SuiteQL's `transactionaccountingline` table or the MCP reports. Posting transactions update the ledger when you save them; quotes, orders and return authorizations track the workflow before posting.

Set a transaction's `postingPeriod` to an open monthly accounting period. Posting into a closed period fails. Set `seed.netsuite.policy.closedThrough` to a month such as `2026-10`, or `-1m` for the month before the scene starts, to test closing rules.

## Asynchronous jobs and batches

Add `Prefer: respond-async` to a record or SuiteQL request. The response is `202` with the job URL in `Location`. Poll the job until `completed` is true, then follow its task links and each task's `result` link. The world runs the job one second after submission on its clock.

For a batch of 1–100 records, send `POST`, `PATCH` or `PUT` to the record collection with `Content-Type: application/vnd.oracle.resource+json; type=collection` and an `items` array. For `GET` or `DELETE`, supply `ids` in the query. Batches use `Prefer: respond-async` and create one task per record.

Pass `X-NetSuite-Idempotency-Key` to identify an asynchronous submission. Reusing it returns `400 IDEMPOTENCY_ERROR` with the first job's URL in `Location`.

## Starter data

Inspect the starter records and the fields you can use in a scene:

```bash theme={null}
ancha sandbox configuration --tools netsuite --json
ancha twins seed netsuite
```

The first command prints the starter dataset. The second lists accepted seed fields and any built-in check examples. A scene uses the data you put in its `seed` field.

The starter account is **Acme**, account ID `7654321`, with one subsidiary, USD, Net 15, Net 30 and Due on receipt terms, and ten accounts.

| Record | Detail |
| - | - |
| Customers | Ridgeway Robotics, Pinecrest Health, Bluefield Logistics, Kestrel Credit Union and Lakeview Retail. |
| Vendors | Northgate Cloud Hosting, Harlow & Reid LLP, Pemberton Office Supply and Swiftline Couriers. |
| Service items | Implementation at 1,500 USD per week, an annual platform license at 12,000 USD, monthly support at 600 USD and training at 900 USD per session. |
| Sales order and invoices | Pinecrest's `SO1001` orders three implementation weeks, with one billed on `INV1003`. Five invoices cover Ridgeway support, Pinecrest implementation, Bluefield training and Kestrel's annual license. |
| Customer payments and credit | Ridgeway has a 200 USD payment and a 100 USD support credit applied to `INV1001` (internal ID `1002`). Kestrel's 12,000 USD invoice is paid. |
| Vendor bills and payment | Northgate's approved 2,400 USD hosting bill, Harlow & Reid's 3,750 USD bill awaiting approval, and Pemberton's approved 180 USD supplies bill with its payment. |
| Journal entry | `JE1001` accrues 1,200 USD in legal fees against accrued expenses. |

## Built-in dataset

`netsuite-pe` is the books of a private-equity portfolio company, Ostrander Industrial Holdings: four subsidiaries, US dollar and euro books, and 18 months of order to cash and procure to pay. It holds what an operator finds at close: overdue receivables, duplicate bills, unapplied payments and credits, three-way-match exceptions and journal entries waiting for approval. It comes with 25 tasks: 10 operator questions whose answers are computed from the books, and 15 workflows that change them, each graded on the records a correct agent leaves.

```bash theme={null}
ancha world gen --dataset netsuite-pe --size m
```

| Size | Customers | Vendors | Transactions |
| - | - | - | - |
| `s` | 60 | 34 | 1,522 |
| `m` | 400 | 180 | 11,431 |
| `l` | 800 | 360 | 22,268 |

For an agent that calls NetSuite directly, in a project with no tests, `ancha init` writes it with a test for each task; for an agent that reaches NetSuite through Composio, with a test for each read task. See [`ancha world gen`](https://docs.ancha.io/cli/world-gen#a-built-in-dataset) and [Test a NetSuite agent](https://docs.ancha.io/guides/test-a-netsuite-agent.md).

## Your own exports

```bash theme={null}
ancha world import netsuite exports/ --id our-books
```

The command writes a world from REST record JSON, SuiteQL results and saved search CSV, each record in its own subsidiary and currency, and names each record whose books do not add up. See [`ancha world import netsuite`](https://docs.ancha.io/cli/world#ancha-world-import-netsuite).

## Errors

Errors use `application/vnd.oracle.resource+json; type=error`. The body contains `type`, `title`, `status` and an `o:errorDetails` array. Each detail has `detail` and `o:errorCode`, with `o:errorPath` when a field is at fault.

| Status | `o:errorCode` | Meaning |
| - | - | - |
| `401` | `INVALID_LOGIN` | The bearer token or TBA credentials failed authentication. Check the supplied credentials, realm and signature. |
| `404` | `NONEXISTENT_ID` | The record instance does not exist. Check the internal or external ID. |
| `400` | `USER_ERROR` | A business rule failed, such as applying more than the amount due or paying a bill before approval. Read `detail` and `o:errorPath` for the field to change. |

## Checks

Use [trace checks](https://docs.ancha.io/concepts/checks.md#trace-patterns), for example `{ called: "POST /services/rest/record/v1/customerPayment" }`, `{ not_called: "DELETE /services/rest/record/v1/*/*" }` or, for the MCP tools, `{ called: "MCP ns_runCustomSuiteQL" }`. [State checks](https://docs.ancha.io/reference/checks.md#netsuite) read the records: `netsuite.record`, `netsuite.count`, `netsuite.unchanged` and `netsuite.preserved`. The last compares a seeded record's fields and sublists with its final state, except the top-level `except_fields`. A failure names changed fields with before and after values. An [answer check](https://docs.ancha.io/reference/checks.md#answer-checks) reads the totals, names and document numbers in the agent's final answer.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.