# Operations (sample payloads)

## Main operations

### Create record

Create a new record instance.
**Sample Input**

```json
{
    "record_type": "customer",
    "writable_record_fields": [
        \{
            "key": "companyname",
            "value": "Acme Corporation"
        \},
        \{
            "key": "email",
            "value": "info@acmecorp.com"
        \},
        \{
            "key": "phone",
            "value": "555-123-4567"
        \},
        \{
            "key": "subsidiary",
            "value": 1
        \}
    ],
    "replace": [
        "addressbook"
    ]
}
```

**Sample Output**

```json
\{
    "url": "https://1234567.app.netsuite.com/app/common/entity/custjob.nl?id=87654321",
    "record_id": "87654321"
\}
```

### Delete record

Delete a record instance.
**Sample Input**

```json
\{
    "record_type": "customer",
    "record_id": 12345
\}
```

**Sample Output**

### Execute SuiteQL (advanced query)

SuiteQL is a query language based on the SQL database query language. SuiteQL provides advanced dynamic query capabilities that can be used to access NetSuite records.
**Sample Input**

```json
\{
    "raw_query": "SELECT id, entityid, companyname FROM customer WHERE companyname LIKE 'A%' ORDER BY companyname",
    "limit": 10,
    "offset": 0
\}
```

**Sample Output**

```json
{
    "links": [
        \{
            "rel": "self",
            "href": "/services/rest/query/v1/suiteql"
        \}
    ],
    "count": 3,
    "hasMore": false,
    "items": [
        \{
            "links": [],
            "id": "1234",
            "entityid": "CUST001",
            "companyname": "Acme Corporation"
        \},
        \{
            "links": [],
            "id": "5678",
            "entityid": "CUST002",
            "companyname": "Alpha Industries"
        \},
        \{
            "links": [],
            "id": "9012",
            "entityid": "CUST003",
            "companyname": "Apex Solutions"
        \}
    ],
    "offset": 0,
    "totalResults": 3
}
```

### Filter Records (advanced search query)

Retrieve a list of records. Execute a raw search query to extract data from NetSuite.
**Sample Input**

```json
\{
    "record_type": "customer",
    "raw_query": "SELECT id, companyName, email, phone FROM customer WHERE lastModifiedDate > '2023-01-01T00:00:00' AND isInactive = 'F' ORDER BY companyName ASC",
    "limit": 50,
    "offset": 0
\}
```

**Sample Output**

```json
{
    "links": [
        \{
            "rel": "self",
            "href": "/services/rest/record/v1/customer?q=SELECT id, companyName, email, phone FROM customer WHERE lastModifiedDate > '2023-01-01T00:00:00' AND isInactive = 'F' ORDER BY companyName ASC&limit=50&offset=0"
        \},
        \{
            "rel": "next",
            "href": "/services/rest/record/v1/customer?q=SELECT id, companyName, email, phone FROM customer WHERE lastModifiedDate > '2023-01-01T00:00:00' AND isInactive = 'F' ORDER BY companyName ASC&limit=50&offset=50"
        \}
    ],
    "count": 50,
    "hasMore": true,
    "items": [
        {
            "links": [
                \{
                    "rel": "self",
                    "href": "/services/rest/record/v1/customer/12345"
                \}
            ],
            "id": "12345",
            "companyName": "Acme Corporation",
            "email": "info@acme.com",
            "phone": "555-123-4567"
        },
        {
            "links": [
                \{
                    "rel": "self",
                    "href": "/services/rest/record/v1/customer/12346"
                \}
            ],
            "id": "12346",
            "companyName": "Beta Industries",
            "email": "contact@betaindustries.com",
            "phone": "555-987-6543"
        }
    ],
    "offset": 0,
    "totalResults": 150
}
```

### Find records

Retrieve a list of records.
**Sample Input**

```json
{
    "record_type": "customer",
    "conditions": [
        \{
            "field": "companyName",
            "operator": "CONTAIN",
            "value": "Tech"
        \},
        \{
            "field": "dateCreated",
            "operator": "AFTER",
            "value": "2023-01-01"
        \}
    ],
    "conditions_matching": "Match all conditions",
    "limit": 50,
    "offset": 0
}
```

**Sample Output**

```json
{
    "links": [
        \{
            "rel": "self",
            "href": "https://1234567.suitetalk.api.netsuite.com/services/rest/record/v1/customer"
        \}
    ],
    "count": 2,
    "hasMore": false,
    "items": [
        {
            "links": [
                \{
                    "rel": "self",
                    "href": "https://1234567.suitetalk.api.netsuite.com/services/rest/record/v1/customer/12345"
                \}
            ],
            "id": "12345"
        },
        {
            "links": [
                \{
                    "rel": "self",
                    "href": "https://1234567.suitetalk.api.netsuite.com/services/rest/record/v1/customer/67890"
                \}
            ],
            "id": "67890"
        }
    ],
    "offset": 0,
    "totalResults": 2
}
```

### Get record

Retrieve a record.
**Sample Input**

```json
\{
    "record_type": "employee",
    "record_id": 12345,
    "expand_sub_resources": true
\}
```

**Sample Output**

```json
{
    "links": [
        \{
            "rel": "self",
            "href": "/app/accounting/employees/12345"
        \}
    ],
    "addressbook": {
        "links": [
            \{
                "rel": "addresses",
                "href": "/app/accounting/employees/12345/addresses"
            \}
        ]
    },
    "autoName": false,
    "billPay": true,
    "btemplate": "EMPLOYEE",
    "currency": {
        "links": [
            \{
                "rel": "currency",
                "href": "/app/accounting/currency/1"
            \}
        ],
        "id": "1",
        "refName": "USD"
    },
    "custentity2": false,
    "custentity_2663_payment_method": true,
    "dateCreated": "2023-05-15T09:30:00Z",
    "email": "john.doe@example.com",
    "entityId": "JDoe",
    "externalId": "EMP12345",
    "firstName": "John",
    "lastName": "Doe",
    "gender": "MALE",
    "giveAccess": true,
    "hiredate": "2023-01-01",
    "i9verified": true,
    "id": "12345",
    "initials": "JD",
    "isinactive": false,
    "isJobResource": true,
    "issalesrep": true,
    "issupportrep": false,
    "lastModifiedDate": "2023-05-20T14:45:00Z",
    "purchaseorderlimit": 5000,
    "requirePwdChange": false,
    "sendEmail": true,
    "subsidiary": {
        "links": [
            \{
                "rel": "subsidiary",
                "href": "/app/accounting/subsidiary/1"
            \}
        ],
        "id": "1",
        "refName": "Parent Company"
    },
    "terminationbydeath": false,
    "unsubscribe": "F",
    "workCalendar": {
        "links": [
            \{
                "rel": "workCalendar",
                "href": "/app/accounting/workcalendar/1"
            \}
        ],
        "id": "1",
        "refName": "Standard Work Calendar"
    }
}
```

### List field options

List options of a record field.
**Sample Input**

```json
\{
    "record_type": "customer",
    "field": "entitystatus"
\}
```

**Sample Output**

```json
\{
    "result": [
        "CUSTOMER-Closed Won",
        "CUSTOMER-Contacted",
        "CUSTOMER-Qualified",
        "CUSTOMER-Prospect",
        "CUSTOMER-Lead"
    ]
\}
```

### List record fields

List all the available fields for a given record type.
**Sample Input**

```json
{
    "record_type": "customer"
}
```

**Sample Output**

```json
{
    "type": "object",
    "properties": {
        "entityId": \{
            "type": "string",
            "title": "Entity ID"
        \},
        "companyName": \{
            "type": "string",
            "title": "Company Name"
        \},
        "email": \{
            "type": "string",
            "title": "Email"
        \},
        "phone": \{
            "type": "string",
            "title": "Phone"
        \},
        "addressbook": {
            "type": "array",
            "title": "Address Book",
            "items": {
                "type": "object",
                "properties": {
                    "addr1": \{
                        "type": "string",
                        "title": "Address Line 1"
                    \},
                    "addr2": \{
                        "type": "string",
                        "title": "Address Line 2"
                    \},
                    "city": \{
                        "type": "string",
                        "title": "City"
                    \},
                    "state": \{
                        "type": "string",
                        "title": "State"
                    \},
                    "zip": \{
                        "type": "string",
                        "title": "ZIP Code"
                    \},
                    "country": \{
                        "type": "string",
                        "title": "Country"
                    \}
                }
            }
        },
        "subsidiary": {
            "type": "object",
            "title": "Subsidiary",
            "properties": {
                "internalId": \{
                    "type": "string",
                    "title": "Internal ID"
                \},
                "name": \{
                    "type": "string",
                    "title": "Name"
                \}
            }
        },
        "salesRep": {
            "type": "object",
            "title": "Sales Representative",
            "properties": {
                "internalId": \{
                    "type": "string",
                    "title": "Internal ID"
                \},
                "name": \{
                    "type": "string",
                    "title": "Name"
                \}
            }
        },
        "creditLimit": \{
            "type": "number",
            "title": "Credit Limit"
        \},
        "balance": \{
            "type": "number",
            "title": "Balance"
        \},
        "dateCreated": \{
            "type": "string",
            "format": "date-time",
            "title": "Date Created"
        \},
        "lastModifiedDate": \{
            "type": "string",
            "format": "date-time",
            "title": "Last Modified Date"
        \}
    }
}
```

### List record types

Retrieve all record types.
**Sample Input**

```json
\{
    "select": [
        "customer",
        "invoice",
        "salesorder"
    ]
\}
```

**Sample Output**

```json
{
    "items": [
        {
            "name": "customer",
            "links": [
                \{
                    "rel": "self",
                    "href": "/record/v1/customer",
                    "mediaType": "application/json"
                \}
            ]
        },
        {
            "name": "invoice",
            "links": [
                \{
                    "rel": "self",
                    "href": "/record/v1/invoice",
                    "mediaType": "application/json"
                \}
            ]
        },
        {
            "name": "salesorder",
            "links": [
                \{
                    "rel": "self",
                    "href": "/record/v1/salesorder",
                    "mediaType": "application/json"
                \}
            ]
        }
    ]
}
```

### Raw HTTP request (advanced)

Perform a raw HTTP request with some pre-configuration and processing by the connector, such as authentication.
**Sample Input**

```json
{
    "method": "GET",
    "url": {
        "endpoint": "/customers"
    },
    "headers": [
        \{
            "key": "Accept",
            "value": "application/json"
        \}
    ],
    "query_parameters": [
        \{
            "key": "limit",
            "value": "10"
        \},
        \{
            "key": "offset",
            "value": "0"
        \}
    ],
    "body": {
        "none": null
    },
    "include_raw_body": false,
    "parse_response": "true"
}
```

**Sample Output**

```json
{
    "response": {
        "status_code": 200,
        "headers": \{
            "Content-Type": "application/json",
            "X-RateLimit-Limit": "5000",
            "X-RateLimit-Remaining": "4999"
        \},
        "body": {
            "customers": [
                \{
                    "id": "1001",
                    "name": "Acme Corporation",
                    "email": "info@acme.com",
                    "phone": "+1-555-123-4567"
                \},
                \{
                    "id": "1002",
                    "name": "Global Industries",
                    "email": "contact@globalindustries.com",
                    "phone": "+1-555-987-6543"
                \}
            ],
            "total_count": 2,
            "limit": 10,
            "offset": 0
        }
    }
}
```

### Transform record

Transform a record from one type into an another, using data from an existing record.
**Sample Input**

```json
{
    "record_type": "customer",
    "record_id_to_transform": 12345,
    "record_type_to_transform_in": "lead",
    "writable_record_fields": [
        \{
            "key": "companyname",
            "value": "Acme Corporation"
        \},
        \{
            "key": "email",
            "value": "info@acmecorp.com"
        \},
        \{
            "key": "phone",
            "value": "555-123-4567"
        \}
    ]
}
```

**Sample Output**

```json
{
    "success": true
}
```

### Update record

Update a record instance.
**Sample Input**

```json
{
    "record_type": "customer",
    "record_id": 12345,
    "writable_record_fields": [
        \{
            "key": "companyname",
            "value": "Acme Corporation"
        \},
        \{
            "key": "phone",
            "value": "555-123-4567"
        \},
        \{
            "key": "email",
            "value": "info@acmecorp.com"
        \}
    ],
    "replace": [
        "addressbook"
    ]
}
```

**Sample Output**

```json
{
    "success": true
}
```

### Upsert record

Upsert a record instance.
**Sample Input**

```json
{
    "record_type": "customer",
    "external_id": "CUST123",
    "writable_record_fields": [
        \{
            "key": "companyname",
            "value": "Acme Corporation"
        \},
        \{
            "key": "email",
            "value": "info@acmecorp.com"
        \},
        \{
            "key": "phone",
            "value": "555-123-4567"
        \},
        \{
            "key": "custentity_customer_type",
            "value": "Corporate"
        \}
    ]
}
```

**Sample Output**

```json
{
    "success": true
}
```

## DDL operations

### Find records (DDL)

> **Warning:** Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping

Retrieve a list of Record IDs associated with the selected Record type.
**Sample Input**

```json
{
    "record_type": "customer"
}
```

**Sample Output**

### Get field for replace (DDL)

> **Warning:** Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping

Retrieve a list of sublist names.
**Sample Input**

```json
{
    "record_type": "salesorder"
}
```

**Sample Output**

```json
{
    "result": \{
        "text": "Shipping Address",
        "value": "shippingaddress"
    \}
}
```

### List field options (DDL)

> **Warning:** Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping

List only fields that have options, for a given record type.
**Sample Input**
**Sample Output**

```json
{
    "result": [
        \{
            "text": "Customer Category",
            "value": "category"
        \},
        \{
            "text": "Customer Status",
            "value": "status"
        \},
        \{
            "text": "Sales Rep",
            "value": "salesrep"
        \},
        \{
            "text": "Subsidiary",
            "value": "subsidiary"
        \},
        \{
            "text": "Payment Terms",
            "value": "terms"
        \}
    ]
}
```

### List record fields 1st level (DDL)

> **Warning:** Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping

Retrieve a list of fields associated with the selected Record type.
**Sample Input**

```json
{
    "record_type": "customer"
}
```

**Sample Output**

```json
{
    "result": [
        \{
            "text": "Company Name",
            "value": "companyname"
        \},
        \{
            "text": "First Name",
            "value": "firstname"
        \},
        \{
            "text": "Last Name",
            "value": "lastname"
        \},
        \{
            "text": "Email",
            "value": "email"
        \},
        \{
            "text": "Phone",
            "value": "phone"
        \},
        \{
            "text": "Address",
            "value": "address"
        \},
        \{
            "text": "Customer Category",
            "value": "category"
        \},
        \{
            "text": "Sales Rep",
            "value": "salesrep"
        \},
        \{
            "text": "Credit Limit",
            "value": "creditlimit"
        \},
        \{
            "text": "Currency",
            "value": "currency"
        \}
    ]
}
```

### List record types (DDL)

> **Warning:** Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping

Retrieve a list of Record types.
**Sample Input**
**Sample Output**

```json
{
    "result": [
        \{
            "text": "Customer",
            "value": "customer"
        \},
        \{
            "text": "Sales Order",
            "value": "salesorder"
        \},
        \{
            "text": "Invoice",
            "value": "invoice"
        \},
        \{
            "text": "Item",
            "value": "item"
        \},
        \{
            "text": "Vendor",
            "value": "vendor"
        \}
    ]
}
```

### List record types to transform from (DDL)

> **Warning:** Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping

Retrieve a list of Record types that can be transformed into another record type.
**Sample Input**
**Sample Output**

### List record types to transform in (DDL)

> **Warning:** Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping

Retrieve a list of Record types you that you want transform another record type into.
**Sample Input**

```json
{
    "key_name": "customer"
}
```

**Sample Output**

```json
{
    "result": [
        \{
            "text": "Contact",
            "value": "contact"
        \},
        \{
            "text": "Lead",
            "value": "lead"
        \},
        \{
            "text": "Prospect",
            "value": "prospect"
        \},
        \{
            "text": "Vendor",
            "value": "vendor"
        \}
    ]
}
```

### List writable record fields (DDL)

> **Warning:** Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping

Retrieve a list of fields associated with the selected Record type.
**Sample Input**

```json
{
    "record_type": "customer"
}
```

**Sample Output**
