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

# Oracle NetSuite (SuiteTalk REST)

> Client-mode REST API connector for a curated NetSuite SuiteTalk slice: inventoryItem, inventoryadjustment, workOrder, workOrderCompletion transform, and SuiteQL

Technical Preview

## Overview

A client-mode connector for a **curated inventory and manufacturing** slice of [NetSuite SuiteTalk REST Web Services](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/book_1559132836.html) under `/services/rest` (record/v1 + query/v1):

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| GET inventoryItem | `record/v1/inventoryItem/{id}` | Inventory item by internal ID (`expandSubResources=true`) |
| POST inventoryAdjustment | `record/v1/inventoryadjustment` | Official record ID is lowercase `inventoryadjustment` |
| GET workOrder | `record/v1/workOrder/{id}` | Work order by internal ID |
| POST workOrderCompletion | `record/v1/workOrder/{id}/!transform/workOrderCompletion` | Official create path is a WIP transform (not a bare POST collection) |
| POST suiteql query | `query/v1/suiteql` | Requires header `Prefer: transient` |

`BASE_ADDRESS` is the SuiteTalk REST root (`https://{account}.suitetalk.api.netsuite.com/services/rest`). Topics use `erp/netsuite/<object>/<verb>`.

> [!NOTE]
>
> NetSuite REST APIs require a real account ID and an OAuth 2.0 Bearer token (or TBA). This template has not been verified against a live account. Prefer Hub secrets for tokens. Pull per-record OpenAPI with `GET .../record/v1/metadata-catalog/{recordType}` and `Accept: application/swagger+json`.

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — Oracle NetSuite SuiteTalk REST (curated inventory / work order / SuiteQL slice)
# Auth: Bearer {value.json.access_token} (OAuth 2.0 M2M or auth code)
# BASE_ADDRESS: https://YOUR_ACCOUNT.suitetalk.api.netsuite.com/services/rest

DEFINE ROUTE NetSuiteRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://YOUR_ACCOUNT.suitetalk.api.netsuite.com/services/rest"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Getinventoryitem
        WITH SOURCE_TOPIC "erp/netsuite/inventory-item/get"
        WITH DESTINATION_TOPIC "erp/netsuite/inventory-item/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/record/v1/inventoryItem/{value.json.id}?expandSubResources=true"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT Createinventoryadjustment
        WITH SOURCE_TOPIC "erp/netsuite/inventory-adjustment/create"
        WITH DESTINATION_TOPIC "erp/netsuite/inventory-adjustment/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/record/v1/inventoryadjustment"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.access_token}"
        WITH BODY "{payload}"
    ADD EVENT Getworkorder
        WITH SOURCE_TOPIC "erp/netsuite/work-order/get"
        WITH DESTINATION_TOPIC "erp/netsuite/work-order/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/record/v1/workOrder/{value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT Createworkordercompletion
        WITH SOURCE_TOPIC "erp/netsuite/work-order-completion/create"
        WITH DESTINATION_TOPIC "erp/netsuite/work-order-completion/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/record/v1/workOrder/{value.json.id}/!transform/workOrderCompletion"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.access_token}"
        WITH BODY "{payload}"
    ADD EVENT Executesuiteql
        WITH SOURCE_TOPIC "erp/netsuite/suiteql/query"
        WITH DESTINATION_TOPIC "erp/netsuite/suiteql/query/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/query/v1/suiteql?limit={value.json.limit}&offset={value.json.offset}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Prefer" "transient"
            ADD "Authorization" "Bearer {value.json.access_token}"
        WITH BODY "{payload}"

```

## Events

| Event | Method | Endpoint | Request topic | Response topic |
| - | - | - | - | - |
| Getinventoryitem | GET | `/record/v1/inventoryItem/{id}` | `erp/netsuite/inventory-item/get` | `erp/netsuite/inventory-item/get/response` |
| Createinventoryadjustment | POST | `/record/v1/inventoryadjustment` | `erp/netsuite/inventory-adjustment/create` | `erp/netsuite/inventory-adjustment/create/response` |
| Getworkorder | GET | `/record/v1/workOrder/{id}` | `erp/netsuite/work-order/get` | `erp/netsuite/work-order/get/response` |
| Createworkordercompletion | POST | `/record/v1/workOrder/{id}/!transform/workOrderCompletion` | `erp/netsuite/work-order-completion/create` | `erp/netsuite/work-order-completion/create/response` |
| Executesuiteql | POST | `/query/v1/suiteql` | `erp/netsuite/suiteql/query` | `erp/netsuite/suiteql/query/response` |

## Auth

**Option A — OAuth 2.0 Bearer (default in the template):**

Pass the access token on the MQTT request payload:

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{"access_token": "YOUR_NETSUITE_ACCESS_TOKEN", "id": "20"}
```

The connector sends `Authorization: Bearer {value.json.access_token}`. Obtain the token via OAuth 2.0 client credentials (M2M) or authorization code against `https://{account}.suitetalk.api.netsuite.com/services/rest/auth/oauth2/v1/token`.

**Option B — Token-Based Auth (OAuth 1.0a):**

Supported by NetSuite REST Web Services but not modeled in this client-mode header set. Use a broker-side TBA signer or an upstream action if you need TBA.

Prefer Hub secrets / `GET SECRET`. Never commit real credentials.

## Example MQTT payloads

**GET inventory item**

Topic: `erp/netsuite/inventory-item/get`

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{"access_token": "YOUR_TOKEN", "id": "20"}
```

**POST inventory adjustment**

Topic: `erp/netsuite/inventory-adjustment/create`

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "access_token": "YOUR_TOKEN",
  "account": {"id": "1"},
  "adjLocation": {"id": "1"},
  "subsidiary": {"id": "1"},
  "inventory": {
    "items": [
      {
        "adjustQtyBy": 5.0,
        "item": {"id": "20"},
        "line": 1,
        "location": {"id": "1"}
      }
    ]
  }
}
```

**GET work order**

Topic: `erp/netsuite/work-order/get`

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{"access_token": "YOUR_TOKEN", "id": "4"}
```

**POST work order completion (transform)**

Topic: `erp/netsuite/work-order-completion/create`

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "access_token": "YOUR_TOKEN",
  "id": "4",
  "startOperation": {"refName": "10"},
  "endOperation": {"refName": "20"}
}
```

**POST SuiteQL**

Topic: `erp/netsuite/suiteql/query`

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "access_token": "YOUR_TOKEN",
  "limit": 10,
  "offset": 0,
  "q": "SELECT id, itemid FROM item WHERE itemtype = 'InvtPart' FETCH FIRST 10 ROWS ONLY"
}
```

The SuiteQL event already sends `Prefer: transient`. Body should include at least `{"q": "..."}` (optional `params` for bound parameters).

## Deploy notes

1. Replace `YOUR_ACCOUNT` in `BASE_ADDRESS`.
2. Deploy only `NetSuiteRestApi.lot` with `-addRoute` (no `ADD METADATA` in that file).
3. Use `hub-metadata.lot` + `icon.png` for Hub template listing (`WITH STATUS "beta"`).
4. Status stays **blocked** in the factory queue until a live authenticated HTTP smoke succeeds.

## References

* [NetSuite REST Web Services](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/book_1559132836.html)
* [Inventory Item](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/article_161522936052.html)
* [Inventory Adjustment](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_0817101055.html)
* [Work Order](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/article_47212826771.html)
* [Work Order Completion](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/article_94213635853.html)
* [Executing SuiteQL Queries Through REST Web Services](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_157909186990.html)
* [OAuth 2.0 Authorization Header Examples](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_158332610742.html)


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