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

# 🏢 NetSuite

> Connect NetSuite ERP/accounting data to Margin

Connect your NetSuite account to Margin using **Token-Based Authentication (TBA)**.

## 1. Prerequisites

Before you start, make sure you have:

1. NetSuite **Account ID**
2. A NetSuite admin user (or equivalent permissions)
3. A dedicated NetSuite integration user and role for Margin

## 2. Enable NetSuite Features

In NetSuite, go to **Setup > Company > Enable Features** and enable:

* **SOAP WEB SERVICES**
* **REST WEB SERVICES**
* **TOKEN-BASED AUTHENTICATION**

## 3. Create the Integration Record

1. Go to **Setup > Integration > Manage Integrations > New**.
2. Enable **TOKEN-BASED AUTHENTICATION**.
3. Disable:
   * **TBA: AUTHORIZATION FLOW**
   * **AUTHORIZATION CODE GRANT**
4. Save the integration.
5. Copy the generated:
   * **Consumer Key**
   * **Consumer Secret**

## 4. Create Role, User, and Access Token

1. Create a dedicated role in **Setup > Users/Roles > Manage Roles**.
2. Assign permissions based on the data you want Margin to sync.
3. Create a dedicated integration user and assign the role.
4. Create an access token for that user + role:
   * Admin path: **Setup > Users/Roles > Access Tokens > New**
   * Non-admin path: **Settings portlet > Manage Access Tokens > New My Access Token**
5. Copy:
   * **Token ID**
   * **Token Secret**

<Note>
  You can choose a broad role (faster onboarding) or a scoped role (least privilege). Margin works with either, as long as the role can authenticate with TBA, access web services, and read the records you want to sync.
</Note>

## 5. Connect NetSuite in Margin

In Margin's NetSuite connection form, enter:

| Field           | Value                       |
| :-------------- | :-------------------------- |
| Account ID      | NetSuite account ID         |
| Consumer Key    | Integration consumer key    |
| Consumer Secret | Integration consumer secret |
| Token ID        | Access token ID             |
| Token Secret    | Access token secret         |

Margin validates the credentials before enabling syncs.

## 6. Common Issues

* **401 / authentication error:** verify Account ID, Consumer Key/Secret, and Token ID/Secret.
* **Permission errors:** update the integration role to include missing record or web service permissions.
* **Sandbox mismatch:** recreate tokens in each NetSuite environment (tokens are environment-specific).

## 7. NetSuite References

* [NetSuite TBA overview](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/chapter_4247329078.html)
* [NetSuite TBA setup](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_1530099787.html)
* [NetSuite token lifecycle](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/bridgehead_4254081947.html)
* [NetSuite account ID reference](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_1498754928.html)

## Next Steps

Once NetSuite is connected, continue to data modelling.

<Card title="📊 Data Modelling" horizontal="true" href="/modelling/overview">
  Align ERP and accounting data with your event data for reconciled unit economics
</Card>
