While developers often focus on building RESTlet-based integrations for NetSuite due to their flexibility and ease of use, many overlook a critical yet less-discussed topic: governance and throttling limits. These limits can significantly affect the stability and performance of your integration if not handled properly.
What Are RESTlets?
RESTlets are custom scripts deployed on the NetSuite platform that expose APIs to interact with NetSuite data. They’re written using SuiteScript and provide more control than standard REST or SOAP web services.
But unlike public REST APIs, RESTlets operate within the same governance and execution rules as all SuiteScripts.
The Governance Challenge
Each RESTlet call consumes governance units, which are part of NetSuite’s resource management system. If your script exceeds the allowed units per execution, it will be terminated—causing data sync failures, timeouts, and even partial data processing.
- Standard RESTlet calls can cost between 1 to 10 governance units depending on the operation.
- Mass operations, like loading and saving multiple records, can consume 100+ units in one go.
- Each user and script context has a governance limit per script execution (e.g., 1,000 units for User Event scripts).
Throttling: The Hidden Risk
NetSuite throttles concurrent RESTlet requests, especially if they come too frequently from the same integration. If your system sends too many calls within a short period:
- You might get HTTP status
429 Too Many Requests - You may face delayed responses, impacting real-time integration
- NetSuite might temporarily block further calls, depending on volume
Best Practices to Handle This
- Batch Requests on Client Side: Group records before sending them to NetSuite. For example, send 10 invoices in one call rather than 10 separate calls.
- Use SuiteQL Inside RESTlets: Instead of multiple record loads, use SuiteQL queries to retrieve or manipulate data in bulk.
- Implement Retry Logic: Handle
429and similar error responses with exponential backoff and retries. - Monitor Governance Usage: Include log statements to track
runtime.getCurrentScript().getRemainingUsage()within your RESTlet. - Use Queued or Scheduled Scripts: For large imports/exports, RESTlets can trigger scheduled scripts that handle heavy lifting without exceeding limits.