# Stato del tuo account via API: servizio, numeri e webhook

`GET /v1/status/me`

`GET /v1/status/me`, con la tua chiave API, dice come sta il **tuo** account: ciò che la pagina di stato pubblica non può mostrare perché non sa chi la legge. Solo dati dell'account della chiave; mai un URL completo, un segreto né importi.

**`service`.** `status` (lo stesso di `GET /v1/account`), `sending.paused` con `reason` (prova scaduta, pagamento non riuscito…), `receiving.stopped` o `receivingUntil` (fino a quando ricevono i tuoi numeri se nulla cambia) e `trial`. Risponde anche con l'invio fermo per la fatturazione.

**`numbers`.** Ogni numero: `status`, `qualityRating`, `canSend` e `canSendReason` (quelli di `GET /v1/connections/{id}/sending-status`), `reasonCodes` e `metaBlocks`: i blocchi di Meta `141006` (metodo di pagamento), `141010` (verifica dell'azienda) e `131031` (account bloccato), ognuno con la sua `explanation` nella lingua di `lang`.

**`webhooks`.** Ogni endpoint: `id`, `host` (solo il dominio: senza percorso, query né credenziali), `scope` (`account` o `number`), `state` (`active`, `paused`, `auto_disabled` se l'abbiamo spento dopo errori consecutivi, `number_disconnected`), `consecutiveFailures`, `failingSince`, `lastSuccessAt`, `lastFailureAt`, `lastStatusCode`, le consegne delle ultime 24 h e fino a 5 `failureReasons24h` con `cause`, `httpStatus`, `count` e un `text` chiaro («Il tuo endpoint ha risposto 500.»). `deliveries24h` somma tutto: `delivered`, `retrying`, `abandoned`, `pending`.

## Esempi

### cURL

```bash
# your account's status, with your webhooks (only your account; never full URLs nor amounts)
curl "https://api.waiaconnect.com/v1/status/me?lang=en" -H "Authorization: Bearer wc_live_YOUR_API_KEY"
# → { "status": { "service": { "status": "active", "sending": { "paused": false, … }, … },
#       "numbers": [ { "id": "conn_…", "status": "connected", "canSend": "blocked", "metaBlocks": [ { "code": 141006, "explanation": "…" } ] } ],
#       "webhooks": [ { "id": "wh_…", "host": "hooks.example.com", "state": "active", "consecutiveFailures": 3,
#                       "failureReasons24h": [ { "cause": "http_error", "httpStatus": 500, "count": 6, "text": "Your endpoint responded 500." } ] } ],
#       "deliveries24h": { "delivered": 1180, "retrying": 4, "abandoned": 2, "pending": 0 } } }
```

### Node.js

```javascript
const H = { "Authorization": "Bearer wc_live_YOUR_API_KEY" };
const { status } = await (await fetch("https://api.waiaconnect.com/v1/status/me?lang=en", { headers: H })).json();
if (status.service.sending.paused) console.log("sending paused:", status.service.sending.reason);
for (const w of status.webhooks) if (w.state !== "active" || w.consecutiveFailures) console.log(w.host, w.state, w.failureReasons24h.map(r => r.text));
for (const n of status.numbers) for (const b of n.metaBlocks) console.log(n.id, b.code, b.explanation);
```

### PHP

```php
<?php
$ch = curl_init("https://api.waiaconnect.com/v1/status/me?lang=en");
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ["Authorization: Bearer wc_live_YOUR_API_KEY"]]);
$s = json_decode(curl_exec($ch), true)["status"];
foreach ($s["webhooks"] as $w) echo $w["host"], " ", $w["state"], " ", $w["consecutiveFailures"], "
";
```

### Python

```python
import requests
s = requests.get("https://api.waiaconnect.com/v1/status/me", params={"lang": "en"}, headers={"Authorization": "Bearer wc_live_YOUR_API_KEY"}).json()["status"]
print(s["service"]["status"], s["deliveries24h"])
for w in s["webhooks"]:
    print(w["host"], w["state"], [r["text"] for r in w["failureReasons24h"]])
```

## Note

- `?lang=es|en|pt|it` sceglie la lingua dei testi (predefinita `en`); decidi su `cause`, `state` e i codici, mai sul testo.
- Una consegna abbandonata si vede e si rinvia con `GET /v1/webhooks/{id}/deliveries` e `POST …/redeliver`.
- Un account sospeso o cancellato riceve `403 ACCOUNT_SUSPENDED`.
