WhatsApp bans accounts that send too many messages in a short period. The Baileys provider’s built-in rate limiter protects your bot automatically — it’s enabled by default and sits inside the provider’s outbound send pipeline, so every ctx.reply(), bot.send(), bot.broadcast() and media send passes through it.
Transport-owned pacingThe pacing policy lives on the transport provider, not on the
core: each transport may enforce its own limits (Telegram 429s, Discord
buckets, Cloud API tiers — surfaced as typed RateLimitedErrors). This
page covers the WhatsApp (Baileys) token-bucket limiter you configure when
constructing BaileysProvider.
The limiter uses a token bucket algorithm with two independent buckets:
Per-chat — limits how fast you can send to a single conversation.
Global — limits your total outbound throughput across all chats.
When a bucket is empty, messages are queued (not dropped) and released as tokens refill; a throttled chat does not hold the others back. A send that waits in the queue longer than maxWait (30 s by default) rejects with RateLimiterTimeout, a RateLimitedError, so a caller never hangs. An optional jitter adds a random human-like delay between sends.
New accounts are more sensitiveA freshly registered WhatsApp number gets banned faster than an aged one. Start conservative (3 / 10s per chat, 20 / 60s global) and increase gradually.
Whatever the transport, a ctx send (reply, say, media, in handlers, flows
and conversations) that the provider rejects with a RateLimitedError asking
for a short wait is retried in place, so a conversation step does not end on a
transient 429: by default once, when retryAfterMs is at most 5 s.
BotConfig.rateLimitRetry tunes it (retries counts attempts after the first):
new Bot({ provider, rateLimitRetry: { retries: 2, maxWaitMs: '10s' } })new Bot({ provider, rateLimitRetry: false }) // never retry in place
A longer wait, other errors and bot.send() are not retried in place: they
reject with the provider’s error. bot.broadcast()
(its retries option) and the durable outbox have their own back-off.
The rate limiter runs afterbefore('send') hooks but before the actual provider send. If a hook aborts the send, the rate limiter is never consulted — aborted sends don’t consume tokens.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"botmesh","description":"A transport-agnostic TypeScript framework for messaging bots: WhatsApp (Baileys or the Cloud API), Telegram, Discord and more behind one IProvider.","colors":{"primary":"#3451B2","light":"#A8B1FF","dark":"#3451B2"},"logo":{"light":"https://mintcdn.com/afaya/32LyKbpS8BIF3Yl-/logo/light.svg?fit=max\u0026auto=format\u0026n=32LyKbpS8BIF3Yl-\u0026q=85\u0026s=5a9c4db10ba52bbd645a009cc009e31e","dark":"https://mintcdn.com/afaya/32LyKbpS8BIF3Yl-/logo/dark.svg?fit=max\u0026auto=format\u0026n=32LyKbpS8BIF3Yl-\u0026q=85\u0026s=be155346190b752c815b6d06f1134702"},"favicon":"https://mintcdn.com/afaya/32LyKbpS8BIF3Yl-/favicon.svg?fit=max\u0026auto=format\u0026n=32LyKbpS8BIF3Yl-\u0026q=85\u0026s=abe4b13c733adb336381bebc0220d3e5","navbar":{"links":[{"href":"https://www.npmjs.com/package/@botmesh/core","label":"npm"}],"primary":{"type":"github","href":"https://github.com/andresayac/botmesh"}},"footer":{"socials":{"github":"https://github.com/andresayac/botmesh"},"links":[{"header":"Project","items":[{"label":"GitHub","href":"https://github.com/andresayac/botmesh"},{"label":"npm","href":"https://www.npmjs.com/package/@botmesh/core"},{"label":"MIT License","href":"https://github.com/andresayac/botmesh/blob/main/LICENSE"},{"label":"Changelog","href":"https://github.com/andresayac/botmesh/blob/main/CHANGELOG.md"}]}]},"search":{"prompt":"Search the botmesh docs…"},"seo":{"indexing":"navigable"},"icons":{"library":"lucide"},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"styling":{"latex":true},"navigation":{"languages":[{"language":"en","default":true,"href":""},{"language":"es","footer":{"socials":{"github":"https://github.com/andresayac/botmesh"},"links":[{"header":"Proyecto","items":[{"label":"GitHub","href":"https://github.com/andresayac/botmesh"},{"label":"npm","href":"https://www.npmjs.com/package/@botmesh/core"},{"label":"Licencia MIT","href":"https://github.com/andresayac/botmesh/blob/main/LICENSE"},{"label":"Changelog","href":"https://github.com/andresayac/botmesh/blob/main/CHANGELOG.md"}]}]},"href":"es"}]}},"deployment":{"deploymentMetadataValue":{"subdomain":"afaya","hasAudioNarration":false,"actualSubdomain":"afaya","customDomains":["botmesh.afaya.com.co"],"gitSource":{"type":"github","owner":"andresayac","repo":"botmesh-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":"","_id":"6ae0b3e80b849c49dba39507"},"chroma":{"latestBuiltDeploymentHistoryId":"6ae0b3f8dc8e261a8bb682ee","collectionId":"af19fec4-32c9-4ad1-b8a5-5db01ce875d1","liveDeploymentHistoryId":"6ae0b3f8dc8e261a8bb682ee","schemaVersion":"v3"},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae0ecbfb75c048de4393abc","clientVersion":"0.0.3990","searchFilterCounts":[{"language":"en","tag":"API reference","count":541},{"language":"en","tag":"@botmesh/core","count":373},{"language":"en","tag":"@botmesh/core/testing","count":93},{"language":"en","tag":"@botmesh/core/spi","count":75},{"language":"en","tag":"Guide","count":68},{"language":"es","tag":"Guía","count":68},{"language":"en","tag":"Golden transcripts","count":41},{"language":"en","tag":"Durability","count":35},{"language":"en","tag":"Flows","count":34},{"language":"en","tag":"Messages \u0026 context","count":32},{"language":"en","tag":"Forms","count":30},{"language":"es","tag":"Ejemplos","count":29},{"language":"es","tag":"Canales","count":18},{"language":"es","tag":"IA","count":11},{"language":"es","tag":"Producción","count":10},{"language":"es","tag":"Crear bots","count":10},{"language":"es","tag":"Intermedio","count":9},{"language":"es","tag":"Principiante","count":8},{"language":"es","tag":"Tests y herramientas","count":7},{"language":"es","tag":"Referencia","count":6}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-v7-file-tree","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"pause-universal-search-reconcile","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"per-site-search-delta","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-private-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-nav-generations","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-agent-model-picker","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"isAtlas":false,"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"guide/rate-limiting","slug":"/guide/rate-limiting","pageMetadata":{"title":"Rate Limiting (Anti-Ban)","sidebarTitle":"Rate limiting (anti-ban)","description":null,"href":"/guide/rate-limiting"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,em:`em`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Mermaid,Table,Tip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Mermaid)_missingMdxReference(`Mermaid`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`WhatsApp `,_jsx(_components.strong,{children:`bans accounts`}),` that send too many messages in a short period. The Baileys provider’s built-in rate limiter protects your bot automatically — it’s `,_jsx(_components.strong,{children:`enabled by default`}),` and sits inside the provider’s outbound send pipeline, so every `,_jsx(_components.code,{children:`ctx.reply()`}),`, `,_jsx(_components.code,{children:`bot.send()`}),`, `,_jsx(_components.code,{children:`bot.broadcast()`}),` and media send passes through it.`]}),`\n`,_jsxs(Tip,{children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`Transport-owned pacing`})}),_jsxs(_components.p,{children:[`The pacing policy lives on the `,_jsx(_components.strong,{children:`transport provider`}),`, not on the\ncore: each transport may enforce its own limits (Telegram 429s, Discord\nbuckets, Cloud API tiers — surfaced as typed `,_jsx(_components.code,{children:`RateLimitedError`}),`s). This\npage covers the WhatsApp (Baileys) token-bucket limiter you configure when\nconstructing `,_jsx(_components.code,{children:`BaileysProvider`}),`.`]})]}),`\n`,_jsx(Heading,{level:`2`,id:`how-it-works`,children:`How it works`}),`\n`,_jsxs(_components.p,{children:[`The limiter uses a `,_jsx(_components.strong,{children:`token bucket`}),` algorithm with two independent buckets:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Per-chat`}),` — limits how fast you can send to a `,_jsx(_components.em,{children:`single`}),` conversation.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Global`}),` — limits your `,_jsx(_components.em,{children:`total`}),` outbound throughput across all chats.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`When a bucket is empty, messages are `,_jsx(_components.strong,{children:`queued`}),` (not dropped) and released as tokens refill; a throttled chat does not hold the others back. A send that waits in the queue longer than `,_jsx(_components.code,{children:`maxWait`}),` (30 s by default) rejects with `,_jsx(_components.code,{children:`RateLimiterTimeout`}),`, a `,_jsx(_components.code,{children:`RateLimitedError`}),`, so a caller never hangs. An optional `,_jsx(_components.strong,{children:`jitter`}),` adds a random human-like delay between sends.`]}),`\n`,_jsx(Mermaid,{chart:`flowchart LR\n A[\"ctx.reply()\"] --> B[\"before('send') hooks\"]\n B --> C[\"RateLimiter.acquire(chatId)\"]\n C -->|\"tokens available\"| D[\"provider.send()\"]\n C -->|\"bucket empty\"| E[\"queue — wait for refill\"]\n E --> D\n D --> F[\"after('send') hooks\"]`}),`\n`,_jsx(Heading,{level:`2`,id:`configuration`,children:`Configuration`}),`\n`,_jsxs(_components.p,{children:[`Pass `,_jsx(_components.code,{children:`rateLimit`}),` to the `,_jsx(_components.strong,{children:`provider`}),` constructor (`,_jsx(_components.code,{children:`BotConfig.rateLimit`}),` is\ndeprecated: the core ignores it and logs a warning):`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`13`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Bot`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '@botmesh/core'`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BaileysProvider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '@botmesh/baileys'`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` bot`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Bot`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` provider:`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` BaileysProvider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` session:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'my-bot'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` rateLimit:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` perChat:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`max:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 5`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '10s'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// max 5 msgs per chat per 10s`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` global:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`max:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 50`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '60s'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// max 50 msgs total per 60s`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` jitter:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`min:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 500`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`max:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1500`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// random 500–1500ms between sends`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`]})})}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Option`}),_jsx(_components.th,{children:`Type`}),_jsx(_components.th,{children:`Default`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`perChat.max`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`number`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`5`})}),_jsx(_components.td,{children:`Max messages per chat in the window`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`perChat.window`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`string | number`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`'10s'`})}),_jsxs(_components.td,{children:[`Time window (e.g. `,_jsx(_components.code,{children:`'10s'`}),`, `,_jsx(_components.code,{children:`'1m'`}),`, `,_jsx(_components.code,{children:`60000`}),`)`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`global.max`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`number`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`50`})}),_jsx(_components.td,{children:`Max total messages in the window`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`global.window`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`string | number`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`'60s'`})}),_jsx(_components.td,{children:`Time window`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`jitter.min`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`number`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`0`})}),_jsx(_components.td,{children:`Minimum delay between sends (ms)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`jitter.max`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`number`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`0`})}),_jsx(_components.td,{children:`Maximum delay between sends (ms)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`enabled`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`boolean`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`true`})}),_jsxs(_components.td,{children:[`Set `,_jsx(_components.code,{children:`false`}),` to disable entirely`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`maxWait`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`string | number`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`'30s'`})}),_jsxs(_components.td,{children:[`Longest wait in the queue before the send rejects with `,_jsx(_components.code,{children:`RateLimiterTimeout`}),` (`,_jsx(_components.code,{children:`0`}),` waits indefinitely)`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`maxChats`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`number`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`5000`})}),_jsx(_components.td,{children:`Per-chat buckets kept in memory (idle ones are evicted first, so an active limit is never lifted)`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`disable-rate-limiting`,children:`Disable rate limiting`}),`\n`,_jsx(_components.p,{children:`For tests or high-throughput trusted environments:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` bot`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Bot`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` provider:`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` BaileysProvider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` session:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'my-bot'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` rateLimit:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`enabled:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`recommended-settings`,children:`Recommended settings`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Scenario`}),_jsx(_components.th,{children:`perChat`}),_jsx(_components.th,{children:`global`}),_jsx(_components.th,{children:`jitter`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Customer support (low volume)`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`5 / 10s`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`30 / 60s`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`500–1500ms`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Notifications / broadcasts`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`3 / 10s`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`20 / 60s`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`1000–3000ms`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Interactive flows (fast replies)`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`10 / 10s`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`100 / 60s`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`200–500ms`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Development / tests`}),_jsx(_components.td,{children:`disabled`}),_jsx(_components.td,{children:`disabled`}),_jsx(_components.td,{children:`—`})]})]})]}),`\n`,_jsxs(Warning,{children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`New accounts are more sensitive`})}),_jsxs(_components.p,{children:[`A freshly registered WhatsApp number gets banned faster than an aged one. Start conservative (`,_jsx(_components.code,{children:`3 / 10s`}),` per chat, `,_jsx(_components.code,{children:`20 / 60s`}),` global) and increase gradually.`]})]}),`\n`,_jsx(Heading,{level:`2`,id:`programmatic-access`,children:`Programmatic access`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`RateLimiter`}),` instance is internal, but you can import the class from the transport package for advanced use:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`RateLimiter`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '@botmesh/baileys'`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` limiter`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` RateLimiter`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` perChat:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`max:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 5`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '10s'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` global:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`max:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 50`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '60s'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` limiter`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`acquire`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'573001234567@s.whatsapp.net'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// resolves when allowed`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`limiter`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`pending`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// messages waiting in queue`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`limiter`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`reset`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// clear buckets + reject queued sends`})]}),`\n`]})})}),`\n`,_jsxs(Heading,{level:`2`,id:`short-rate-limits-on-ctx-sends`,children:[`Short rate limits on `,_jsx(_components.code,{children:`ctx`}),` sends`]}),`\n`,_jsxs(_components.p,{children:[`Whatever the transport, a `,_jsx(_components.code,{children:`ctx`}),` send (`,_jsx(_components.code,{children:`reply`}),`, `,_jsx(_components.code,{children:`say`}),`, media, in handlers, flows\nand conversations) that the provider rejects with a `,_jsx(_components.code,{children:`RateLimitedError`}),` asking\nfor a short wait is retried in place, so a conversation step does not end on a\ntransient 429: by default once, when `,_jsx(_components.code,{children:`retryAfterMs`}),` is at most 5 s.\n`,_jsx(_components.code,{children:`BotConfig.rateLimitRetry`}),` tunes it (`,_jsx(_components.code,{children:`retries`}),` counts attempts after the first):`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Bot`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`provider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`rateLimitRetry:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`retries:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`maxWaitMs:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '10s'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } })`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Bot`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`provider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`rateLimitRetry:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// never retry in place`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`A longer wait, other errors and `,_jsx(_components.code,{children:`bot.send()`}),` are not retried in place: they\nreject with the provider’s error. `,_jsx(_components.code,{children:`bot.broadcast()`}),`\n(its `,_jsx(_components.code,{children:`retries`}),` option) and the durable outbox have their own back-off.`]}),`\n`,_jsxs(Heading,{level:`2`,id:`how-it-interacts-with-before-send-hooks`,children:[`How it interacts with `,_jsx(_components.code,{children:`before('send')`}),` hooks`]}),`\n`,_jsxs(_components.p,{children:[`The rate limiter runs `,_jsx(_components.strong,{children:`after`}),` `,_jsx(_components.code,{children:`before('send')`}),` hooks but `,_jsx(_components.strong,{children:`before`}),` the actual provider send. If a hook aborts the send, the rate limiter is never consulted — aborted sends don’t consume tokens.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Rate Limiting (Anti-Ban)","sidebarTitle":"Rate limiting (anti-ban)","description":null,"href":"/guide/rate-limiting"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"How it works","slug":"how-it-works","depth":2,"children":[]},{"title":"Configuration","slug":"configuration","depth":2,"children":[]},{"title":"Disable rate limiting","slug":"disable-rate-limiting","depth":2,"children":[]},{"title":"Recommended settings","slug":"recommended-settings","depth":2,"children":[]},{"title":"Programmatic access","slug":"programmatic-access","depth":2,"children":[]},{"title":"Short rate limits on ctx sends","slug":"short-rate-limits-on-ctx-sends","depth":2,"children":[]},{"title":"How it interacts with before('send') hooks","slug":"how-it-interacts-with-before-send-hooks","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"afaya","siteName":"botmesh","title":"Rate Limiting (Anti-Ban) - botmesh","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{"en":{"href":"/guide/rate-limiting","matchLevel":0},"es":{"href":"/es/guide/rate-limiting","matchLevel":1}}},"lastModified":"2026-10-27T18:26:23.304Z","originalFileLocation":"guide/rate-limiting.mdx","locale":"en"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"botmesh\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/afaya/omilwj1Ifh1eDwt5/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/afaya/omilwj1Ifh1eDwt5/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/afaya/omilwj1Ifh1eDwt5/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/afaya/omilwj1Ifh1eDwt5/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/afaya/omilwj1Ifh1eDwt5/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/afaya/omilwj1Ifh1eDwt5/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/afaya/omilwj1Ifh1eDwt5/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/afaya/omilwj1Ifh1eDwt5/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/afaya/omilwj1Ifh1eDwt5/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Rate Limiting (Anti-Ban) - botmesh\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"botmesh\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://botmesh.afaya.com.co/guide/rate-limiting\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://afaya.mintlify.app/_mintlify/api/og/v2?division=Channels\u0026amp;title=Rate+Limiting+%28Anti-Ban%29\u0026amp;theme=dea9f3ba838ba9e4866bef64\u0026amp;signature=fa480a28deb7768d334188063bfa3b54e0479af6bb0b7fe119c525c61643dac6\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Rate Limiting (Anti-Ban) - botmesh\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://afaya.mintlify.app/_mintlify/api/og/v2?division=Channels\u0026amp;title=Rate+Limiting+%28Anti-Ban%29\u0026amp;theme=dea9f3ba838ba9e4866bef64\u0026amp;signature=fa480a28deb7768d334188063bfa3b54e0479af6bb0b7fe119c525c61643dac6\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/afaya/omilwj1Ifh1eDwt5/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"botmesh\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#3451B2\">\u003clink data-mint-head rel=\"canonical\" href=\"https://botmesh.afaya.com.co/guide/rate-limiting\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/guide/rate-limiting.md\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"en\" href=\"https://botmesh.afaya.com.co/guide/rate-limiting\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"es\" href=\"https://botmesh.afaya.com.co/es/guide/rate-limiting\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"x-default\" href=\"https://botmesh.afaya.com.co/guide/rate-limiting\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://botmesh.afaya.com.co/#organization\",\"name\":\"botmesh\",\"url\":\"https://botmesh.afaya.com.co\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/afaya/32LyKbpS8BIF3Yl-/logo/light.svg?fit=max\u0026auto=format\u0026n=32LyKbpS8BIF3Yl-\u0026q=85\u0026s=5a9c4db10ba52bbd645a009cc009e31e\"}},{\"@type\":\"WebSite\",\"@id\":\"https://botmesh.afaya.com.co#website\",\"name\":\"botmesh\",\"url\":\"https://botmesh.afaya.com.co\",\"publisher\":{\"@id\":\"https://botmesh.afaya.com.co/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://botmesh.afaya.com.co/guide/rate-limiting#webpage\",\"url\":\"https://botmesh.afaya.com.co/guide/rate-limiting\",\"name\":\"Rate Limiting (Anti-Ban)\",\"dateModified\":\"2026-10-27T18:26:23.304Z\",\"isPartOf\":{\"@id\":\"https://botmesh.afaya.com.co#website\"},\"breadcrumb\":{\"@id\":\"https://botmesh.afaya.com.co/guide/rate-limiting#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://botmesh.afaya.com.co/guide/rate-limiting#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Channels\",\"item\":\"https://botmesh.afaya.com.co/guide/channels\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Rate Limiting (Anti-Ban)\",\"item\":\"https://botmesh.afaya.com.co/guide/rate-limiting\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://botmesh.afaya.com.co/guide/rate-limiting#article\",\"headline\":\"Rate Limiting (Anti-Ban)\",\"name\":\"Rate Limiting (Anti-Ban)\",\"url\":\"https://botmesh.afaya.com.co/guide/rate-limiting\",\"mainEntityOfPage\":{\"@id\":\"https://botmesh.afaya.com.co/guide/rate-limiting#webpage\"},\"dateModified\":\"2026-10-27T18:26:23.304Z\",\"publisher\":{\"@id\":\"https://botmesh.afaya.com.co/#organization\"},\"isPartOf\":{\"@id\":\"https://botmesh.afaya.com.co#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"botmesh\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"botmesh","nav":{"global":null,"languages":[{"language":"en","default":true,"tabs":[{"tab":"Guide","icon":"book-open","groups":[{"group":"Get started","pages":[{"title":"botmesh","sidebarTitle":"Home","mode":"wide","href":""},{"title":"Getting Started","sidebarTitle":"Quick start","href":"/guide/getting-started"},{"title":"Your First Bot","sidebarTitle":"Your first bot","href":"/guide/first-bot"},{"title":"Terminal simulator (`botmesh dev`)","sidebarTitle":"Terminal simulator","href":"/guide/dev-simulator"},{"title":"Core Concepts","sidebarTitle":"Core concepts","href":"/guide/concepts"}]},{"group":"Build bots","pages":[{"title":"Messages \u0026 Media","sidebarTitle":"Messages \u0026 media","href":"/guide/messages"},{"title":"Conversation Flows","sidebarTitle":"Conversation flows","href":"/guide/flows"},{"title":"Special triggers: WELCOME, message types and CALL","sidebarTitle":"Special triggers","href":"/guide/triggers"},{"title":"Forms (WhatsApp Flows)","href":"/guide/forms"},{"title":"Proactive messages","href":"/guide/proactive-messages"},{"title":"Internationalization (i18n)","href":"/guide/i18n"},{"title":"Human handoff \u0026 access lists","sidebarTitle":"Handoff \u0026 access lists","href":"/guide/handoff"},{"title":"Hooks (Middleware)","sidebarTitle":"Hooks (middleware)","href":"/guide/hooks"},{"title":"Plugins","href":"/guide/plugins"},{"title":"Integrations","href":"/guide/integrations"}]},{"group":"Channels","pages":[{"title":"Channels (providers)","sidebarTitle":"Overview","href":"/guide/channels"},{"title":"Baileys (WhatsApp Web)","description":null,"href":"/guide/baileys"},{"title":"Rate Limiting (Anti-Ban)","sidebarTitle":"Rate limiting (anti-ban)","href":"/guide/rate-limiting"},{"title":"Sub-APIs (v1) → transport escape hatches (v2)","sidebarTitle":"Sub-APIs","description":null,"href":"/guide/sub-apis"},{"title":"WhatsApp Cloud API","href":"/guide/whatsapp-cloud-api"},{"title":"24-hour window and pricing (Cloud API)","sidebarTitle":"WhatsApp 24h window","href":"/guide/session-window"},{"title":"Evolution API","href":"/guide/evolution"},{"title":"WPPConnect","href":"/guide/wppconnect"},{"title":"Twilio","href":"/guide/twilio"},{"title":"Gupshup","href":"/guide/gupshup"},{"title":"HighLevel (GoHighLevel)","sidebarTitle":"HighLevel","href":"/guide/gohighlevel"},{"title":"Messenger","href":"/guide/messenger"},{"title":"Instagram","href":"/guide/instagram"},{"title":"Telegram","href":"/guide/telegram"},{"title":"Discord","href":"/guide/discord"},{"title":"Email","href":"/guide/email"},{"title":"Webhook server (`@botmesh/server`)","sidebarTitle":"Webhook server","href":"/guide/server"},{"group":"Experimental","pages":[{"title":"TikTok","href":"/guide/tiktok"}]}]},{"group":"AI","pages":[{"title":"AI plugin","href":"/guide/ai"},{"title":"AI tool calling","href":"/guide/ai-tools"},{"title":"AI memory \u0026 RAG","href":"/guide/ai-memory-rag"},{"title":"Streaming replies (`ctx.stream`)","sidebarTitle":"Streaming replies","href":"/guide/streaming"},{"title":"Voice (`@botmesh/voice`)","sidebarTitle":"Voice (STT/TTS)","href":"/guide/voice"}]},{"group":"Data and state","pages":[{"title":"Persistent store","href":"/guide/store"},{"title":"Persistent user data (`ctx.user`)","sidebarTitle":"Persistent user data","href":"/guide/user-data"}]},{"group":"Production","pages":[{"title":"Going to production","href":"/guide/production"},{"title":"Deployment","href":"/guide/deploy"},{"title":"Security","href":"/guide/security"},{"title":"Operations: metrics, events, inbox and delivery","sidebarTitle":"Operations","href":"/guide/operations"},{"title":"Tracing (OpenTelemetry)","href":"/guide/tracing"},{"title":"Durable message processing","sidebarTitle":"Durable processing","href":"/guide/durability"},{"title":"Scheduler","sidebarTitle":"Scheduler \u0026 durable tasks","href":"/guide/scheduler"},{"title":"Running N replicas","href":"/guide/replicas"},{"title":"Redis Cluster","href":"/guide/redis-cluster"},{"group":"Experimental","pages":[{"title":"Control plane","href":"/guide/control-plane"}]}]},{"group":"Testing and tools","pages":[{"title":"Testing","href":"/guide/testing"},{"title":"Golden transcripts","href":"/guide/golden-transcripts"},{"title":"Inspect \u0026 lint flows","href":"/guide/flow-tools"},{"title":"ESLint plugin","href":"/guide/eslint"},{"title":"JSON flow schema","href":"/guide/flow-schema"},{"title":"MCP server","href":"/guide/mcp"},{"group":"Experimental","pages":[{"title":"Platform sandbox","href":"/guide/sandbox"}]}]},{"group":"Reference","pages":[{"title":"Configuration reference","href":"/guide/configuration"},{"title":"Packages and versions","href":"/guide/packages"},{"title":"Architecture","href":"/guide/architecture"},{"title":"Threat model","href":"/guide/threat-model"},{"title":"Troubleshooting","href":"/guide/troubleshooting"},{"title":"FAQ","href":"/guide/faq"}]},{"group":"Upgrading","pages":[{"title":"Upgrade to stable: checklist and API changes","sidebarTitle":"Upgrade guide","href":"/guide/stable-migration"},{"title":"Upgrade to stable: dependencies","sidebarTitle":"Dependency changes","href":"/guide/migration"},{"title":"Upgrade to stable: behaviour changes","sidebarTitle":"Behaviour changes","href":"/guide/migration-2"},{"title":"Upgrade notes: channels and plugins","sidebarTitle":"Channels and plugins","href":"/guide/upgrade-channels-plugins"},{"title":"Coming from v1","href":"/guide/migration-v1"}]}]},{"tab":"Examples","icon":"chef-hat","pages":[{"title":"Examples","href":"/examples"}]},{"tab":"API reference","icon":"code","pages":[{"title":"API reference","href":"/api/core"}]}]},{"language":"es","footer":{"socials":{"github":"https://github.com/andresayac/botmesh"},"links":[{"header":"Proyecto","items":[{"label":"GitHub","href":"https://github.com/andresayac/botmesh"},{"label":"npm","href":"https://www.npmjs.com/package/@botmesh/core"},{"label":"Licencia MIT","href":"https://github.com/andresayac/botmesh/blob/main/LICENSE"},{"label":"Changelog","href":"https://github.com/andresayac/botmesh/blob/main/CHANGELOG.md"}]}]},"pages":[{"title":"es","href":"/es/guide/rate-limiting"}]}]},"title":"Rate Limiting (Anti-Ban) - botmesh","buildId":"dpl_2oYXwqkEXirXBPk8wV1FtM5USFWi","deploymentId":"dpl_2oYXwqkEXirXBPk8wV1FtM5USFWi","dynamics":[],"chunks":[]}