BroadNet
Python·/python

Python (REST).

There is no Python SDK: call the REST API directly with requests. POST a JSON body to /sms/sendSms with a Bearer token, or generate a typed client from the OpenAPI 3.1 spec with openapi-generator.

5 min read·Updated September 2026·Section 14 of 15Developer Hub

Overview

Call the BroadNet REST API from Python with the requests or httpx libraries. There is no BroadNet Python package: the only official SDK is for TypeScript and Node.js, not Python. If you want a typed Python client, generate one from the OpenAPI spec with openapi-generator; otherwise the plain HTTP calls below are all you need.

Error handling

Errors return an HTTP status code and an ExceptionResponse JSON body (status, error, message, errorCode, requestUri). resp.raise_for_status() turns them into exceptions. Retry only on network errors and 5xx responses, with backoff; once a call has returned a message ID the send was accepted, so don't resubmit it blindly.

Requirements

Any supported Python 3 version. The synchronous example uses requests and the async example uses httpx; install whichever you use.

Examples

Copy, paste, replace the placeholders — these examples call the production API as written.

terminalbash
pip install requests httpx
↳ Plain HTTP libraries. No BroadNet package is required.
send.pypython
import os, requests

r = requests.post(
    "https://api.broadnet.me/sms/sendSms",
    headers={"Authorization": f"Bearer {os.environ['BROADNET_TOKEN']}"},
    json={
        "senderId": "BroadNet",
        "destinationNumber": "447700900123",
        "message": "Your verification code is 482913",
        "messageType": "TEXT",
    },
)

print(r.status_code, r.text)  # message ID
↳ 200 OK · the response body is the message ID.
async.pypython
import asyncio
import os

import httpx

URL = "https://api.broadnet.me/sms/sendSms"
HEADERS = {"Authorization": f"Bearer {os.environ['BROADNET_TOKEN']}"}


async def send(client: httpx.AsyncClient, number: str, text: str) -> str:
    resp = await client.post(
        URL,
        headers=HEADERS,
        json={
            "senderId": "BroadNet",
            "destinationNumber": number,
            "message": text,
            "messageType": "TEXT",
        },
    )
    resp.raise_for_status()
    return resp.text  # message ID


async def main() -> None:
    recipients = ["447700900123", "447700900124", "447700900125"]
    async with httpx.AsyncClient(timeout=10) as client:
        ids = await asyncio.gather(
            *(send(client, n, "Your code is 482913") for n in recipients)
        )
    print(ids)


if __name__ == "__main__":
    asyncio.run(main())
↳ For large lists, use POST /sms/sendbulk with a file upload instead of many single sends.
terminalbash
# Optional: generate a typed Python client from the OpenAPI spec
curl -O https://www.broadnet.me/developers/openapi.yaml
npx @openapitools/openapi-generator-cli generate \
  -i openapi.yaml -g python -o broadnet-python
Test access · reply within one business day

Request test access and build with confidence.

We reply within one business day with test credentials. Then install the TypeScript SDK or call the REST API from any language, and send your first test message to your own number.

$npm install @broadnet/cpaas-sdk axiosready