NetSuite RESTlets Authenticate an Element Instance

You can authenticate with NetSuite to create your own instance of the NetSuite RESTlets element through the UI or through APIs. Once authenticated, you can use the element instance to access the different functionalities offered by the NetSuite platform. 

Authenticate Through the UI

Use the UI to authenticate with NetSuite and create an element instance as described in Authenticate an Element Instance (UI). In addition to the base authentication parameters, you will need the deployment ID and script ID. Refer to the table of Parameters below for more information.

After successfully authenticating, we give you several options for next steps. Make requests using the API docs associated with the instance, map the instance to a virtual data resource, or use it in a formula template.

Authenticate Through API

Authenticating through API is similar to authenticating via the UI. Instead of clicking and typing through a series of buttons, text boxes, and menus, you will instead send API calls to our /instances endpoint. The end result is the same, though: an authenticated element instance with a token and id for future API calls.

If you are configuring events, see the Events section.

To create an element instance:

  1. Construct a JSON body based on the Custom authentication type. See Parameters for detailed descriptions.

    Custom Authentication
    {
       "element": {
         "key": "netsuiterestlets"
       },
       "configuration": { 
          "account-id": "xxxxxxxxxxxxxxxxx",
          "consumer_key": "xxxxxxxxxxxxxxxxxxxxxxxx",
          "consumer_secret": "xxxxxxxxxxxxxxxxx",
          "deploymentId":"xx"
    },
       "scriptId":"xxx",
       "token-id":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
       "token-secret":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "tags": [
         "<Add_Your_Tag>"
       ],
       "name": "<INSTANCE_NAME>"
     }

    Call the following, including the JSON body you constructed in the previous step:

    Note: Make sure that you include your User and Organization keys in the header. For more information, see Authorization Headers, Organization Secret, and User Secret.
  2. Locate the token and id in the response and save them for all future requests using the element instance.

Example cURL

curl -X POST \
  https://api.cloud-elements.com/elements/api-v2/instances \
  -H 'authorization: User <USER_SECRET>, Organization <ORGANIZATION_SECRET>' \
  -H 'content-type: application/json' \
  -d '{
  "element": {
    "key": "netsuiterestlets"
  },
  "configuration": {
    "account-id": "xxxxxxxxxx",
    "consumer_key": "consumer_key_1234567",
    "consumer_secret": "secret_1234567",
    "token_id": "token_1234",
    "token_secret": "token_secret_1234",
    "deploymentId":"xxxxxx",
    "scriptId":"xxxxx",
    "event.notification.enabled": false
  },
  "tags": [
    "xxxxxxxxx"
  ],
  "name": "NetSuite Instance 1"
}'

Parameters

See NetSuite RESTlets API Provider Setup for information on how to obtain authentication parameters.

Note: Event related parameters are described in Events.
ParameterDescriptionData Type
'key'The element key.
netsuiterestlets
string
Name
name
The name for the element instance created during authentication.Body
Account ID
account-id
the NetSuite account IDstring
Consumer Key
consumer_key
For Custom authentication, the consumer key of a token-based NetSuite integration.string
Consumer Secret
consumer_secret
For Custom authentication, the consumer secret of a token-based NetSuite integration.string
Access Token ID
token_id
For Custom authentication, the token ID of a token-based NetSuite integration.string
Access Token Secret
token_secret
For Custom authentication, the token secret of a token-based NetSuite integration.string
Deployment ID
deploymentId
The deployment ID from the deployed Netsuite record or suitescipt.string
Script ID
scriptId
The script ID of the deployed Netsuite record or suitescript.string

Example Response

In this example, the authenticated element instance ID is 12345 and token starts with ABC/D.... Your values will be different. Make sure that you save the id and token for future requests.

{
    "id": 12345,
    "name": "NetSuite Instance 1",
    "token": "ABC/D/efgHIJK1234lmnopQRS+1tuVWx+yz98765",
    "element": {
        "id": xxx,
        "name": "NetSuite Instance 1",
        "key": "netsuiterestlets",
        "description": "NetSuite Restlets",
        "active": true,
        "deleted": false,
        "typeOauth": true,
        "trialAccount": false,
        "configDescription": "NetSuite Restlets",
        "signupURL": ""
    },
    "provisionInteractions": [],
    "valid": true,
    "eventsEnabled": true,
    "disabled": false,
    "maxCacheSize": 0,
    "cacheTimeToLive": 0,
    "cachingEnabled": false
}