Mensagem de documento

Exemplo de body recebido no webhook

Envio via Endpoint

{
  "event": "MESSAGE",
  "data": {
    "message": {
      "key": {
        "remoteJid": "12321@s.whatsapp.net",//Número da conversa
        "fromMe": true,// Propriedade que indica se a mensagem foi enviada pelo número conectado na instância
        "id": "BAE5E7DE9CEDAB94"// ID da mensagem no WhatsApp
      },
      "message": {
        "documentMessage": {//Os webhooks de documento vem com esse objeto documentMessage em que dentro dele terá os dados do documento
          "url": "https://mmg.whatsapp.net/v/t62.7119-24/12147938_637240178463686_5490412204921601116_n.enc?ccb=11-4&oh=01_AdTXuZutA3Vun2iCVQ0Z-aNa03cRVV1ISaSzU2eP9WjMQQ&oe=64B29BB5&mms3=true",
          "mimetype": "application/pdf",
          "fileSha256": "OA3wjjN/68vb5BlMnRbIPS8Of3JmXfGOdmVl8jnk0/c=",
          "fileLength": "157575",
          "mediaKey": "ORvMqz+jI1DK27lM06vy19tqufmig4WNXbBLZ7rqgYE=",
          "fileName": "file",
          "fileEncSha256": "GShqVnSk8fQCRTY1Xpe2/xrCuXsaRZsMjgGDuPyaYPA=",
          "directPath": "/v/t62.7119-24/12147938_637240178463686_5490412204921601116_n.enc?ccb=11-4&oh=01_AdTXuZutA3Vun2iCVQ0Z-aNa03cRVV1ISaSzU2eP9WjMQQ&oe=64B29BB5",
          "mediaKeyTimestamp": "1686837635"
        }
      },
      "messageTimestamp": "1686837635",
      "status": "PENDING"
    },
    "instanceId": 450
  }
}

Se liga na dica! Perceba que a principal diferença entre os webhooks de media é que o objeto da mensagem vem objetos com nomes diferente, imagem é imageMessage, video é videoMessage, audio é audioMessage e assim por diante.

Recebimento

{
  "event": "MESSAGE",
  "data": {
    "message": {
      "key": {
        "remoteJid": "1321321@s.whatsapp.net",//Número da conversa
        "fromMe": false,// Propriedade que indica se a mensagem foi enviada pelo número conectado na instância
        "id": "A97082DAE07D32CB744B5D0783261420"// ID da mensagem no WhatsApp
      },
      "messageTimestamp": 1686837859,
      "pushName": ".",
      "message": {
        "documentMessage": {
          "url": "https://mmg.whatsapp.net/v/t62.7119-24/34889046_802451707874348_1700986789817026555_n.enc?ccb=11-4&oh=01_AdRqkrHPTuB_6iEHXyRqFhZp4oh9rdAhzmSorCaOT77q4Q&oe=64B2741C&mms3=true",
          "mimetype": "application/pdf",
          "title": "1673291711194.pdf",
          "fileSha256": "WeX5rwlJ3yBRmVYkxrAfjnk8A8zoGCfxCGQHeQa2z4k=",
          "fileLength": "5817",
          "pageCount": 1,
          "mediaKey": "QC+jUxVs5egv8NeOkfN47DgjHCnre/hIfLFOzJMnrMo=",
          "fileName": "1673291711194.pdf",
          "fileEncSha256": "4ernw8rowkU0HjKcPdzGxTljUv9jnq8asDnI1Mn+9Io=",
          "directPath": "/v/t62.7119-24/34889046_802451707874348_1700986789817026555_n.enc?ccb=11-4&oh=01_AdRqkrHPTuB_6iEHXyRqFhZp4oh9rdAhzmSorCaOT77q4Q&oe=64B2741C",
          "mediaKeyTimestamp": "1686769475",
          "thumbnailDirectPath": "/v/t62.36145-24/22559386_204757929187487_2360157085654623539_n.enc?ccb=11-4&oh=01_AdTPKc7DcJv3gAlo4qFMMSZpkfMnfH7REfvJcDtQmPUDQQ&oe=64B28AD3",
          "thumbnailSha256": "+VUJLrOw4b2ZF+ECAUnOHvo5d0uASbvx/6eYEaLhbBY=",
          "thumbnailEncSha256": "p0+zK5YmM3xfzsvrTyL3eNV3smq7K06W+mwQpbsZWnM=",
          "jpegThumbnail": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABERERESERMVFRMaHBkcGiYjICAjJjoqLSotKjpYN0A3N0A3WE5fTUhNX06MbmJiboyiiIGIosWwsMX46/j///8BERERERIRExUVExocGRwaJiMgICMmOiotKi0qOlg3QDc3QDdYTl9NSE1fToxuYmJujKKIgYiixbCwxfjr+P/////CABEIAGAASgMBIgACEQEDEQH/xAAuAAEAAwEBAQAAAAAAAAAAAAAAAQMEAgUGAQEBAQAAAAAAAAAAAAAAAAAAAQL/2gAMAwEAAhADEAAAAPvEZWtfFWhOHZAAI8z08x1ogSiQACMezMc7KLwAACPO9HEX3ZbywAACqyk64mCrRxJ05F4AAAAAP//EADAQAAEDAgIIBQMFAAAAAAAAAAEAAhEDIQQSEBMgIjEycZEUQVFTYQVioiMkQIGx/9oACAEBAAE/ANFWqKYBNz6SAhjxYav8mofUG+3+TUPqAgfp/k1UcQyqSOB6g/5sVs0bokhpgTCbiGNgVWPmBygkXVPE0HloLKoJ+CsoWULKFlCyhAQ46MSQG34ZSmmg4gB1yLAgKlXdZrXOgeUBNMzYjZHMeg0V3FjS5syGngJK8RicoOd9/sCpYiqWXpvcfWwWtf7LkNgcx6DRXIDZImGm0wg9oBIoG44axybWyEHU3B9wlCqxxgHZHMeg0V2l4ygTLTZDC1coBpk2sDlsmU8S2zQ9o+C1MDgN4nZHMeg0YqMhnhlKpMp1Dka0cPtKGFbb9lf1kIPqAACge4QqVfZPcbA5j0GiuJEAkbpuE1jrTUqGPgoAhwOeobzylMfTa7Nlqf2muzCYI67A5j0GhwlwE+RQNInLrgD6Sg6j7w7p72QclZhI9Sg99jraMeocVNKAdcO6Jotia7e6ml51h3TBbQZkGF4ffzw/jMShhjfnvPmhhonnv8rwu7G/3XhrRD+6OGs2zxA9V4a87/dCwH8b/8QAFBEBAAAAAAAAAAAAAAAAAAAAQP/aAAgBAgEBPwB3/8QAGREBAAIDAAAAAAAAAAAAAAAAAgExABFA/9oACAEDAQE/AICVYijca7f/2Q==",
          "thumbnailHeight": 480,
          "thumbnailWidth": 370
        },
        "messageContextInfo": {
          "deviceListMetadata": {
            "senderKeyHash": "AofW3u2YzeOX8g==",
            "senderTimestamp": "1686702226",
            "recipientKeyHash": "l7l0ggVb98ikLg==",
            "recipientTimestamp": "1686834621"
          },
          "deviceListMetadataVersion": 2
        }
      },
      "base64": "BASE64 DO DOCUMENTO"// Base64 referente ao docuemnto para que possa subir em seu sistema.
    },
    "instanceId": 450
  }
}

Last updated