Skip to main content

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

client.contacts.grant_consent("+77011234567")
client.contacts.withdraw_consent("+77011234567")

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.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for airboxhq 0.2.0
File Size Uploaded Provenance Actions
airboxhq-0.2.0.tar.gz 9.9 kB With provenance Details for airboxhq-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for airboxhq 0.2.0
File Interpreter ABI Platform Actions
airboxhq-0.2.0-py3-none-any.whl Python 3 none any Details for airboxhq-0.2.0-py3-none-any.whl

Total release size: 17.7 kB

Release files / airboxhq-0.2.0.tar.gz

Download URL airboxhq-0.2.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
900479e894ca34a87599d4b0a9a1362a9cc5efded55fe4b8f6ea7eece0478811
BLAKE2b-256 checksum
How to use checksums
5062e52ab2208548d432fda332e72833661ff558c6eb65338c3931370ca520aa
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 log

Release files / airboxhq-0.2.0-py3-none-any.whl

Download URL airboxhq-0.2.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31ca433f067317abe839111972abbd65fad55633d025226b3942732340ffe5d2
BLAKE2b-256 checksum
How to use checksums
cd1d3f37776690f9bd12648718dfe7f11b4affa6b960865d83b1e57b799788b4
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 log

Security for airboxhq 0.2.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.

Select from 2 files

Attestation for airboxhq-0.2.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 log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page