Blueping for Python
Blueping gives your AI agent its own email inbox in one API call: username@blueping.dev, receiving at once. Every message arrives as clean JSON, with the sender's new words, verification codes (OTP) and links pulled out, attachments readable as text, and a verdict on who sent it and what it says.
This package has no dependencies and runs on Python 3.9 and later. It gives you typed responses, safe retries, webhook verification, and a small CLI that gets you an API key from your terminal.
Email inboxes for agents
An agent can have its own inbox, username@blueping.dev, in one call, with no key and no person to start: Blueping.signup() makes the agent, its key and its first inbox, which receives at once.
from blueping import Blueping
signed = Blueping.signup(name="Acme Support", owner_email="you@example.com")
# Keep signed["api_key"]: this is the only answer that shows it.
client, inbox = signed.client, signed["inbox"]
# Sign up to a service with inbox["address"], then wait for its code or its sign-in link.
found = client.wait_for_code(inbox["id"], from_="service.example")
print(found["code"], found["link"])
Until a person claims the agent, it writes only to people who wrote to it first, and to echo@blueping.dev, which answers within seconds with a test code. The owner gets a 6-digit code by email, and client.verify_signup(code) claims the agent.
With a key from your dashboard, Blueping() reads BLUEPING_API_KEY, and each agent gets as many inboxes as its plan holds:
blueping = Blueping()
support = blueping.inboxes.create("acme-support", display_name="Acme Support", client_id="support")
print(support["address"]) # acme-support@blueping.dev
page = client.inboxes.list_messages(inbox["id"], wait=30)
print(page["held"]) # what was kept back and why: include_held=True lists it
client.messages.reply(page["data"][0]["id"], "Thanks, received.")
client.inboxes.send(inbox["id"], "ana@example.com", "Your invoice", "Attached.", attachments=[{"filename": "invoice.pdf", "content_type": "application/pdf", "content": pdf_bytes}])
The rest of the mailbox works the same way:
from datetime import datetime, timedelta, timezone
email = page["data"][0]
client.messages.forward(email["id"], "accounting@acme.com", text="For the books.")
client.messages.label(email["id"], add=["invoices"])
text = client.messages.attachment_text(email["id"], email["attachments"][0]["id"])["text"] # what the file says
client.drafts.create(inbox["id"], to="ana@acme.com", subject="Reminder", text="Tomorrow at 9.", send_at=datetime.now(timezone.utc) + timedelta(hours=1))
client.rules.add(inbox["id"], "receive", "block", "@spam.example")
client.inboxes.list_threads() and client.threads read and label conversations, client.drafts writes, schedules and sends drafts, and client.rules keeps each inbox's allow and block lists.
Every email carries auth (SPF, DKIM and DMARC, with a verdict) and safety (text aimed at a model, hidden text). A message whose sender failed authentication, or that carries instructions for a model, is held: lists count it in held, and include_held=True shows it. Every send, forward and new draft carries an Idempotency-Key, so a retry sends or writes once. client.me.limits() says what the agent may send now, with warnings from 80% of a limit.
A send that meets a limit waits
A send past a limit that only takes time, such as the plan's day or month or the ramp of new recipients, is never refused for it: it comes back with status "queued", sends_at and reason, and goes out by itself at sends_at, with every check run again. Every send's answer reads its Blueping-Usage header for you, in usage.
sent = client.inboxes.send(inbox["id"], "ana@example.com", "Your invoice", "Attached.")
if sent["status"] == "queued":
print(f"goes at {sent['sends_at']}, waiting for {sent['reason']}")
print(sent.get("usage")) # {"day": {"used": 42, "allowed": 100}, "month": {"used": 1200, "allowed": 3000}}
# Refused instead of queued, for code that decides itself: raises daily_limit_reached and the others.
client.inboxes.send(inbox["id"], "ana@example.com", "Now or never", "Hi", if_limited="refuse")
Email plans
| Plan | Price | Inboxes | Emails sent a month | A day |
|---|---|---|---|---|
| Free | $0 | 3 | 3,000 | 100 |
| Developer | $19 a month, or $180 a year | 50 | 15,000 | 1,500 |
| Startup | $79 a month, or $780 a year | 500 | 75,000 | 7,500 |
| Scale | $249 a month, or $2,484 a year | 5,000 | 300,000 | 30,000 |
Mail the agent receives never counts as a send: the plan's storage is what holds it. On Free, mail the agent sends ends with a short "Sent with Blueping" line; paid plans add nothing. client.me.mail_plan_checkout("developer", period="year") answers a payment page for the agent's owner to open in their own browser. Every limit: blueping.dev/pricing.
Many inboxes, delivery and events
# One inbox per customer, up to 50 in one call: the same client_id twice makes nothing twice.
batch = client.inboxes.create_many([{"username": "acme-1", "client_id": "cust_1"}, {"username": "globex", "client_id": "cust_2"}])
for inbox in client.inboxes.iterate(): # page after page
print(inbox["address"])
health = client.inboxes.deliverability(inbox["id"], days=30) # delivered, bounced, complaints, what to do
entries = client.suppressions.list() # the addresses nothing more goes to
for event in client.events.iterate(types=["email.received", "email.bounced"]): # as it happens, kept 7 days
print(event["type"], event["data"])
found = client.search("invoice november", has_attachment=True) # every inbox: the text, and on a paid plan the files
month = client.usage.get(month="2026-11")
A key can be limited to one inbox and to permissions: a call past them raises PermissionDenied (with required) or InboxOutOfScope (with key_inbox_id), both a BluepingError. client.messages.release(message_id) lets a held message in, with a key that holds held:release. With an admin key, BluepingOrg() reads BLUEPING_ADMIN_KEY and creates agents and their keys: org.agents.create(), org.keys.create(), org.audit.list() and org.usage(). Keys and permissions.
Install
pip install blueping
Get an API key
Run the CLI:
blueping login
It shows a link and a short code, and opens the link in your browser when it can. Sign in with Google, GitHub or your email, check that the page shows the same code and approve. The key is saved in ~/.config/blueping/config.json, readable only by you, and never printed. No credit card. You can also sign up on the website, copy the key from the dashboard and set it as BLUEPING_API_KEY.
An agent uses two steps instead, so it can show your user the link while it waits: blueping login --start, then blueping login --check until it prints approved. Without a terminal, or with --json, a plain login starts and returns the same way.
Try it in a minute
from blueping import Blueping
blueping = Blueping() # reads BLUEPING_API_KEY
inbox = blueping.inboxes.create(client_id="first-try")
blueping.inboxes.send(inbox["id"], "echo@blueping.dev", "Hello", "Testing my inbox")
# echo@blueping.dev answers within seconds, with a test code.
found = blueping.wait_for_code(inbox["id"], from_="blueping.dev")
page = blueping.inboxes.list_messages(inbox["id"])
print(inbox["address"], found["code"], [message["subject"] for message in page["data"]])
client_id makes the create safe to run again: the same id returns the same inbox.
Errors
Every API error raises BluepingError with status, code, message and details, which holds every extra field the API sent, next_action and retry_after included:
from blueping import Blueping, BluepingError
blueping = Blueping()
try:
blueping.inboxes.send(inbox_id, "ana@example.com", "Your invoice", "Attached.")
except BluepingError as error:
print(error.code, error.details.get("next_action")) # what to do now, written for an agent
| Code | Status | What it means |
|---|---|---|
recipient_not_allowed |
403 | Before a person claims the agent, it writes only to people who wrote to it first, to echo@blueping.dev and to its owner. |
message_held |
403 | A held message isn't answered or forwarded: it waits for a person. |
recipient_blocked |
403 | One of the inbox's own send rules refuses a recipient. |
inbox_limit_reached |
429 | The plan's inboxes are all in use. |
queue_full |
429 | The send met a limit and the queue is full. retry_after says when it has room. |
no_code_yet |
404 | wait_for_code found no code in time. Call it again. |
too_many_recipients |
400 | 10 addresses at most per message, to, cc and bcc together. |
attachments_too_large |
413 | 10 MB of attachments per send. |
rate_limited |
429 | Too many requests in a short time. Wait details["retry_after"] seconds. |
unauthorized |
401 | The API key is wrong, or was revoked. |
internal_error |
500 | Something failed on Blueping's side. The client already retried with the same key. |
When the API cannot be reached at all, the client raises BluepingConnectionError, a subclass of BluepingError with status 0 and code "network_error". Every code, with what it means and what to do: blueping.dev/docs/errors.
Retries and idempotency
The client retries any request that got no answer, and any 500, up to two times with a short backoff. Every send, reply, forward and new draft carries an Idempotency-Key, kept 24 hours, so a retried send never goes out twice. Pass your own key to make your own retries safe as well, for example when a job runs again:
blueping.messages.reply(message_id, "Invoice 1042 is scheduled for payment on December 1.", idempotency_key="invoice-1042-ack")
Without a key, the same message to the same people from the same inbox within 5 minutes still goes once. You can also change the 30 second timeout, or turn retries off:
blueping = Blueping(timeout=10, max_retries=0)
Webhooks
Blueping posts events to your URLs as they happen: email.received when mail reaches an inbox, email.held when it is kept back, email.sent when a send goes out, email.delivered, email.deferred, email.bounced and email.complained for each recipient, email.suppressed when an address joins the suppression list, email.failed when a send fails, email.draft_failed when a scheduled draft fails, and test.ping when you ask for a test. Each message event carries data["inbox"] and data["message"].
An account has up to 10 webhooks, each with its own secret and the events it wants. Keep the secret the answer holds: no other answer shows it again. email.held needs a key that holds held:read.
hook = blueping.webhooks.create("https://example.com/blueping", events=["email.received", "email.bounced"])
print(hook["secret"]) # whsec_..., store it as BLUEPING_WEBHOOK_SECRET
blueping.webhooks.test(hook["id"]) # sends a signed test.ping
print(blueping.webhooks.deliveries(hook["id"])["data"]) # the latest 50, with their status and last error
blueping.webhooks.update(hook["id"], enabled=False) # off for now
Each event carries a Blueping-Signature header. verify_webhook checks it against the raw request body, refuses events signed more than five minutes ago so they cannot be replayed, and returns the event. It raises WebhookVerificationError when anything is off. Pass the body exactly as it arrived, before any JSON parsing, since parsing and serializing again changes the bytes.
Flask
import os
from flask import Flask, request
from blueping import Blueping, WebhookVerificationError, verify_webhook
app = Flask(__name__)
blueping = Blueping()
WEBHOOK_SECRET = os.environ["BLUEPING_WEBHOOK_SECRET"]
@app.post("/blueping")
def blueping_webhook():
try:
event = verify_webhook(
request.get_data(),
request.headers.get("Blueping-Signature"),
WEBHOOK_SECRET,
)
except WebhookVerificationError:
return "Invalid signature", 400
if event["type"] == "email.received":
message = event["data"]["message"]
print(f"{message['from']['address']} wrote: {message['subject']}")
blueping.messages.reply(message["id"], "Got it, thanks.", idempotency_key=event["id"])
return "", 204
FastAPI
import os
from fastapi import FastAPI, HTTPException, Request, Response
from blueping import WebhookVerificationError, verify_webhook
app = FastAPI()
WEBHOOK_SECRET = os.environ["BLUEPING_WEBHOOK_SECRET"]
@app.post("/blueping")
async def blueping_webhook(request: Request) -> Response:
try:
event = verify_webhook(
await request.body(),
request.headers.get("blueping-signature"),
WEBHOOK_SECRET,
)
except WebhookVerificationError:
raise HTTPException(status_code=400, detail="Invalid signature")
if event["type"] == "email.received":
message = event["data"]["message"]
print(f"{message['from']['address']} wrote: {message['subject']}")
return Response(status_code=204)
Answer with a 2xx status within 10 seconds. Blueping retries failed deliveries for about 31 hours, so the same event can arrive more than once: use event["id"] to skip the ones you already handled.
Testing your handler
sign_webhook builds a valid signature header, so your tests can post events to your own endpoint:
import json
from blueping import sign_webhook
body = json.dumps({
"id": "evt_test",
"type": "test.ping",
"created_at": "2026-11-22T09:00:00.000Z",
"data": {},
}).encode()
response = test_client.post(
"/blueping",
content=body, # data=body with Flask's test client
headers={"Blueping-Signature": sign_webhook(body, WEBHOOK_SECRET)},
)
assert response.status_code == 204
CLI
Installing the package also installs the blueping command. It is small: it gets your agent a key and says where the agent stands.
blueping login # get a key: approve this terminal in your browser
blueping login --start # for agents: print the link and the code, then return
blueping login --check # for agents: prints pending, approved, denied or expired
blueping whoami # which agent and which key this terminal uses
blueping limits # the plan, the claim, and what is left today and this month
blueping upgrade --plan developer # a payment page for the agent's owner: nothing is bought until they pay
blueping logout # delete the saved key
blueping alone signs you in the first time, then shows the plan, the claim, the inboxes and today's sends. upgrade takes --plan developer|startup|scale and --period month|year, and prints a Stripe page for the agent's owner to open in their own browser. Every command takes --json, and the CLI never prints a key. BLUEPING_CLIENT sets how the approval page names who asks, such as Claude Code. python -m blueping works too. Over SSH or in CI, blueping login doesn't open a browser: open its link on any device where you can sign in.
The full email CLI, with inboxes, mail, verification codes and sending, is npx blueping, from the Node.js package.
Configuration
| Setting | Argument | Environment variable | Default |
|---|---|---|---|
| API key | api_key |
BLUEPING_API_KEY |
the key saved by blueping login |
| Base URL | base_url |
BLUEPING_BASE_URL |
the saved key's server, then https://blueping.dev |
Arguments win over environment variables, which win over the saved file.
Use Blueping from Claude Code and other agents
An agent can make and read its own inbox. Paste this into it:
Read https://blueping.dev/agent-onboarding.md and set yourself up with a Blueping inbox.
Or add the hosted MCP server. There is nothing to install, and it signs in through the browser:
claude mcp add --transport http blueping https://blueping.dev/mcp
claude mcp login blueping
Cursor, Codex, ChatGPT, a key instead of OAuth, the skill and the plugin: blueping.dev/agents. LangChain, CrewAI, Pydantic AI, LlamaIndex and the other frameworks, set up in a few lines: blueping.dev/integrations.
License
MIT
Metadata
Release files for blueping 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blueping-2.0.1.tar.gz | 68.8 kB | Without provenance | Details for blueping-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blueping-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for blueping-2.0.1-py3-none-any.whl |
Total release size: 123.8 kB
Release files / blueping-2.0.1.tar.gz
| Download URL | blueping-2.0.1.tar.gz |
|---|---|
| Size | 68.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27e08f062e6c493cd38c2b6d2839eedea9ffd0f5fd82a9f1e46bae1e1cd04aa8
|
|
BLAKE2b-256 checksum How to use checksums |
5e85a4d65cb51d81a8f5931abd727a962ba4353fe60406c4d4dda8fadf0c08a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / blueping-2.0.1-py3-none-any.whl
| Download URL | blueping-2.0.1-py3-none-any.whl |
|---|---|
| Size | 54.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
258e294a9b6f059bb084298959c0729fadf1b664da23e92192efb7e3c8d34fc5
|
|
BLAKE2b-256 checksum How to use checksums |
3fd004257d23df9180e0d10d69ac4fda856fbb6b59470c552d92d80ec2b8d061
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for blueping 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.