Skip to main content

Overview

The reset() method removes a rate limit from the database, resetting it to its initial state. The next request will start fresh with full capacity.

Method Signature

Parameters

RunMutationCtx
required
The context object from a mutation, including runMutation. Only the runMutation property is used, so you can destructure it: { runMutation }.
string
required
The name of the rate limit to reset. This will reset all shards for this rate limit name.
object
Optional arguments to specify which rate limit instance to reset.
string
If provided, resets only the rate limit for this specific key (e.g., a specific user). If not provided, resets the shared global rate limit for this name.

Return Type

Promise<void>
Returns a promise that resolves when the reset is complete. No value is returned.

When to Use

The reset() method is useful in several scenarios:
  • User upgrades - Reset limits when a user upgrades to a premium plan
  • Administrative actions - Manually clear rate limits for support purposes
  • Testing - Reset limits between test runs
  • Abuse mitigation - Clear limits after resolving a security incident
  • Forgiveness - Give users a fresh start after explaining the limits

Examples

Reset Global Rate Limit

Reset User-Specific Rate Limit

Reset on Subscription Upgrade

Admin Tool with Key Selection

Testing Utility

Side Effects

Resetting a rate limit immediately removes all tracking data for that limit. Any tokens that were consumed or reserved are forgotten, and the limit starts fresh with full capacity.
For fixed window rate limits without a specified start time, resetting will cause the new window to begin at a random time. The window alignment will be different after the reset.
The reset() method affects all shards for the specified rate limit name. With sharded rate limits, all shards are deleted and will be recreated on the next request.

Notes

Resetting a rate limit that doesn’t exist (never been used) is a no-op. It doesn’t throw an error.
Use reset() carefully in production. Resetting limits could allow users to bypass intended restrictions. Always verify authorization before allowing resets.