[[ratelimits]] entry exposes a rate limiter binding on env — as the handler’s env argument in a telnyx.toml project, or through import { env } from "@telnyx/edge-runtime" in a func.toml one. The binding name is uppercased and hyphens are replaced with underscores, so a limiter named api-limit is available as env.API_LIMIT.
env.NAME.limit({ key })
Checks and increments the counter for key in the current fixed window.
Input
Return value
The method returnsPromise<{ success: boolean }>:
Treat
success: false as a rejection.
Rate limiting fails open: if the counter store is unreachable the check returns { success: true } and the request is admitted, so an outage means requests are not limited rather than all being rejected.
The binding returns only the decision. Your function is responsible for returning an appropriate response, such as HTTP 429 Too Many Requests.
TypeScript type
telnyx-edge types writes the binding’s declaration into telnyx-env.d.ts, so env.<NAME> is typed for you. It requires @telnyx/edge-runtime 0.9.2 or later, the first release exporting RateLimiter. The generated shape is: