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

# NetSuite Attach File

> Uploads a task file to the NetSuite File Cabinet and attaches it to a record such as a vendor bill.

Puts a document — typically the invoice PDF the task was started from — into the workspace's own NetSuite account and attaches it to a record, where it shows under the record's **Communication → Files** subtab. Display name **"NetSuite Attach File"**. Off by default.

<Warning>
  The integration's role needs the **SOAP Web Services** permission, which REST-only NetSuite integrations usually lack. Add it before enabling this tool; see Authentication below.
</Warning>

It uses **SuiteTalk SOAP**, not REST: NetSuite's REST record API has no File Cabinet `file` record and no attach operation. SOAP signs with the same token-based-auth credentials as the other NetSuite tools (a `tokenPassport` header, HMAC-SHA256), so nothing has to be deployed in the customer's account — no RESTlet, no script.

## Authentication and enablement

Configured tool bound to a **NetSuite** integration (account id, token id/secret, consumer key/secret — the same binding as [NetSuite Lookup](/docs/tools/netsuite_lookup)). On top of what the REST tools need, the role behind the token must have:

* **Setup → SOAP Web Services** (REST Web Services alone is not enough),
* **Lists → Documents and Files** at Create level, and access to the target folder,
* **REST Web Services** and **SuiteAnalytics Workbook**, used to find an earlier upload when a retry needs it,
* Edit access to the record type being attached to (e.g. Bills).

The Integration record must have **Token-based Authentication** enabled, as it already does for REST. Sandbox account ids such as `123456_SB1` work as given.

## Inputs

* `record_type` — **required.** The record to attach to: `vendorBill`, `vendorCredit`, `vendorPayment`, `purchaseOrder`, `itemReceipt`, `salesOrder`, `invoice`, `creditMemo`, `customerPayment`, `cashSale`, `estimate`, `journalEntry`, `expenseReport`, `vendor`, `customer`, `employee`, `contact`. Case and underscores are ignored (`vendorbill`, `VENDOR_BILL`).
* `record_id` — **required.** The record's internal id, e.g. `bill_id` from [NetSuite Create Vendor Bill](/docs/tools/netsuite_create_vendor_bill).
* `file_url` — the file to upload: a task file's storage URL or any HTTPS URL. Required unless `file_id` is given.
* `folder_id` — internal id of the File Cabinet folder to upload into. Required unless `file_id` is given; usually pinned on the configured tool.
* `file_name` — name to store the file under, with its extension (NetSuite derives the file type from it). Defaults to the file name in `file_url`. The tool adds `_` and the first 8 hex characters of the content's SHA-256 before the extension (`INV-1042.pdf` → `INV-1042_84d89877.pdf`), so the same file always gets the same name.
* `file_id` — internal id of a file already in the File Cabinet. When set, nothing is downloaded or uploaded; that file is attached. Use it to retry only the attach after an upload succeeded.
* `dry_run` — configuration and testing only (hidden from the agent). `true` sends nothing to NetSuite and returns the requests instead (see Output). Default `false`.

## Output

Success: `tool_name`, `status: "attached"`, `file_id`, `file_name`, `folder_id`, `size_bytes`, `uploaded` (`false` when `file_id` was given), `reused_upload` (`true` when an earlier attempt's upload was found and attached instead of uploading again), `record_type` (the SOAP name), `record_id`, `attach_status: "attached"`, `file_link` (the file's File Cabinet page), `record_link` (for every transaction type; omitted for vendor, customer, employee and contact records), `completed_at`.

Dry run: `status: "dry_run"`, `dry_run: true`, `requests[]` — each with `method`, `url`, `headers` and the SOAP envelope as `body` — and `notes`. In the envelope the consumer key, token, nonce, timestamp and signature read `[REDACTED]`, and the file content is replaced by `[base64 of N bytes omitted]`. The attach request names the file as `{file_id returned by the upload}` unless `file_id` was given. The task file itself is still downloaded, to check that it exists and fits.

## Limits and side effects

* Two SOAP calls: `add` (creates the file in the folder) then `attach`. With `file_id`, only `attach`.
* Files up to **10 MB** (NetSuite's web-services limit for inline content).
* If the upload fails — including NetSuite refusing a name already in the folder — the tool looks the hashed name up in the folder (one read-only SuiteQL query). If an earlier attempt stored the file, that file is attached and nothing is uploaded twice. Because the name carries the content hash, a match is the same bytes.
* Never deletes or replaces files, and never edits the record beyond the attachment.
* Logs record type, record id, file id and size — never the file content or name.

## Expected errors

* `NetSuite integration not configured…`, missing consumer pair, invalid account id — configuration.

* `validation error: …` — unsupported `record_type`, a non-numeric id, no `file_url` / `folder_id`, or a file name with a path in it.

* `the file is larger than NetSuite's 10 MB web-services upload limit` / `the file at file_url is empty` — nothing uploaded.

* `NetSuite refused the file upload: … INVALID_LOGIN_ATTEMPT …` — usually the role lacks **SOAP Web Services**, or the token is for another account.

* `Attaching file 555 to vendorBill 9001 failed: … The file was uploaded (id 555); to retry only the attach, call again with file_id=555.` — the upload stuck, the attach did not.

* `The file upload failed: … NetSuite may still have stored it, and checking folder … also failed` — the tool cannot tell whether the upload landed; look in the folder before calling again.

SOAP faults are classified by fault type: invalid credentials, missing permission and similar are final; request-limit, concurrency and unexpected-error faults are retried. Configuration, validation, size errors, NetSuite refusals and any attach failure after an upload are limitations (`status: "limitation"`), handed straight back to the agent — retrying the whole call would upload the file again. Network errors and NetSuite throttling during the upload are ordinary errors and are retried.


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