---
title: "rate limit · RUAL Documentation"
description: "Counts calls per registered key and reports whether this one is still within the limit. Replaces the incr-key + ttl + condition chain every API blueprin…"
canonical: https://docs.rual.nl/block-types/redis/function_rate_limit
language: en
---

# rate limit

This block is part of the [`redis`](https://docs.rual.nl/block-types/redis) group and was last modified in core [`v15.0.0`](https://docs.rual.nl/core-versions/150000).

### Redis Key Selection Required

This block relies on a Redis key to perform its redis releated actions. You must manually select the Redis key you want to use in the flow in the blueprint using the Redis key selector modal. To access the modal, click the white button on the block.

Counts calls per registered key and reports whether this one is still within the limit. Replaces the incr-key + ttl + condition chain every API blueprint used to build by hand: pick a key that identifies the caller (for example one with a `{ip:value}` placeholder), a limit, and a window. Rejected calls count towards the limit as well.

- flow `flow`

- limit required `number` How many calls are allowed within the window.

- window `number` Length of the window in seconds.

Default `60`

- sliding window `condition` When true the previous window is weighted by how much of it still overlaps, so a caller can't spend the whole budget twice around a window boundary. Costs one extra Redis read.

Default `false`

- flow `flow`

- allowed `condition` False when this call is over the limit. Simulated runs always report true and consume nothing.

- remaining `number` Calls left in the current window, never below zero.

- retry after `number` Seconds until the window resets. Zero while the call is allowed : use it for the `Retry-After` header on a 429.

- key `value` The resolved key the counter is kept under.

- error `value` `NO_KEY` or `INVALID_LIMIT` when the block is misconfigured, or the Redis error when the counter could not be read. On a Redis failure the call is allowed through rather than blocking the endpoint.

| `rate limit` |
| --- |
| `throttle` |
| `quota` |
| `too many requests` |

A typical wiring for [rate limit](https://docs.rual.nl/block-types/redis/function_rate_limit): [number](https://docs.rual.nl/block-types/number/number_default) feeds the `limit` pin; the `flow` out pin feeds [branch](https://docs.rual.nl/block-types/flow/branch); the `allowed` out pin feeds [AND](https://docs.rual.nl/block-types/condition/condition_and).

![Studio canvas example for the rate limit block: typical wiring for rate limit.](https://docs.rual.nl/canvas-examples/function_rate_limit.png)

### Commonly used with

In production blueprints, this block is most often wired together with:

- [number](https://docs.rual.nl/block-types/number/number_default): feeds into this block. Generates a valid number from the filled custom value in the blueprint.

- [branch](https://docs.rual.nl/block-types/flow/branch): this block feeds into it.

- [create](https://docs.rual.nl/block-types/globals/trigger_custom_function): feeds into this block. Creates a new function that can be executed using the given name.

- [get guid](https://docs.rual.nl/block-types/users/user_get_guid): feeds into this block. Returns the guid (field: _meta.guid) of the given user.

- [AND](https://docs.rual.nl/block-types/condition/condition_and): this block feeds into it. operator for a set of boolean operands will be true if and only if all the operands are true.

- [rate limit](https://docs.rual.nl/block-types/redis/function_rate_limit): wired in both directions with this block. Counts calls per registered key and reports whether this one is still within the limit. Replaces the incr-key + ttl + condition chain every API blueprint used to build by hand: pick a key that identifies the caller (for example one with a {ip:value} placeholder), a limit, and a window. Rejected calls count towards the limit as well.

### Version history

Introduced in [`v15.0.0`](https://docs.rual.nl/core-versions/150000).
