Check a rate limit

POST
/v1/risk/limits

Takes cost tokens (default 1) from key's share of one of your buckets and says whether to let the request through: a 200 either way, with allowed. Denied requests take nothing. Each key has its own bucket of burst tokens refilling at limit per period_seconds (GCRA, the algorithm COSS limits its own API with). COSS keeps only a keyed hash of key. While COSS can't count, the bucket's on_failure answers and degraded is true.

Authorization

bearerAuth
headerAuthorizationBearer <token>

A secret API key from the dashboard: coss_live_… for production environments, coss_test_… for sandbox environments.

Header Parameters

Idempotency-Key?string

Makes retries safe: a repeated allowed check with the same key is answered again without taking more tokens, for an hour. 1-256 characters.

Length1 <= length <= 256
Coss-Version?"2026-10-10"

The API version (a date) to use for this request. Defaults to your organization's version, pinned to the latest one when it first used the API and upgraded from the dashboard. The SDK always sends the version it was built for.

Value in"2026-10-10"

Request Body

application/json
  1. body
bucket*string

The bucket's name.

Match^[a-z0-9][a-z0-9._-]{0,63}$
key*string

Who or what is limited: a user id, an email address, an IP address… COSS keeps only a keyed hash of it.

Length1 <= length <= 512
cost?integer

Tokens this request takes. Default 1.

Range1 <= value <= 1000000

Response Body

The answer for this request.

application/json
  1. response
object*"risk_limit"
Value in"risk_limit"
bucket*string
allowed*boolean

Whether to let the request through. Denied requests take no tokens.

limit*integer

The bucket's size (burst).

remaining*integer

Tokens left for this key.

reset_ms*integer

Milliseconds until the key's bucket is full again.

retry_after_ms*|

When denied: milliseconds until the same request would be allowed; null when it never would (cost above the bucket's size). 0 when allowed.

degraded*boolean

COSS couldn't count (its store was unavailable): allowed is the bucket's on_failure.

import { Coss } from "coss";const coss = new Coss({  apiKey: process.env.COSS_API_KEY,  baseUrl: "https://api.coss.com",});const { data, error } = await coss.risk.limit({  bucket: "password_reset",  key: "ada@example.com",});
{  "object": "risk_limit",  "bucket": "password_reset",  "allowed": true,  "limit": 5,  "remaining": 4,  "reset_ms": 720000,  "retry_after_ms": 0,  "degraded": false}