Lebara Usage API

Personal, self-hosted integration. This page is a local reference; the full setup guide is in the repository README.

Authentication required. Every /api/v1/… route needs Authorization: Bearer <API_BEARER_TOKEN>. /health and /ready are public. Never put the token in a URL or share it.

Endpoints

MethodPathPurpose
GET/healthLiveness: {"status":"ok"}
GET/readyReadiness and whether a Lebara session is available
GET/api/v1/auth/statusSafe session status; add ?refresh=true to verify upstream
POST/api/v1/auth/startStart the supported login flow (credentials must be in the service environment)
GET/api/v1/numbersNumbers available to the account
GET/api/v1/usage?msisdn=…&refresh=falseCurrent usage snapshot
GET/api/v1/usage/history?msisdn=…&start_date=YYYY-MM-DDMonthly activity history
GET/api/v1/usage/daily?msisdn=…&days=14Daily data derived from local samples
POST/api/v1/usage/refreshRefresh one number ({"msisdn":"…"}) or all known numbers

Examples

curl -s -H "Authorization: Bearer $TOKEN" http://127.0.0.1:8686/api/v1/numbers
curl -s -H "Authorization: Bearer $TOKEN" \
  "http://127.0.0.1:8686/api/v1/usage?refresh=true"
curl -s -H "Authorization: Bearer $TOKEN" \
  "http://127.0.0.1:8686/api/v1/usage/history?start_date=2025-01-01"
curl -s -H "Authorization: Bearer $TOKEN" \
  "http://127.0.0.1:8686/api/v1/usage/daily?days=14"

Error shape

{"error":{"code":"reauth_required","message":"The Lebara session is missing or has expired."}}

Codes include unauthorized, reauth_required, invalid_msisdn, invalid_date, invalid_parameter, rate_limited, upstream_timeout, upstream_error, upstream_schema_changed, and login_challenge_required.

Logging in

Start the login with:

curl -s -X POST -H "Authorization: Bearer $TOKEN" http://127.0.0.1:8686/api/v1/auth/start

If Lebara presents a Cloudflare/Turnstile challenge, complete it in the visible Chromium window (run with BROWSER_HEADLESS=false). The service never defeats or bypasses a challenge.

Units

Current-plan data is normalised to decimal GB (1 GB = 1000 MB). Voice is minutes, SMS is messages. History data rows are reported upstream in MB and include both value (MB) and value_gb. Unlimited allowances keep unlimited: true; numeric totals are included only when upstream supplies them.

The upstream activity history is monthly only. /usage/daily is derived from optional local samples; a new installation cannot reconstruct days before sampling began.