Skip to main content

Arara Python SDK

PyPI Python License Docs

SDK oficial da AraraHQ para Python: envio de WhatsApp, templates, campanhas, contatos, conversas, números, opt-outs, smart links e carteira, com chamadas síncronas e assíncronas.

AraraHQ: WhatsApp para empresas brasileiras, com atendimento em equipe com IA, campanhas para a base e sistemas conectados pela API.

Instalação

pip install ararahq-sdk

Requer Python 3.8 ou superior.

Autenticação

Autenticação por API key (Bearer ara_live_...), criada no painel da Arara. Sem chave no construtor, o SDK lê ARARA_API_KEY.

export ARARA_API_KEY="ara_live_..."

Algumas áreas exigem chave com permissão ADMIN: contacts, conversations, wallet e auth.me(). Com chave sem essa permissão a API responde 403 sem envelope e o SDK levanta AraraForbiddenError (a chave é válida, só não tem permissão).

Uso rápido

from arara_api_sdk import AraraClient
from arara_api_sdk.models.message import SendMessageRequest

with AraraClient() as client:
    response = client.messages.send(
        SendMessageRequest(
            receiver="+5511987654321",
            template_name="pedido_enviado",
            template_variables=["Ana"],
        ),
        idempotency_key="pedido-4521",
    )
    print(response.id, response.status, response.cost)

receiver aceita whatsapp:+5511..., +5511... ou só dígitos. cost pode vir None (modo TEST, mensagem agendada).

Assíncrono:

import asyncio
from arara_api_sdk import AraraClient
from arara_api_sdk.models.message import SendMessageRequest

async def main():
    async with AraraClient() as client:
        response = await client.messages.send_async(
            SendMessageRequest(receiver="+5511987654321", body="Oi!")
        )
        print(response.id)

asyncio.run(main())

Idempotência e retries

messages.send, messages.send_batch e campaigns.create sempre mandam Idempotency-Key. Se você não passar idempotency_key, o SDK gera um UUID v4 por chamada e usa a mesma chave em todas as tentativas daquela chamada: um timeout depois de a API aceitar não vira envio duplicado.

Timeout, erro de conexão, 5xx e 429 são repetidos até max_retries (backoff exponencial, ou o Retry-After do 429). GET, PUT e DELETE repetem livremente; POST e PATCH só repetem quando levam Idempotency-Key não vazia (chave só com espaços conta como ausente; nos métodos do SDK ela é trocada por um UUID gerado).

Recursos

client.auth.me()                                   # GET /auth/me (ADMIN)

client.messages.send(request, idempotency_key=None)
client.messages.send_batch(batch_request)          # até 1000 destinatários
client.messages.get(message_id)
client.messages.list_by_batch(batch_id)

page = client.templates.list(name=None, status=None, page=0, size=50)
page.data, page.pagination.total_pages
client.templates.create(CreateTemplateRequest(name=..., category="UTILITY", body="Olá {{1}}", samples={"1": "Ana"}))
client.templates.get(template_id)                  # sempre pelo id (UUID)
client.templates.get_status(template_id)
client.templates.analytics(template_id, period="30d")
client.templates.delete(template_id)

client.campaigns.create(campaign_request, idempotency_key=None)
client.campaigns.list(page=0, size=20, status=None)   # content, total_pages, total_elements
client.campaigns.get(campaign_id)
client.campaigns.cancel(campaign_id)

client.opt_outs.list()
client.opt_outs.create("+5511987654321", reason="pediu para sair")
client.opt_outs.get("+5511987654321")
client.opt_outs.delete("+5511987654321")

client.smart_links.list(page=0, size=50)           # Page com data e pagination
client.contacts, client.conversations, client.numbers, client.wallet

Para achar um template pelo nome, use client.templates.list(name="...") e pegue o id do resultado.

Todo método tem a versão _async (send_async, list_async, ...).

Erros

Todo erro herda de AraraError e traz status_code, code, message, details e retry_after, lidos do envelope {"error": {"code", "message", "details"}}.

Situação Exceção
401 AraraAuthError
403 sem envelope (corpo do Spring {timestamp, status, error, path} ou vazio): chave inválida, sem permissão (ex.: não ADMIN) ou rota fora da allowlist AraraForbiddenError (mensagem = campo error do corpo)
403 PLAN_FEATURE_LOCKED AraraPlanFeatureLockedError (feature, current_plan, upgrade_to)
403 com outro código (PLAN_LIMIT_REACHED, ACCOUNT_NOT_ACTIVATED...) AraraApiError (com code)
400 AraraValidationError
404 AraraResourceNotFoundError
422 (INVALID_RECIPIENT, RECIPIENT_OPTED_OUT, TEMPLATE_PAUSED...) AraraUnprocessableError
429 AraraRateLimitError
5xx AraraServerError
timeout / conexão AraraTimeoutError / AraraConnectionError
from arara_api_sdk import AraraPlanFeatureLockedError, AraraUnprocessableError

try:
    client.campaigns.create(request)
except AraraPlanFeatureLockedError as e:
    print(f"Disponível a partir do plano {e.upgrade_to}")
except AraraUnprocessableError as e:
    print(e.code, e.details)

Configuração

client = AraraClient(
    api_key="...",
    timeout=30.0,
    max_retries=3,
    base_url="https://api.ararahq.com",
)

Também por variáveis de ambiente: ARARA_API_KEY, ARARA_BASE_URL, ARARA_TIMEOUT, ARARA_MAX_RETRIES.

Desenvolvimento

python -m venv .venv && source .venv/bin/activate
pip install -e ".[test]" ruff build
ruff check arara_api_sdk
python -m pytest
python -m build

Publicação: cada push na main publica no PyPI (Trusted Publishing) se a versão do pyproject.toml ainda não existir lá, e cria a tag e o release no GitHub. Ver CHANGELOG.md.

Licença

MIT. Ver LICENSE.

Metadata

Release files for ararahq-sdk 2.0.1

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

Source distribution (sdist)

Source distribution for ararahq-sdk 2.0.1
File Size Uploaded Provenance Actions
ararahq_sdk-2.0.1.tar.gz 21.1 kB With provenance Details for ararahq_sdk-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ararahq-sdk 2.0.1
File Interpreter ABI Platform Actions
ararahq_sdk-2.0.1-py3-none-any.whl Python 3 none any Details for ararahq_sdk-2.0.1-py3-none-any.whl

Total release size: 51.0 kB

Release files / ararahq_sdk-2.0.1.tar.gz

Download URL ararahq_sdk-2.0.1.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
be7cacc6621d275fa88125774e2992dd87130114c5787504a3cf17980d31b2e8
BLAKE2b-256 checksum
How to use checksums
ed0c0edafc4885ebe3cf49eb3db539bbfd7ba63fb8413b66f1f296b19fe86d20
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 Nov 15, 2026.

Transparency log

Release files / ararahq_sdk-2.0.1-py3-none-any.whl

Download URL ararahq_sdk-2.0.1-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4390ed0ab7fd635d16a08d3f8a1e36fda42017b32d52ae49438c509a1e93cbee
BLAKE2b-256 checksum
How to use checksums
9723559f43a24b459c228e28fa738f07cc81ccc1dde6ea37e2c7c45ad5fc4a3c
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 Nov 15, 2026.

Transparency log

Security for ararahq-sdk 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ararahq_sdk-2.0.1.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 Nov 15, 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