Omni Connect

Eventi (webhook)

Omni Connect ti avvisa di quello che succede con una POST firmata al tuo indirizzo: un messaggio arrivato, un esercente collegato, un modello approvato. Questa pagina spiega il formato, la firma, i tentativi e tutti gli eventi, con un esempio per ognuno.

La busta comune#

Ogni evento ha la stessa forma:

JSON
{
  "id": "cmesempio0000delivery0001",
  "event": "message.received",
  "data": { "accountId": "cmesempio0000account00001" },
  "sentAt": "2026-10-01T10:30:01.000Z"
}
Campo Significato
id Identificativo della consegna. Uguale a ogni nuovo tentativo: usalo per la deduplica
event Nome dell'evento, per esempio message.received
data Il contenuto, diverso per ogni evento
sentAt Ora di questo tentativo di invio. Cambia a ogni tentativo

Header della richiesta:

Header Valore
Content-Type application/json
User-Agent OmniConnect/0.1
X-OmniConnect-Event Il nome dell'evento
X-OmniConnect-Delivery-Id L'id della consegna
X-OmniConnect-Signature sha256= più la firma HMAC del body

La firma#

X-OmniConnect-Signature = sha256= + HMAC-SHA256 esadecimale del body grezzo, con il tuo segreto per gli eventi come chiave.

In Node.js:

JavaScript
const crypto = require('node:crypto');

function firmaValida(body, firma, segreto) {
  const attesa = 'sha256=' + crypto.createHmac('sha256', segreto).update(body).digest('hex');
  const a = Buffer.from(attesa);
  const b = Buffer.from(String(firma || ''));
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

In PHP:

PHP
<?php
// Con PHP-FPM il segreto arriva da env[...] nel pool, fastcgi_param o SetEnv.
$segreto = getenv('OMNI_WEBHOOK_SECRET') ?: ($_SERVER['OMNI_WEBHOOK_SECRET'] ?? '');
$body = file_get_contents('php://input');
$attesa = 'sha256=' . hash_hmac('sha256', $body, $segreto);
$valida = $segreto !== '' && hash_equals($attesa, $_SERVER['HTTP_X_OMNICONNECT_SIGNATURE'] ?? '');

Gli esempi completi, con deduplica e risposta, sono in Inizia in 30 minuti.

Tentativi e backoff#

Gli eventi passano da una coda salvata su database: non si perdono se il motore si riavvia.

Le consegne fallite si leggono e si ritentano:

bash
curl -s "$OMNI_URL/v1/deliveries?status=failed&limit=100" -H "Authorization: Bearer $OMNI_KEY"
JSON
{
  "items": [
    {
      "id": "cmesempio0000delivery0009",
      "event": "message.received",
      "status": "failed",
      "attempts": 1,
      "nextAttemptAt": null,
      "lastError": "HTTP 404",
      "data": { "accountId": "cmesempio0000account00001" },
      "createdAt": "2026-10-01T10:30:00.000Z",
      "updatedAt": "2026-10-01T10:30:00.000Z"
    }
  ]
}

status può essere pending (in coda, con nextAttemptAt), delivered o failed. limit va da 1 a 500 (predefinito 100). Per ritentare subito una consegna, anche già fallita:

bash
curl -s -X POST "$OMNI_URL/v1/deliveries/cmesempio0000delivery0009/retry" -H "Authorization: Bearer $OMNI_KEY"

Idempotenza e ordine#

Elenco degli eventi#

Evento Quando
account.connected Esercente collegato, numero registrato o collegato
account.activated Account diventato active
account.health Cambia lo stato letto da Meta
account.disconnected Account scollegato
account.reconnected Account ripristinato
account.token_invalid Token dell'esercente non più valido
account.token_expiring Token in scadenza entro 7 giorni
account.alert Avviso di Meta
account.sync_requested Sincronizzazione coexistence chiesta a Meta
message.received Messaggio in arrivo da un cliente (anche allegati, vocali e reazioni)
message.status Stato di consegna di un messaggio inviato
message.echo Messaggio scritto dall'esercente nell'app (coexistence)
message.edited Messaggio modificato
message.revoked Messaggio cancellato
contact.changed Un cliente ha cambiato numero o identificativo
contact.preference Un cliente ha fermato o riattivato i messaggi marketing
conversation.handover Una conversazione è passata a un altro gestore, o è tornata
history.chunk Blocco di storico chat salvato (coexistence)
history.completed Storico completo (coexistence)
history.media Allegati dello storico disponibili (coexistence)
contacts.synced Rubrica dell'app aggiornata (coexistence)
template.status Modello approvato, rifiutato, sospeso o disattivato
template.category Categoria del modello cambiata da Meta
template.quality Qualità del modello cambiata
template.components Contenuto del modello cambiato da Meta
template.create_failed Modello del catalogo non creato su un esercente

Negli esempi data è completo; gli identificativi sono finti.

Eventi dell'account#

account.connected#

L'esercente ha finito il collegamento. Arriva anche dopo register (via: "register"), quando il numero coexistence arriva dopo (via: "refresh-phone") e quando Meta conferma il collegamento di un account rimasto connecting. L'esempio è quello del collegamento dal pulsante; le altre varianti hanno meno campi:

Variante via Campi che mancano rispetto all'esempio
Collegamento dal pulsante assente nessuno
Dopo register "register" coexistence, registerError, externalRef, sessionToken
Numero coexistence arrivato dopo "refresh-phone" externalRef, sessionToken (qui coexistence è true)
Conferma di Meta assente displayPhone, coexistence, registered, registerError, externalRef, sessionToken

Leggi i campi con un valore predefinito e collega l'evento al tuo esercente con accountId: externalRef c'è solo la prima volta.

JSON
{
  "id": "cmesempio0000delivery0001",
  "event": "account.connected",
  "data": {
    "accountId": "cmesempio0000account00001",
    "wabaId": "100000000000001",
    "phoneNumberId": "300000000000001",
    "displayPhone": "+39 095 000 0000",
    "status": "awaiting_payment_method",
    "coexistence": false,
    "registered": true,
    "registerError": null,
    "externalRef": "pizzeria-esempio-42",
    "sessionToken": "0123456789abcdef0123456789abcdef0123456789abcdef",
    "businessId": "200000000000001",
    "links": {
      "whatsappManager": "https://business.facebook.com/latest/whatsapp_manager/phone_numbers/?business_id=200000000000001&tab=phone-numbers&asset_id=100000000000001",
      "businessSettings": "https://business.facebook.com/latest/settings/whatsapp_account?business_id=200000000000001&selected_asset_id=100000000000001&selected_asset_type=whatsapp-business-account",
      "paymentMethod": "https://business.facebook.com/wa/manage/home/",
      "paymentHelp": "https://www.facebook.com/business/help/488291839463771",
      "deepLinked": true
    }
  },
  "sentAt": "2026-10-01T09:30:00.000Z"
}

registerError vale null, pin_mismatch (il numero ha già un PIN a due passaggi) o register_failed (verifica non completata). Vedi problemi tipici.

account.activated#

L'account è diventato active. via: "template" = Meta ha consegnato un messaggio a pagamento; via: "health_status" = Meta dice che il numero può inviare, ma questo non conferma il pagamento: lo conferma solo status.paymentConfirmedAt (pagamento). activatedAt è uguale a ogni tentativo di consegna.

JSON
{
  "id": "cmesempio0000delivery0002",
  "event": "account.activated",
  "data": {
    "accountId": "cmesempio0000account00001",
    "wabaId": "100000000000001",
    "phoneNumberId": "300000000000001",
    "status": "active",
    "via": "template",
    "activatedAt": "2026-10-01T09:40:00.000Z"
  },
  "sentAt": "2026-10-01T09:40:00.000Z"
}

account.health#

Qualcosa è cambiato nello stato letto da Meta. changed dice cosa: canSend, paymentMethodMissing, qualityRating, messagingLimit, nameStatus, paymentConfirmedAt, status. Con "status" in changed l'account è tornato awaiting_payment_method per un problema di pagamento. via dice chi ha letto: onboarding, link-account, api, job, webhook, send. snapshot è la fotografia, previous quella precedente (o null).

JSON
{
  "id": "cmesempio0000delivery0003",
  "event": "account.health",
  "data": {
    "accountId": "cmesempio0000account00001",
    "wabaId": "100000000000001",
    "phoneNumberId": "300000000000001",
    "status": "active",
    "paymentConfirmedAt": "2026-10-01T09:40:00.000Z",
    "changed": ["qualityRating"],
    "via": "job",
    "snapshot": {
      "checkedAt": "2026-10-02T09:00:00.000Z",
      "canSend": "available",
      "healthScope": "phone",
      "paymentMethodMissing": false,
      "paymentConfirmedAt": "2026-10-01T09:40:00.000Z",
      "problems": [],
      "entities": [
        { "type": "PHONE_NUMBER", "id": "300000000000001", "canSend": "available" }
      ],
      "phone": {
        "id": "300000000000001",
        "status": "CONNECTED",
        "qualityRating": "YELLOW",
        "messagingLimit": "TIER_250",
        "nameStatus": "APPROVED",
        "newNameStatus": null,
        "codeVerificationStatus": "VERIFIED",
        "platformType": "CLOUD_API",
        "accountMode": "LIVE",
        "displayPhoneNumber": "+39 095 000 0000",
        "verifiedName": "Pizzeria Esempio",
        "isOnBizApp": false,
        "throughputLevel": "STANDARD"
      },
      "waba": {
        "id": "100000000000001",
        "name": "Pizzeria Esempio",
        "accountReviewStatus": "APPROVED",
        "businessVerificationStatus": "verified",
        "messagingLimit": null
      },
      "fieldsDropped": [],
      "readErrors": []
    },
    "previous": {
      "checkedAt": "2026-10-01T09:45:00.000Z",
      "canSend": "available",
      "healthScope": "phone",
      "paymentMethodMissing": false,
      "paymentConfirmedAt": "2026-10-01T09:40:00.000Z",
      "problems": [],
      "entities": [
        { "type": "PHONE_NUMBER", "id": "300000000000001", "canSend": "available" }
      ],
      "phone": {
        "id": "300000000000001",
        "status": "CONNECTED",
        "qualityRating": "GREEN",
        "messagingLimit": "TIER_250",
        "nameStatus": "APPROVED",
        "newNameStatus": null,
        "codeVerificationStatus": "VERIFIED",
        "platformType": "CLOUD_API",
        "accountMode": "LIVE",
        "displayPhoneNumber": "+39 095 000 0000",
        "verifiedName": "Pizzeria Esempio",
        "isOnBizApp": false,
        "throughputLevel": "STANDARD"
      },
      "waba": {
        "id": "100000000000001",
        "name": "Pizzeria Esempio",
        "accountReviewStatus": "APPROVED",
        "businessVerificationStatus": "verified",
        "messagingLimit": null
      },
      "fieldsDropped": [],
      "readErrors": []
    },
    "links": {
      "whatsappManager": "https://business.facebook.com/latest/whatsapp_manager/phone_numbers/?business_id=200000000000001&tab=phone-numbers&asset_id=100000000000001",
      "businessSettings": "https://business.facebook.com/latest/settings/whatsapp_account?business_id=200000000000001&selected_asset_id=100000000000001&selected_asset_type=whatsapp-business-account",
      "paymentMethod": "https://business.facebook.com/wa/manage/home/",
      "paymentHelp": "https://www.facebook.com/business/help/488291839463771",
      "deepLinked": true
    }
  },
  "sentAt": "2026-10-02T09:00:01.000Z"
}

account.disconnected#

Meta ha scollegato l'account: l'invio non è più possibile. reason vale partner_app_uninstalled, partner_removed, account_deleted, account_offboarded, disabled_update o relinked_elsewhere (l'esercente si è collegato con un altro gestionale). In coexistence disconnectReason spiega il perché e next cosa fare.

JSON
{
  "id": "cmesempio0000delivery0004",
  "event": "account.disconnected",
  "data": {
    "accountId": "cmesempio0000account00001",
    "wabaId": "100000000000001",
    "event": "PARTNER_REMOVED",
    "reason": "partner_removed",
    "banState": null,
    "disconnectReason": "PRIMARY_INACTIVITY",
    "initiatedBy": "SYSTEM",
    "coexistence": true,
    "next": "Far aprire l'app WhatsApp Business sul telefono del cliente (telefono inattivo): il collegamento si ripristina con ACCOUNT_RECONNECTED o rifacendo l'onboarding coexistence",
    "status": "disconnected"
  },
  "sentAt": "2026-10-15T08:00:00.000Z"
}

disconnectReason (coexistence): PRIMARY_INACTIVITY e COMPANION_INACTIVITY (basta riaprire l'app), ACCOUNT_DISCONNECTED, BUSINESS_DOWNGRADE, CHANGE_NUMBER, USER_RE_REGISTERED (serve un nuovo collegamento), oppure null. initiatedBy vale USER, SYSTEM o null.

account.reconnected#

Meta ha ripristinato l'account: riapertura dell'app in coexistence (event: "ACCOUNT_RECONNECTED") o account riabilitato (event: "DISABLED_UPDATE" con banState: "REINSTATE"). status è lo stato dopo il ripristino.

JSON
{
  "id": "cmesempio0000delivery0005",
  "event": "account.reconnected",
  "data": {
    "accountId": "cmesempio0000account00001",
    "wabaId": "100000000000001",
    "event": "ACCOUNT_RECONNECTED",
    "coexistence": true,
    "status": "active"
  },
  "sentAt": "2026-10-15T09:00:00.000Z"
}

account.token_invalid#

Il token di Meta dell'esercente è scaduto o revocato: l'account è error. Serve un nuovo collegamento. reason vale expired, invalidated o invalid.

JSON
{
  "id": "cmesempio0000delivery0006",
  "event": "account.token_invalid",
  "data": {
    "accountId": "cmesempio0000account00001",
    "wabaId": "100000000000001",
    "phoneNumberId": "300000000000001",
    "status": "error",
    "reason": "expired",
    "next": "Rifare il collegamento WhatsApp (nuova sessione di onboarding)"
  },
  "sentAt": "2026-11-30T10:00:00.000Z"
}

account.token_expiring#

Il token dell'esercente scade entro 7 giorni. Il controllo gira una volta al giorno. Chiedi all'esercente di rifare il collegamento prima della scadenza.

JSON
{
  "id": "cmesempio0000delivery0007",
  "event": "account.token_expiring",
  "data": {
    "accountId": "cmesempio0000account00001",
    "wabaId": "100000000000001",
    "phoneNumberId": "300000000000001",
    "expiresAt": "2026-11-30T09:30:00.000Z",
    "daysLeft": 5,
    "expired": false,
    "next": "Far rifare il collegamento WhatsApp al cliente (nuova sessione di onboarding) prima della scadenza"
  },
  "sentAt": "2026-11-25T03:00:00.000Z"
}

account.alert#

Un avviso di Meta che non cambia lo stato dell'account: qualità o limite del numero, nome visualizzato, restrizioni, disattivazione programmata, revisione dell'account, sicurezza. field dice da dove viene; value è il contenuto originale di Meta.

field Cosa avvisa event
phone_number_quality_update Cambia la capacità di invio del numero assente
phone_number_name_update Esito della revisione del nome visualizzato (in value.decision) assente
account_alerts Avvisi di Meta: aumento del limite negato, account ufficiale, foto del profilo persa assente
account_update Restrizioni, violazioni e altri eventi dell'account Il nome di Meta, per esempio ACCOUNT_RESTRICTION
account_review_update Esito della revisione dell'account WhatsApp APPROVED, REJECTED, PENDING, DEFERRED
business_capability_update Cambiano il limite di messaggi o il numero massimo di numeri assente
security In WhatsApp Manager è stato cambiato o disattivato il PIN della verifica in due passaggi PIN_CHANGED, PIN_RESET_REQUEST, PIN_REQUEST_SUCCESS
business_username_updates Stato del nome utente WhatsApp dell'esercente APPROVED, RESERVED, DELETED
business_status_update Avviso sul portfolio business dell'esercente Il nome di Meta, per esempio COMPROMISED_NOTIFICATION
message_template_status_update L'account ha raggiunto il numero massimo di modelli LIMIT_EXCEEDED
messages Errore di Meta che riguarda il numero e non un messaggio preciso (i codici sono in errors) messages_error
messages Avviso di sistema di Meta su un cliente, diverso dal cambio di numero (la frase di Meta è in text, il tipo in systemType) system_message
history, messages Avvisi della coexistence Vedi sotto

Dopo phone_number_name_update, account_review_update e una restrizione o violazione dell'account, il motore rilegge lo stato da Meta: subito, oppure entro un minuto se lo aveva appena letto. Se qualcosa è cambiato ricevi anche account.health.

Con security l'avviso porta hint, una frase che dice cosa fare. Se l'account WhatsApp Business dell'esercente ha più numeri, l'avviso può riguardare un numero diverso da quello collegato: il numero è in value.display_phone_number e hint lo dice.

JSON
{
  "id": "cmesempio0000delivery0008",
  "event": "account.alert",
  "data": {
    "accountId": "cmesempio0000account00001",
    "wabaId": "100000000000001",
    "field": "account_update",
    "event": "partner_added_without_number",
    "value": {
      "event": "PARTNER_ADDED",
      "waba_info": { "waba_id": "100000000000001", "owner_business_id": "200000000000001" }
    }
  },
  "sentAt": "2026-10-01T09:30:00.000Z"
}

Valori di event che arrivano dal motore: partner_added_without_number (account collegato senza numero registrato), DISABLED_UPDATE con banState: "SCHEDULE_FOR_DISABLE" (Meta disattiverà l'account), e in coexistence history_sync_declined (l'esercente non ha condiviso la cronologia), history_sync_error e unsupported_message_131060 (un messaggio che la Cloud API non può consegnare: l'esercente lo trova nell'app). Gli altri eventi di account_update arrivano con il nome di Meta.

account.sync_requested#

Coexistence: Meta ha accettato la sincronizzazione della rubrica (kind: "contacts") o dello storico (kind: "history"). requestId è da citare al supporto di Meta in caso di problemi.

JSON
{
  "id": "cmesempio0000delivery0010",
  "event": "account.sync_requested",
  "data": {
    "accountId": "cmesempio0000account00001",
    "wabaId": "100000000000001",
    "phoneNumberId": "300000000000001",
    "kind": "history",
    "syncType": "history",
    "requestId": "700000000000001",
    "requestedAt": "2026-10-01T09:31:00.000Z"
  },
  "sentAt": "2026-10-01T09:31:00.000Z"
}

Eventi dei messaggi#

message.received#

Un cliente ha scritto all'esercente: un testo, una foto, un vocale, uno sticker, una posizione. Anche una reazione a un messaggio arriva così, con type: "reaction".

content c'è anche in message.echo, message.edited e message.revoked.

JSON
{
  "id": "cmesempio0000delivery0011",
  "event": "message.received",
  "data": {
    "accountId": "cmesempio0000account00001",
    "message": {
      "id": "cmesempio0000message00003",
      "accountId": "cmesempio0000account00001",
      "direction": "inbound",
      "waMessageId": "wamid.ESEMPIO0000000003",
      "from": "393330000000",
      "to": "390950000000",
      "waUserId": "IT.13491208655302741918",
      "type": "text",
      "body": "Ciao, avete un tavolo per stasera?",
      "payload": {
        "from": "393330000000",
        "from_user_id": "IT.13491208655302741918",
        "id": "wamid.ESEMPIO0000000003",
        "timestamp": "1790850600",
        "type": "text",
        "text": { "body": "Ciao, avete un tavolo per stasera?" },
        "profile_name": "Mario Rossi"
      },
      "status": "received",
      "content": {
        "type": "text",
        "text": "Ciao, avete un tavolo per stasera?",
        "caption": null,
        "media": null,
        "reaction": null,
        "replyTo": null,
        "forwarded": false,
        "location": null,
        "contacts": null,
        "profileName": "Mario Rossi",
        "username": null,
        "timestamp": "2026-10-01T10:30:00.000Z",
        "readAt": null
      },
      "createdAt": "2026-10-01T10:30:00.000Z",
      "updatedAt": "2026-10-01T10:30:00.000Z"
    },
    "contactName": "Mario Rossi"
  },
  "sentAt": "2026-10-01T10:30:01.000Z"
}

Un messaggio vocale, mandato in risposta a un messaggio dell'esercente:

JSON
{
  "id": "cmesempio0000delivery0016",
  "event": "message.received",
  "data": {
    "accountId": "cmesempio0000account00001",
    "message": {
      "id": "cmesempio0000message00008",
      "accountId": "cmesempio0000account00001",
      "direction": "inbound",
      "waMessageId": "wamid.ESEMPIO0000000008",
      "from": "393330000000",
      "to": "390950000000",
      "waUserId": "IT.13491208655302741918",
      "type": "audio",
      "body": "[audio]",
      "payload": {
        "context": { "from": "390950000000", "id": "wamid.ESEMPIO0000000002" },
        "from": "393330000000",
        "from_user_id": "IT.13491208655302741918",
        "id": "wamid.ESEMPIO0000000008",
        "timestamp": "1790850900",
        "type": "audio",
        "audio": {
          "mime_type": "audio/ogg; codecs=opus",
          "sha256": "wvqXMe6n7n1W0zphvLPoLj+s/NtKqmr3zZ7YzTP7xFI=",
          "id": "600000000000002",
          "voice": true
        },
        "profile_name": "Mario Rossi"
      },
      "status": "received",
      "content": {
        "type": "audio",
        "text": null,
        "caption": null,
        "media": {
          "kind": "audio",
          "id": "600000000000002",
          "link": null,
          "mimeType": "audio/ogg; codecs=opus",
          "filename": null,
          "sha256": "wvqXMe6n7n1W0zphvLPoLj+s/NtKqmr3zZ7YzTP7xFI=",
          "size": null,
          "voice": true,
          "animated": false
        },
        "reaction": null,
        "replyTo": {
          "messageId": "cmesempio0000message00002",
          "waMessageId": "wamid.ESEMPIO0000000002",
          "from": "390950000000"
        },
        "forwarded": false,
        "location": null,
        "contacts": null,
        "profileName": "Mario Rossi",
        "username": null,
        "timestamp": "2026-10-01T10:35:00.000Z",
        "readAt": null
      },
      "createdAt": "2026-10-01T10:35:00.000Z",
      "updatedAt": "2026-10-01T10:35:00.000Z"
    },
    "contactName": "Mario Rossi"
  },
  "sentAt": "2026-10-01T10:35:01.000Z"
}

Una reazione del cliente a un messaggio dell'esercente. Non è un fumetto nuovo: va messa sul messaggio content.reaction.messageId. Quando il cliente la toglie arriva un altro evento con emoji: null e removed: true.

JSON
{
  "id": "cmesempio0000delivery0017",
  "event": "message.received",
  "data": {
    "accountId": "cmesempio0000account00001",
    "message": {
      "id": "cmesempio0000message00009",
      "accountId": "cmesempio0000account00001",
      "direction": "inbound",
      "waMessageId": "wamid.ESEMPIO0000000009",
      "from": "393330000000",
      "to": "390950000000",
      "waUserId": "IT.13491208655302741918",
      "type": "reaction",
      "body": "❤️",
      "payload": {
        "from": "393330000000",
        "from_user_id": "IT.13491208655302741918",
        "id": "wamid.ESEMPIO0000000009",
        "timestamp": "1790850960",
        "type": "reaction",
        "reaction": { "message_id": "wamid.ESEMPIO0000000002", "emoji": "❤️" },
        "profile_name": "Mario Rossi"
      },
      "status": "received",
      "content": {
        "type": "reaction",
        "text": null,
        "caption": null,
        "media": null,
        "reaction": {
          "messageId": "cmesempio0000message00002",
          "waMessageId": "wamid.ESEMPIO0000000002",
          "emoji": "❤️",
          "removed": false
        },
        "replyTo": null,
        "forwarded": false,
        "location": null,
        "contacts": null,
        "profileName": "Mario Rossi",
        "username": null,
        "timestamp": "2026-10-01T10:36:00.000Z",
        "readAt": null
      },
      "createdAt": "2026-10-01T10:36:00.000Z",
      "updatedAt": "2026-10-01T10:36:00.000Z"
    },
    "contactName": "Mario Rossi"
  },
  "sentAt": "2026-10-01T10:36:01.000Z"
}

message.status#

Stato di consegna di un messaggio inviato: sent, delivered, read, played (messaggio vocale ascoltato) o failed. Collegalo all'invio con waMessageId. messageId è null se il messaggio non era stato inviato da Omni Connect. timestamp è l'ora di Meta in secondi. Con failed, errors contiene i codici di Meta.

recipientId è il numero del destinatario, recipientUserId il suo BSUID e username il suo nome utente: valgono null quando Meta non li manda. Con failed Meta non manda né BSUID né nome utente; per un invio fatto solo al BSUID può mancare il numero (Clienti con nome utente).

JSON
{
  "id": "cmesempio0000delivery0012",
  "event": "message.status",
  "data": {
    "accountId": "cmesempio0000account00001",
    "messageId": "cmesempio0000message00002",
    "waMessageId": "wamid.ESEMPIO0000000002",
    "status": "failed",
    "timestamp": "1790850660",
    "recipientId": "393330000000",
    "recipientUserId": null,
    "username": null,
    "errors": [
      {
        "code": 131042,
        "title": "Business eligibility payment issue",
        "message": "There was an error related to your payment method"
      }
    ]
  },
  "sentAt": "2026-10-01T10:31:01.000Z"
}

message.echo#

Coexistence: l'esercente ha scritto un messaggio dall'app WhatsApp Business sul telefono. Lo ricevi per mostrare la conversazione completa nel gestionale. Non apre la finestra di 24 ore e non costa.

JSON
{
  "id": "cmesempio0000delivery0013",
  "event": "message.echo",
  "data": {
    "accountId": "cmesempio0000account00001",
    "message": {
      "id": "cmesempio0000message00005",
      "accountId": "cmesempio0000account00001",
      "direction": "outbound",
      "waMessageId": "wamid.ESEMPIO0000000005",
      "from": "390950000000",
      "to": "393330000000",
      "waUserId": null,
      "type": "text",
      "body": "Sì, vi aspettiamo alle 20!",
      "payload": {
        "from": "390950000000",
        "to": "393330000000",
        "id": "wamid.ESEMPIO0000000005",
        "timestamp": "1790850720",
        "type": "text",
        "text": { "body": "Sì, vi aspettiamo alle 20!" }
      },
      "status": "sent_from_app",
      "content": {
        "type": "text",
        "text": "Sì, vi aspettiamo alle 20!",
        "caption": null,
        "media": null,
        "reaction": null,
        "replyTo": null,
        "forwarded": false,
        "location": null,
        "contacts": null,
        "profileName": null,
        "username": null,
        "timestamp": "2026-10-01T10:32:00.000Z",
        "readAt": null
      },
      "createdAt": "2026-10-01T10:32:00.000Z",
      "updatedAt": "2026-10-01T10:32:00.000Z"
    }
  },
  "sentAt": "2026-10-01T10:32:01.000Z"
}

message.edited#

Un messaggio già consegnato è stato modificato: dal cliente (source: "user") o dall'esercente nell'app (source: "app"). message è il messaggio originale aggiornato (nuovo body, status: "edited"). Se l'originale non è noto, originalFound è false.

JSON
{
  "id": "cmesempio0000delivery0014",
  "event": "message.edited",
  "data": {
    "accountId": "cmesempio0000account00001",
    "originalWaMessageId": "wamid.ESEMPIO0000000003",
    "waMessageId": "wamid.ESEMPIO0000000006",
    "originalFound": true,
    "source": "user",
    "message": {
      "id": "cmesempio0000message00003",
      "accountId": "cmesempio0000account00001",
      "direction": "inbound",
      "waMessageId": "wamid.ESEMPIO0000000003",
      "from": "393330000000",
      "to": "390950000000",
      "waUserId": "IT.13491208655302741918",
      "type": "text",
      "body": "Ciao, avete un tavolo per quattro stasera?",
      "payload": {
        "from": "393330000000",
        "from_user_id": "IT.13491208655302741918",
        "id": "wamid.ESEMPIO0000000003",
        "timestamp": "1790850600",
        "type": "text",
        "text": { "body": "Ciao, avete un tavolo per stasera?" },
        "edits": [
          {
            "waMessageId": "wamid.ESEMPIO0000000006",
            "timestamp": "1790850780",
            "message": { "type": "text", "text": { "body": "Ciao, avete un tavolo per quattro stasera?" } }
          }
        ],
        "profile_name": "Mario Rossi"
      },
      "status": "edited",
      "content": {
        "type": "text",
        "text": "Ciao, avete un tavolo per quattro stasera?",
        "caption": null,
        "media": null,
        "reaction": null,
        "replyTo": null,
        "forwarded": false,
        "location": null,
        "contacts": null,
        "profileName": "Mario Rossi",
        "username": null,
        "timestamp": "2026-10-01T10:30:00.000Z",
        "readAt": null
      },
      "createdAt": "2026-10-01T10:30:00.000Z",
      "updatedAt": "2026-10-01T10:33:00.000Z"
    }
  },
  "sentAt": "2026-10-01T10:33:01.000Z"
}

message.revoked#

Un messaggio già consegnato è stato cancellato dal mittente. Stessi campi di message.edited; il messaggio originale ha status: "revoked".

JSON
{
  "id": "cmesempio0000delivery0015",
  "event": "message.revoked",
  "data": {
    "accountId": "cmesempio0000account00001",
    "originalWaMessageId": "wamid.ESEMPIO0000000003",
    "waMessageId": "wamid.ESEMPIO0000000007",
    "originalFound": true,
    "source": "user",
    "message": {
      "id": "cmesempio0000message00003",
      "accountId": "cmesempio0000account00001",
      "direction": "inbound",
      "waMessageId": "wamid.ESEMPIO0000000003",
      "from": "393330000000",
      "to": "390950000000",
      "waUserId": "IT.13491208655302741918",
      "type": "text",
      "body": "Ciao, avete un tavolo per stasera?",
      "payload": {
        "from": "393330000000",
        "from_user_id": "IT.13491208655302741918",
        "id": "wamid.ESEMPIO0000000003",
        "timestamp": "1790850600",
        "type": "text",
        "text": { "body": "Ciao, avete un tavolo per stasera?" },
        "revoke": { "waMessageId": "wamid.ESEMPIO0000000007", "timestamp": "1790850840" },
        "profile_name": "Mario Rossi"
      },
      "status": "revoked",
      "content": {
        "type": "text",
        "text": "Ciao, avete un tavolo per stasera?",
        "caption": null,
        "media": null,
        "reaction": null,
        "replyTo": null,
        "forwarded": false,
        "location": null,
        "contacts": null,
        "profileName": "Mario Rossi",
        "username": null,
        "timestamp": "2026-10-01T10:30:00.000Z",
        "readAt": null
      },
      "createdAt": "2026-10-01T10:30:00.000Z",
      "updatedAt": "2026-10-01T10:34:00.000Z"
    }
  },
  "sentAt": "2026-10-01T10:34:01.000Z"
}

Eventi dei clienti e delle conversazioni#

contact.changed#

Un cliente dell'esercente ha cambiato numero di telefono. Meta gli assegna anche un BSUID nuovo. Aggiorna la scheda del cliente con i valori nuovi, così la conversazione continua nello stesso posto (Clienti con nome utente).

change Significato Numeri
number Ha cambiato numero previousPhoneNumber è quello di prima, phoneNumber quello nuovo
user_id È cambiato solo il BSUID e Meta non può mostrarti il numero phoneNumber è null

text è la frase di Meta, messageId l'avviso salvato tra i messaggi dell'account con type: "system". Questo avviso non arriva mai come message.received. previousWaUserId e waUserId sono null se Meta non li manda.

JSON
{
  "id": "cmesempio0000delivery0025",
  "event": "contact.changed",
  "data": {
    "accountId": "cmesempio0000account00001",
    "change": "number",
    "previousPhoneNumber": "393330000000",
    "phoneNumber": "393470000000",
    "previousWaUserId": "IT.13491208655302741918",
    "waUserId": "IT.10230984751029384756",
    "text": "User Mario Rossi changed from 393330000000 to 393470000000",
    "waMessageId": "wamid.ESEMPIO0000000010",
    "messageId": "cmesempio0000message00010",
    "changedAt": "2026-10-05T08:15:00.000Z"
  },
  "sentAt": "2026-10-05T08:15:01.000Z"
}

contact.preference#

Un cliente ha chiesto dalla chat di non ricevere più i messaggi marketing dell'esercente (value: "stop"), oppure li ha riattivati (value: "resume"). Dopo uno stop Meta non consegna più i modelli MARKETING a quel cliente: annotalo nel tuo registro dei consensi e toglilo dalle promozioni (consenso). I messaggi di servizio non sono toccati.

phoneNumber è null se il cliente ha un nome utente e non mostra il numero: riconoscilo con waUserId.

JSON
{
  "id": "cmesempio0000delivery0026",
  "event": "contact.preference",
  "data": {
    "accountId": "cmesempio0000account00001",
    "phoneNumber": "393330000000",
    "waUserId": "IT.13491208655302741918",
    "profileName": "Mario Rossi",
    "username": null,
    "category": "marketing_messages",
    "value": "stop",
    "detail": "User requested to stop marketing messages",
    "changedAt": "2026-10-05T09:00:00.000Z"
  },
  "sentAt": "2026-10-05T09:00:01.000Z"
}

conversation.handover#

Riguarda solo gli esercenti che sullo stesso numero hanno più di un gestore delle risposte, per esempio un'altra applicazione o l'assistente automatico di Meta, e hanno impostato in Meta Business Suite chi risponde a cosa. In quel caso ogni conversazione ha un solo gestore alla volta, e solo lui può mandare risposte libere.

type canReply Significato
control_passed true La conversazione è passata a Omni Connect: ora puoi rispondere
control_taken false Un altro gestore ha preso la conversazione: smetti di rispondere

phoneNumber è il numero del cliente (null se Meta non lo manda). previousOwnerRole e newOwnerRole dicono chi la gestiva e chi la gestisce: customer_service, marketing, utility, ctwa, ai_agent, escalation. metadata è la nota di chi ha passato la conversazione, summary il riassunto scritto da Meta, se c'è. Dopo 24 ore senza messaggi del cliente una conversazione torna libera da sola, senza evento.

JSON
{
  "id": "cmesempio0000delivery0027",
  "event": "conversation.handover",
  "data": {
    "accountId": "cmesempio0000account00001",
    "type": "control_passed",
    "canReply": true,
    "phoneNumber": "393330000000",
    "previousOwnerRole": "ai_agent",
    "newOwnerRole": "escalation",
    "metadata": "Il cliente chiede di parlare con una persona",
    "summary": "Il cliente vuole spostare la prenotazione di stasera alle 21",
    "changedAt": "2026-10-05T10:00:00.000Z"
  },
  "sentAt": "2026-10-05T10:00:01.000Z"
}

Eventi della coexistence#

history.chunk#

Un blocco dello storico chat (fino a 180 giorni) è stato salvato. Lo storico arriva a fasi: phase 0 = ultimo giorno, 1 = da 1 a 90 giorni, 2 = da 90 a 180 giorni. progress va da 0 a 100. I messaggi non ti arrivano uno per uno: leggili cliente per cliente con GET /v1/accounts/:id/conversation (Importare rubrica e chat), oppure con GET /v1/accounts/:id/messages.

JSON
{
  "id": "cmesempio0000delivery0016",
  "event": "history.chunk",
  "data": {
    "accountId": "cmesempio0000account00001",
    "phase": 1,
    "chunkOrder": 3,
    "progress": 45,
    "threads": 12,
    "messages": 340,
    "inserted": 338
  },
  "sentAt": "2026-10-01T09:40:00.000Z"
}

history.completed#

Lo storico è arrivato tutto (progress 100).

JSON
{
  "id": "cmesempio0000delivery0017",
  "event": "history.completed",
  "data": { "accountId": "cmesempio0000account00001", "phase": 2, "progress": 100 },
  "sentAt": "2026-10-01T09:55:00.000Z"
}

history.media#

Gli allegati di alcuni messaggi dello storico sono diventati disponibili (di solito solo per gli ultimi 14 giorni). messageId è l'id del messaggio in Omni Connect: è lo stesso messaggio di prima, che ora ha il tipo vero e content.media.id. Rileggilo (per esempio con GET /v1/accounts/:id/conversation) e scarica il file con GET /v1/accounts/:id/media/:mediaId.

JSON
{
  "id": "cmesempio0000delivery0018",
  "event": "history.media",
  "data": {
    "accountId": "cmesempio0000account00001",
    "messages": [{ "waMessageId": "wamid.ESEMPIO0000000008", "messageId": "cmesempio0000message00008", "type": "image" }]
  },
  "sentAt": "2026-10-01T09:56:00.000Z"
}

contacts.synced#

La rubrica dell'app WhatsApp Business è cambiata: sincronizzazione iniziale o modifica successiva. action vale add (aggiunto o modificato) o remove. La rubrica completa si legge a pagine con GET /v1/accounts/:id/contacts (Importare rubrica e chat).

Ogni contatto porta anche waUserId (il BSUID) e username (il nome utente), quando Meta li manda. phoneNumber è null per un contatto che ha un nome utente e non mostra il numero: in quel caso c'è sempre waUserId.

JSON
{
  "id": "cmesempio0000delivery0019",
  "event": "contacts.synced",
  "data": {
    "accountId": "cmesempio0000account00001",
    "count": 1,
    "contacts": [
      { "action": "add", "phoneNumber": "393330000000", "waUserId": "IT.13491208655302741918", "username": null, "fullName": "Mario Rossi", "firstName": "Mario", "timestamp": "1790850000" }
    ]
  },
  "sentAt": "2026-10-01T09:35:00.000Z"
}

Eventi dei modelli#

In questi eventi template è la riga del modello in Omni Connect, non la forma della risposta delle rotte. Ha accountId e l'ultimo errore in campi separati (lastErrorCode, lastErrorSubcode, lastErrorTitle, lastErrorMessage). Non ha i campi che le rotte ricavano dal contenuto (header, body, footer, buttons, examples) né l'oggetto lastError: il testo è in components, oppure rileggi il modello con GET /v1/accounts/:id/templates/:templateId.

template.status#

Meta ha deciso su un modello. template.status vale approved, rejected, paused, disabled, archived, deleted (o pending). event è il valore originale di Meta, metaTemplateId l'identificativo di Meta del modello. Per un rifiuto: reason, e rejectionInfo con il consiglio di Meta. Con event: "DISABLED", disableInfo dice da quando.

Casi particolari:

JSON
{
  "id": "cmesempio0000delivery0020",
  "event": "template.status",
  "data": {
    "accountId": "cmesempio0000account00001",
    "template": {
      "id": "cmesempio0000template0001",
      "accountId": "cmesempio0000account00001",
      "catalogId": null,
      "name": "conferma_prenotazione",
      "language": "it",
      "metaTemplateId": "400000000000001",
      "status": "approved",
      "category": "UTILITY",
      "reason": "NONE",
      "components": [
        { "type": "BODY", "text": "Ciao {{1}}, la tua prenotazione per {{2}} persone è confermata per le {{3}}. A presto!", "example": { "body_text": [["Mario", "2", "20:30"]] } }
      ],
      "parameterFormat": "positional",
      "source": "account",
      "qualityScore": null,
      "lastErrorCode": null,
      "lastErrorSubcode": null,
      "lastErrorTitle": null,
      "lastErrorMessage": null,
      "lastAttemptAt": "2026-10-01T10:50:00.000Z",
      "rejectionRecommendation": null,
      "createdAt": "2026-10-01T10:50:00.000Z",
      "updatedAt": "2026-10-01T11:05:00.000Z"
    },
    "event": "APPROVED",
    "metaTemplateId": "400000000000001",
    "reason": "NONE",
    "rejectionInfo": null,
    "otherInfo": null,
    "disableInfo": null
  },
  "sentAt": "2026-10-01T11:05:01.000Z"
}

template.category#

Meta ha cambiato la categoria di un modello, oppure avvisa che la cambierà. Una categoria diversa cambia il prezzo dei messaggi (categorie).

pending Significato
false Cambio avvenuto: da previousCategory a newCategory. template.category è già quella nuova
true Preavviso: la categoria è ancora newCategory. correctCategory è quella che Meta ritiene giusta e effectiveAt dice quando la cambierà (null se Meta non dà una data)

appealStatus dice se si può fare ricorso (per esempio ELIGIBLE); il ricorso si fa in WhatsApp Manager. Con un preavviso hai il tempo di correggere il testo del modello o di avvisare l'esercente del costo.

JSON
{
  "id": "cmesempio0000delivery0021",
  "event": "template.category",
  "data": {
    "accountId": "cmesempio0000account00001",
    "template": {
      "id": "cmesempio0000template0002",
      "accountId": "cmesempio0000account00001",
      "catalogId": "cmesempio0000catalog00001",
      "name": "avviso_servizio",
      "language": "it",
      "metaTemplateId": "400000000000002",
      "status": "approved",
      "category": "MARKETING",
      "reason": "NONE",
      "components": [
        { "type": "BODY", "text": "Gentile {{1}}, ti informiamo che {{2}}. Per informazioni rispondi a questo messaggio.", "example": { "body_text": [["Mario", "il negozio resterà chiuso lunedì"]] } }
      ],
      "parameterFormat": "positional",
      "source": "catalog",
      "qualityScore": "GREEN",
      "lastErrorCode": null,
      "lastErrorSubcode": null,
      "lastErrorTitle": null,
      "lastErrorMessage": null,
      "lastAttemptAt": "2026-10-01T09:30:00.000Z",
      "rejectionRecommendation": null,
      "createdAt": "2026-10-01T09:30:00.000Z",
      "updatedAt": "2026-10-03T08:00:00.000Z"
    },
    "previousCategory": "UTILITY",
    "newCategory": "MARKETING",
    "pending": false,
    "correctCategory": "MARKETING",
    "effectiveAt": null,
    "appealStatus": "ELIGIBLE"
  },
  "sentAt": "2026-10-03T08:00:01.000Z"
}

template.quality#

È cambiata la qualità di un modello: GREEN, YELLOW, RED o UNKNOWN. Un modello che scende troppo può essere sospeso (paused).

JSON
{
  "id": "cmesempio0000delivery0022",
  "event": "template.quality",
  "data": {
    "accountId": "cmesempio0000account00001",
    "template": {
      "id": "cmesempio0000template0001",
      "accountId": "cmesempio0000account00001",
      "catalogId": null,
      "name": "conferma_prenotazione",
      "language": "it",
      "metaTemplateId": "400000000000001",
      "status": "approved",
      "category": "UTILITY",
      "reason": "NONE",
      "components": [
        { "type": "BODY", "text": "Ciao {{1}}, la tua prenotazione per {{2}} persone è confermata per le {{3}}. A presto!", "example": { "body_text": [["Mario", "2", "20:30"]] } }
      ],
      "parameterFormat": "positional",
      "source": "account",
      "qualityScore": "YELLOW",
      "lastErrorCode": null,
      "lastErrorSubcode": null,
      "lastErrorTitle": null,
      "lastErrorMessage": null,
      "lastAttemptAt": "2026-10-01T10:50:00.000Z",
      "rejectionRecommendation": null,
      "createdAt": "2026-10-01T10:50:00.000Z",
      "updatedAt": "2026-10-10T12:00:00.000Z"
    },
    "previousQualityScore": "GREEN",
    "newQualityScore": "YELLOW"
  },
  "sentAt": "2026-10-10T12:00:01.000Z"
}

template.components#

Meta ha cambiato il contenuto di un modello. changes riporta i testi nuovi (body, headerText, footer, buttons; null se invariati); template.components è già aggiornato.

JSON
{
  "id": "cmesempio0000delivery0023",
  "event": "template.components",
  "data": {
    "accountId": "cmesempio0000account00001",
    "template": {
      "id": "cmesempio0000template0001",
      "accountId": "cmesempio0000account00001",
      "catalogId": null,
      "name": "conferma_prenotazione",
      "language": "it",
      "metaTemplateId": "400000000000001",
      "status": "approved",
      "category": "UTILITY",
      "reason": "NONE",
      "components": [
        { "type": "BODY", "text": "Ciao {{1}}, la tua prenotazione per {{2}} persone è confermata per le ore {{3}}. A presto!" }
      ],
      "parameterFormat": "positional",
      "source": "account",
      "qualityScore": "GREEN",
      "lastErrorCode": null,
      "lastErrorSubcode": null,
      "lastErrorTitle": null,
      "lastErrorMessage": null,
      "lastAttemptAt": "2026-10-01T10:50:00.000Z",
      "rejectionRecommendation": null,
      "createdAt": "2026-10-01T10:50:00.000Z",
      "updatedAt": "2026-10-12T12:00:00.000Z"
    },
    "changes": {
      "body": "Ciao {{1}}, la tua prenotazione per {{2}} persone è confermata per le ore {{3}}. A presto!",
      "headerText": null,
      "footer": null,
      "buttons": null
    }
  },
  "sentAt": "2026-10-12T12:00:01.000Z"
}

template.create_failed#

Un modello del tuo catalogo non è stato creato su un esercente: rifiutato da Meta o fermato dalle regole di scrittura. Succede durante il sync del catalogo, dopo il collegamento o dopo register. Il modello resta in stato error: correggi la voce del catalogo e rilancia il sync, oppure modificalo sull'esercente.

JSON
{
  "id": "cmesempio0000delivery0024",
  "event": "template.create_failed",
  "data": {
    "accountId": "cmesempio0000account00001",
    "template": {
      "id": "cmesempio0000template0003",
      "accountId": "cmesempio0000account00001",
      "catalogId": "cmesempio0000catalog00002",
      "name": "offerta_settimana",
      "language": "it",
      "metaTemplateId": null,
      "status": "error",
      "category": "MARKETING",
      "reason": null,
      "components": [
        { "type": "BODY", "text": "Ciao {{1}}, questa settimana {{2}} per te. Ti aspettiamo in negozio!", "example": { "body_text": [["Mario", "il 10% di sconto"]] } }
      ],
      "parameterFormat": "positional",
      "source": "catalog",
      "qualityScore": null,
      "lastErrorCode": 100,
      "lastErrorSubcode": 2388293,
      "lastErrorTitle": "Testo del titolo di Meta",
      "lastErrorMessage": "Testo della spiegazione di Meta",
      "lastAttemptAt": "2026-10-01T09:31:00.000Z",
      "rejectionRecommendation": null,
      "createdAt": "2026-10-01T09:31:00.000Z",
      "updatedAt": "2026-10-01T09:31:00.000Z"
    },
    "error": {
      "code": 100,
      "subcode": 2388293,
      "title": "Testo del titolo di Meta",
      "message": "Testo della spiegazione di Meta"
    }
  },
  "sentAt": "2026-10-01T09:31:01.000Z"
}