Skip to main content

Official Python SDK for the Pilot Status public API.

Project description

pilot-status (Python SDK)

Official Python SDK for the Pilot Status public API.

Installation

pip install pilot-status

Quickstart

Create an API key in the dashboard and use it only on the backend.

import os

from pilot_status import PilotStatusClient

client = PilotStatusClient(
    api_key=os.environ["PILOT_STATUS_API_KEY"],
)

accepted = client.messages.send(
    {
        "templateId": "onboarding-test",
        "destinationNumber": "+5511999999999",
        "variables": {"name": "John"},
    }
)

message = client.messages.get(accepted["id"])
print(message["status"])

Management (projects, API keys, numbers)

These endpoints create resources within the scope (project + environment) of the current api_key.

Projects

project = client.projects.create(
    {
        "name": "My Project",
        "description": "Optional description",
    }
)

projects = client.projects.list()

API keys

key = client.api_keys.create(
    {
        "name": "Backend Key",
        "retentionDays": 30,
    }
)

keys = client.api_keys.list()

Numbers (WhatsApp)

all_numbers = client.numbers.list()
# JSON array: id, instanceName, primaryLink/secondaryLink, apiKeys refs — no upstream tokens

created = client.numbers.create(
    {
        "name": "My WhatsApp",
        "number": "+5511999999999",
    }
)
# created["qrcodeBase64"], created["pairingCode"] (letter code or None)

refreshed = client.numbers.connect(created["instance"]["id"])
# refreshed["qrcodeBase64"], refreshed["pairingCode"]

status = client.numbers.get_status(created["instance"]["id"])
print(status["state"])

Opt-in check (destination authorization)

In LIVE, sending may require opt-in when using the Pilot Status WhatsApp number. You can check whether a destination is already authorized for your project:

opt_in = client.messages.check_opt_in("+5511999999999")
if not opt_in["authorized"]:
    raise Exception(f"Missing opt-in: {opt_in['reason']}")

Analytics

stats = client.analytics.get_dashboard_stats(tz="America/Sao_Paulo")
print(stats["totalSent"], stats["failureRate"])

Webhooks (parse / validation)

from pilot_status import parse_customer_webhook

def handler(payload: dict):
    event = parse_customer_webhook(payload)

    if event["event"] == "message.failed":
        print(event["data"]["errorMessage"])

Notes:

  • Customer webhook payloads do not include: projectSlug, lastMessageId. Optional correlationId (same as HTTP 202 when present) may appear on outbound status events and on message.reply / message.received when correlated to a prior send.
  • message.received includes fromMe (boolean).
  • message.group is delivered for inbound group messages (includes groupName).
  • message.newsletter is delivered for inbound channel messages (JID ending in @newsletter).
  • Supported events in the parser: message.sent, message.delivered, message.read, message.failed, message.reply, message.received, message.group, message.newsletter, optin.created.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pilot_status-1.1.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pilot_status-1.1.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file pilot_status-1.1.0.tar.gz.

File metadata

  • Download URL: pilot_status-1.1.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pilot_status-1.1.0.tar.gz
Algorithm Hash digest
SHA256 12b26f1ab49842fbd06b738dd82b8860624c3dafe3d7f4296940c6ae74e10d3f
MD5 645df423b2adf562a724005abd8c81b4
BLAKE2b-256 308303759404ae28165dc891c904e0b59537447a9e3590ff436df7a369dc8b4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pilot_status-1.1.0.tar.gz:

Publisher: publish-pypi.yml on oismaelash/pilot-status-nextjs-typescript-frontend-backend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pilot_status-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pilot_status-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pilot_status-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ad7f682049bbcacb83cdbad0b17b246313612bcafb1cd9fd13844b52dc11f2b
MD5 4be9e1fb7981ba8e1b0ea01c0f4c9b35
BLAKE2b-256 eb5fbc5492001bfbaad13d02e4569bce23d452e5f6ea33b34ce116f9cdb01aa3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pilot_status-1.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on oismaelash/pilot-status-nextjs-typescript-frontend-backend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page