In ServiceNow, rate limits help manage the volume of incoming REST API requests and protect system performance by preventing excessive API traffic. Setting up rate limits ensures that your instance stays responsive and stable, even when external systems are making frequent calls. Let’s go through how to create and manage rate limits in ServiceNow.
1. Where to Create Rate Limits:
You define rate limits in the “System Web Services > REST > Rate Limit Rules” module.
2. Steps to Create a Rate Limit:
Here’s a step-by-step guide:
System Web Services
> REST
> Rate Limits
> Create New
.Table API
, Attachment API
, or your own scripted APIs).All users
, Single User
, User with role
3. Example:
Let’s say you want to limit requests to the Table API to 1000 requests per hour per user:
Table API
All users
1000
4. Handling Rate Limit Exceeding:
When an API client exceeds the rate limit, ServiceNow responds with an HTTP 429 Too Many Requests status code. You can customize error handling and response messages if needed.
5. Advanced Considerations:
1. Create a new Record [ System Web Services > REST > Rate Limit Rules ]
In image above, we have created a rate limite rule to limit POST calls to Case
table to 3 calls per hour. We have applied this rule to All users
for demo purpose, you should chose Single user
or User with role
with create a more granular rules.
2. Call this API four times We will now use curl to call this API 4 times.
That’s it folks.