Airbox Python SDK
WhatsApp and Instagram messages through one REST API, from Python.
Every call of the API, grouped by resource: messages, templates, media, contacts, channels and test.
Install
pip install airboxhq
Python 3.9 or newer. No dependencies.
Make the client
import os
from airboxhq import Airbox
client = Airbox(api_key=os.environ["AIRBOX_API_KEY"])
The key falls back to AIRBOX_API_KEY when you leave it out. A test key sends to the simulator, so you can try every call before connecting a number.
Messages
data = client.messages.send_text(
to="+77011234567",
body="Your order is ready",
idempotency_key="order-1042",
)
print(data)
channel defaults to "auto", which replies on the channel the customer last wrote on. The same idempotency_key never sends twice.
Images, video, audio and voice take a url or the media_id of an upload. Images and video take a caption too.
client.messages.send_image(to="+77011234567", url="https://example.com/receipt.jpg", caption="Your receipt")
client.messages.send_video(to="+77011234567", media_id="med_123")
client.messages.send_audio(to="+77011234567", url="https://example.com/song.mp3")
client.messages.send_voice(to="+77011234567", media_id="med_456")
messages.send(**params) still takes the body of POST /v1/messages as it is. Read a message back with its status:
message = client.messages.get(data["id"])
print(message["status"])
Templates
A template is how you write first, outside the 24 hour window.
templates = client.templates.list()
client.templates.send(
"order_ready",
to="+77011234567",
language="ru",
parameters=["1042"],
)
parameters is a list for positional placeholders or a dict for named ones. channel defaults to "whatsapp".
Media
uploaded = client.media.upload("receipt.pdf")
client.messages.send_image(to="+77011234567", media_id=uploaded["id"])
data = client.media.download("med_123")
with open("photo.jpg", "wb") as file:
file.write(data)
upload takes bytes, a path or a binary file object. Pass filename and content_type when they cannot be guessed. download returns the raw bytes.
Contacts
page = client.contacts.list(phone="+77011234567")
print(page["data"], page["has_more"])
contact = client.contacts.get(page["data"][0]["id"])
conversation = client.contacts.list_messages(contact["id"], limit=50)
print([message["direction"] for message in conversation["data"]])
client.contacts.grant_consent("+77011234567")
client.contacts.withdraw_consent("+77011234567")
list and list_messages return a page, {"data": [...], "has_more": ...}, newest first for messages. Pass the id of the last item as after to get the next page, and limit (1 to 100) to size it. Params you leave out are not sent.
Channels
for channel in client.channels.list():
print(channel)
Test
Simulate a customer writing to you. Only a test key may call it, otherwise the API answers test_key_required.
client.test.inbound(from_="+77011234567", text={"body": "Hello"}, name="Aida")
With asyncio
import asyncio
import os
from airboxhq import AsyncAirbox
async def main():
async with AsyncAirbox(api_key=os.environ["AIRBOX_API_KEY"]) as client:
data = await client.messages.send_text(to="+77011234567", body="Hi")
print(data)
asyncio.run(main())
Every resource and call is here, awaited: await client.templates.list().
Errors
A refused request raises airboxhq.AirboxError with the API's own code and the request id:
from airboxhq import AirboxError
try:
client.messages.send_text(to="+77011234567", body="Hi")
except AirboxError as error:
print(error.code, error.request_id)
License
MIT
Metadata
Release files for airboxhq 0.3.0
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 |
|---|---|---|---|---|
| airboxhq-0.3.0.tar.gz | 11.5 kB | With provenance | Details for airboxhq-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| airboxhq-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for airboxhq-0.3.0-py3-none-any.whl |
Total release size: 19.9 kB
Release files / airboxhq-0.3.0.tar.gz
| Download URL | airboxhq-0.3.0.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ac05dc5bc5f376fdff6c902e7b1f385fba9643bc5388a26221e9d31eaa90f94
|
|
BLAKE2b-256 checksum How to use checksums |
1e84ffb7589d0df251faea6d3ce83d49726c7f2506b054c8aaf2bdaa28a0ce73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logRelease files / airboxhq-0.3.0-py3-none-any.whl
| Download URL | airboxhq-0.3.0-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
77326fd3518a7a39a1cd065c2fe7381aab49ca914e9bbd4dd853b1b29254750b
|
|
BLAKE2b-256 checksum How to use checksums |
39fec4ee265aa7200332009dbb62d3ec4733a4f0e98421ffba0678c2f951d007
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logSecurity for airboxhq 0.3.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for airboxhq-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logA 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.