How to set Rate limit for 2 requests per day for an inbound REST Table API

vivek72
Tera Guru

Hi,

For one of the inbound integration requirement, we need to restrict 3rd party for invoking a ServiceNow table API only 2 times per day.

I know OOB there is a feature to set rate limit for  no. of requests per hour, but we need something similar to set no. of request per day.

Please let me know if anyone has done if before.

 

1 ACCEPTED SOLUTION

Cheikh Ahmadou
Tera Guru

Never has done it before, but why not 

 

Scripted REST API + Custom Counter Table with 

  • Fields:

    • integration_id or api_key

    • date (type: Date)

    • counter (Integer)

     

  • In your Scripted REST API:

    Each time the 3rd-party calls your endpoint:

    • Check if there’s already an entry for today.

    • If yes and counter >= 2, reject the request (return HTTP 429 or custom message).

    • Otherwise, increment the counter and allow the request to proceed.

     

 

Reset Behavior

You’ll want to reset the counter daily. Since the date is stored as a separate field, each day a new record is created. You can also run a scheduled job to clean up old entries after 30 days.

 

 

View solution in original post

4 REPLIES 4

Cheikh Ahmadou
Tera Guru

Never has done it before, but why not 

 

Scripted REST API + Custom Counter Table with 

  • Fields:

    • integration_id or api_key

    • date (type: Date)

    • counter (Integer)

     

  • In your Scripted REST API:

    Each time the 3rd-party calls your endpoint:

    • Check if there’s already an entry for today.

    • If yes and counter >= 2, reject the request (return HTTP 429 or custom message).

    • Otherwise, increment the counter and allow the request to proceed.

     

 

Reset Behavior

You’ll want to reset the counter daily. Since the date is stored as a separate field, each day a new record is created. You can also run a scheduled job to clean up old entries after 30 days.

 

 

vivek72
Tera Guru

ok, thanks @Cheikh Ahmadou  for your response. 

So it requires a complete customization, and nothing is available OOO.

I would not say it is required but i don't have an OOO in mind.

Ankur Bawiskar
Tera Patron
Tera Patron

@vivek72 

yes it's based on hours and not on request per day

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader