SDKs
Set custom limits for specific identifiers
import { Override } from "@unkey/ratelimit" const unkey = new Override({ rootKey: process.env.UNKEY_ROOT_KEY, })
async function handler(request) { const identifier = request.getUserId() // or ip or anything else you want try { const { meta, data } = await unkey.setOverride({ identifier: identifier, limit: 10, duration: 60000, namespaceName: "email.outbound", }) if (data.error){ // handle the error here console.error(data.error.message); return; } } catch (err) { console.error(err); return; } // handle the request here }
Was this page helpful?