lymitdocs

docs

REST API

Use Lymit from any language with one HTTP endpoint.

The SDK is a thin client over one endpoint. Any language can call it directly.

Authentication

Authorization: Bearer lym_live_… on every request. Missing, malformed, unknown or revoked → 401 invalid_api_key.

POST https://api.lymit.io/v1/limit

1curl -s https://api.lymit.io/v1/limit \2  -H "authorization: Bearer $LYMIT_API_KEY" \3  -H "content-type: application/json" \4  -d '{"namespace":"ai_generation","identifier":"user_123","cost":150,5       "config":{"algorithm":"tokenBucket","capacity":5000,"refillRate":1000,"interval":"1h"}}'

Body (≤ 4 KB):

FieldTypeRules
namespacestring1–256 chars
identifierstring1–256 chars
costinteger≥ 0, default 1; 0 peeks
configobject{ algorithm: "fixedWindow" | "slidingWindow", limit, window } or { algorithm: "tokenBucket", capacity, refillRate, interval }

Response — 200 allowed, 429 rejected — plus headers X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset (Unix seconds) and, on 429, Retry-After (seconds):

1{2  "success": true,3  "limit": 5000,4  "remaining": 4850,5  "reset": 1700000540000,6  "algorithm": "tokenBucket"7}

Errors

{ "error": { "code", "message", "field"? } }

CodeStatusWhen
bad_request400Invalid body; field names the culprit, e.g. config.interval
invalid_api_key401Missing, unknown or revoked key
feature_not_in_plan403e.g. tokenBucket on Hobby
too_many_requests429Workspace exceeded its per-minute ceiling
quota_exceeded429Workspace over its plan quota (distinct from a limit rejection by the presence of error.code)
internal500Our bug; details in our logs, never in the response

Codes are stable: we add, we never rename.