Docs menu

Guardrails and rate limits for API keys and agents

Limit what a bubblr API key can send: a per-key rate limit, a list of allowed recipients, and drafts-only keys whose messages a person approves.

Guardrails are set on an API key, by your team's owners and admins in the app (Developers → API keys). They hold for every request made with that key: REST, the SDK and the MCP server alike. An agent can't step around them by switching how it calls, and a key can't change its own.

Use them whenever software sends on its own, and especially while you try out an AI agent.

Guardrail Effect When it's hit
Rate limit At most N sends per window (default window: one hour). 429 rate_limited
Allowed recipients Only these people and groups. 403 recipient_not_allowed
Drafts only Sends become drafts a person approves. 202 with a draft

Rate limit

A key with a rate limit of, say, 30 per hour can send 30 messages in any 60 minutes. Drafts count; replays of the same Idempotency-Key don't. The count is kept in the database, so it holds across concurrent requests and restarts.

Over the limit, sends answer 429:

JSON
{ "error": { "code": "rate_limited", "message": "This API key may send 30 messages per hour and has reached that. Try again in 412 s, or ask an admin to raise the key's send_rate_limit.",
  "details": { "limit": 30, "window_sec": 3600, "retry_after_sec": 412 } } }

with a Retry-After header in seconds. The SDK's RateLimitError has it as retryAfter. Wait at least that long; retrying sooner is refused again.

The rate limit is about sending. Reading has no per-key limit; keep it reasonable (page through history, don't poll every second: use webhooks).

Allowed recipients

A key with allowed recipients can only send to them: phone numbers with their country code (+14155550142), email addresses, or group chat ids. It holds for sends, reactions, typing and read receipts. Anyone else is 403 recipient_not_allowed, and the message isn't sent. Reading isn't limited.

A short list is the safest way to try an agent: give it a key that can only text your own phone.

Drafts only

A drafts-only key can't send at all. POST …/messages with it answers 202 with a draft instead of a message:

JSON
{ "object": "draft", "id": "drf_7Lp2mC9xQe", "status": "pending", "to": "+14155550142", "text": "Thanks Hannah! Does Thursday at 3 PM work?", … }

Nothing reaches the person until someone approves it: a team member in the app's inbox, or your code with POST /v1/drafts/{draft_id}/approve and a key that can send and isn't drafts-only. Approving can change the text first ({"text": "…"}), and sends under the approving key's own guardrails. POST /v1/drafts/{draft_id}/reject discards it with an optional reason the agent can read.

Drafts arrive as draft.created events, then draft.approved (with the message) or draft.rejected. List them with GET /v1/drafts?status=pending. A drafts-only key also can't react, show typing or mark chats read (403 draft_only_key): those reach the person at once and can't be drafts.

Approving isn't an MCP tool on purpose: a person approves, not the agent.

Choosing guardrails for an agent

Stage Suggested key
Trying it out Drafts only, allowed recipients = your own number, messages:read + messages:send
First customers Drafts only, a rate limit (30 an hour)
Trusted Not drafts-only, a rate limit that fits your volume, only the lines it serves

Give each agent its own key, so you can see what each one did (drafts and messages record the key) and revoke one without touching the others.

Keys come with your first line.

Request an invite and we'll set up a line for your team. API access is part of every plan.

Request an invite