Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The NetSuite Pro

The NetSuite Pro Logo The NetSuite Pro Logo

The NetSuite Pro Navigation

  • Home
  • About Us
  • Tutorials
    • NetSuite Scripting
    • NetSuite Customization
    • NetSuite Integration
    • NetSuite Advanced PDF Templates
    • NetSuite Reporting & Analytics Guide
    • Real-World NetSuite Examples
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Home
  • About Us
  • Tutorials
    • NetSuite Scripting
    • NetSuite Customization
    • NetSuite Integration
    • NetSuite Advanced PDF Templates
    • NetSuite Reporting & Analytics Guide
    • Real-World NetSuite Examples
  • Blog
  • Contact Us
Home/ NetSuite RESTlet & REST API Tutorials/How to Create a RESTlet in NetSuite: Step-by-Step Tutorial

How to Create a RESTlet in NetSuite: Step-by-Step Tutorial

A RESTlet is a server-side SuiteScript that exposes a custom REST-based web service in NetSuite. Unlike standard REST endpoints, RESTlets give you full control over the logic, authentication, and data returned β€” making them the most flexible integration option in NetSuite.

In this tutorial, you’ll learn exactly how to create, deploy, and test a RESTlet from scratch using SuiteScript 2.1.

What Is a RESTlet?

A RESTlet is a SuiteScript script type that maps to HTTP methods:

  • GET β€” retrieve data
  • POST β€” create records
  • PUT β€” update records
  • DELETE β€” remove records

RESTlets are deployed as Script Deployments and accessible via a unique URL that external systems can call.

Prerequisites

Before creating a RESTlet, make sure you have:

  • A NetSuite account with SuiteScript permissions
  • Developer role or Administrator access
  • Basic knowledge of SuiteScript 2.1

Step 1: Write the RESTlet Script

Create a new file called restlet_example.js with the following code:

/**
 * @NApiVersion 2.1
 * @NScriptType Restlet
 */
define(['N/record', 'N/log'], function(record, log) {

  // GET β€” retrieve a customer by internal ID
  function doGet(params) {
    log.debug('GET called', params);
    var customerId = params.id;
    var customerRecord = record.load({
      type: record.Type.CUSTOMER,
      id: customerId
    });
    return {
      id: customerId,
      name: customerRecord.getValue('companyname'),
      email: customerRecord.getValue('email')
    };
  }

  // POST β€” create a new customer
  function doPost(body) {
    log.debug('POST called', body);
    var newCustomer = record.create({ type: record.Type.CUSTOMER });
    newCustomer.setValue('companyname', body.name);
    newCustomer.setValue('email', body.email);
    var newId = newCustomer.save();
    return { success: true, id: newId };
  }

  // PUT β€” update an existing customer
  function doPut(body) {
    log.debug('PUT called', body);
    var customerRecord = record.load({
      type: record.Type.CUSTOMER,
      id: body.id
    });
    customerRecord.setValue('companyname', body.name);
    customerRecord.save();
    return { success: true, id: body.id };
  }

  return { get: doGet, post: doPost, put: doPut };
});

Step 2: Upload the Script to NetSuite

  1. Go to Documents > Files > SuiteScripts in NetSuite.
  2. Upload your restlet_example.js file.

Step 3: Create a Script Record

  1. Go to Customization > Scripting > Scripts > New.
  2. Set the Script Type to RESTlet.
  3. Select your uploaded script file.
  4. Map the functions: GET Function β†’ doGet, POST Function β†’ doPost, PUT Function β†’ doPut.
  5. Click Save.

Step 4: Deploy the Script

  1. On the Script record, go to the Deployments tab.
  2. Click New Deployment.
  3. Set the Status to Released.
  4. Under Audience, set the roles that can access this RESTlet.
  5. Click Save. Copy the External URL β€” this is your RESTlet endpoint.

Step 5: Test the RESTlet

Use Postman (or any REST client) to test your RESTlet:

  • Method: GET
  • URL: Your External URL from the deployment
  • Auth: Token-Based Authentication (TBA) or OAuth 2.0
  • Params: id=1 (a valid customer internal ID)

A successful response will return a JSON object with the customer data.

Next Steps

Now that your RESTlet is live, you can:

  • Connect to it from external systems β€” see Calling a NetSuite RESTlet from External Systems.
  • Secure it with Token-Based Authentication β€” see Token-Based Authentication (TBA) in NetSuite.
  • Use OAuth 2.0 for modern auth flows β€” see OAuth 2.0 in NetSuite.
Share
  • Facebook

Sidebar

Ask A Question

Stats

  • Questions 6
  • Answers 6
  • Best Answers 0
  • Users 5
  • Popular
  • Answers
  • Rocky

    Issue in running a client script in NetSuite SuiteScript 2.0 ...

    • 1 Answer
  • admin

    How can I send an email with an attachment in ...

    • 1 Answer
  • admin

    How do I avoid SSS_USAGE_LIMIT_EXCEEDED in a Map/Reduce script?

    • 1 Answer
  • admin
    admin added an answer The issue is usually caused by following Wrong script file… September 14, 2025 at 10:33 pm
  • admin
    admin added an answer Steps to send an Invoice PDF by email: define(['N/email', 'N/render',… August 28, 2025 at 3:05 am
  • admin
    admin added an answer This error means your script hit NetSuite’s governance usage limit… August 28, 2025 at 3:02 am

Top Members

Rocky

Rocky

  • 1 Question
  • 22 Points
Begginer
Sophie1022

Sophie1022

  • 0 Questions
  • 20 Points
Begginer
jmargoli

jmargoli

  • 0 Questions
  • 20 Points
Begginer

Trending Tags

clientscript netsuite scripting suitescript
  • NetSuite Certifications in 2026: Complete Guide for Admins and DevelopersMay 13, 2026
  • N/runtime Module in NetSuite: Complete Guide to Script Context, User Info & Environment in SuiteScriptMay 12, 2026
  • N/email Module in NetSuite: Complete Guide to Sending Emails in SuiteScriptMay 10, 2026
  • Using AI to Write and Debug SuiteScript: A Complete Practical GuideMay 9, 2026
  • Top AI Prompts for NetSuite: Real-World Examples for Admins & DevelopersMay 8, 2026
  • Setting Up Claude AI with NetSuite Using MCP: A Step-by-Step Configuration GuideMay 7, 2026
  • How to Use Claude AI to Simplify Your NetSuite WorkflowMay 7, 2026
  • What No One Tells You About Being a NetSuite Consultant DeveloperMay 7, 2026
  • N/search Module in NetSuite: Complete Guide to Searching Records in SuiteScriptMay 7, 2026
  • N/record Module in NetSuite: Complete Guide to Creating, Loading, and Editing Records in SuiteScriptMay 6, 2026

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Menu

  • Home
  • About Us
  • Tutorials
    • NetSuite Scripting
    • NetSuite Customization
    • NetSuite Integration
    • NetSuite Advanced PDF Templates
    • NetSuite Reporting & Analytics Guide
    • Real-World NetSuite Examples
  • Blog
  • Contact Us

Quick Links

  • NetSuite Scripting
  • NetSuite Customization
  • NetSuite Advanced PDF Template
  • NetSuite Integration
  • NetSuite Reporting & Analytics

Subscribe for NetSuite Insights....

© 2025 The NetSuite Pro. All Rights Reserved