Skip to main content
This walkthrough configures a function to allow two requests per authenticated user during each 10-second window.
Use telnyx-edge v0.4.0 or later. Earlier versions may upload an invalid [[ratelimits]] block instead of rejecting it locally, and do not generate the binding’s type.

1. Start from a project

This walkthrough uses a telnyx.toml project, where the runtime serves your fetch handler. new-func --actor scaffolds one:
Every command below runs from the project directory.
It works in a func.toml project too — keep your own HTTP server and reach the binding with import { env } from "@telnyx/edge-runtime".

2. Declare a rate limiter

Add a [[ratelimits]] block to telnyx.toml, alongside whatever else the project declares:
This configuration allows two successful checks per key in each 10-second window.

3. Check the limit in your handler

Generate the binding’s type first, so env.API_LIMIT is typed for you. It is written into telnyx-env.d.ts alongside every other binding the manifest declares, so a project that also hosts an actor gets both in one Env:
The binding returns a decision; it does not send a 429 response automatically.

4. Ship and test

For the configuration above, three requests with the same trusted user ID during one window produce two 200 responses followed by a 429:
The CLI validates each declared limiter before upload and prints its name, limit, and period. See the API Reference for the binding’s method contract and return values.