W2A

Media Messages

Messages with medias.

Read the details of how to use it in Requests.

There's a lib for nodejs here: Click here

Upload media

Now you can send your media using multipart-form, see as bellow.

  •           const axios = require('axios');
              const FormData = require('form-data');
              const fs = require('fs');
              let data = new FormData();
              data.append('file', fs.createReadStream('FILEPATH'));
      
              const payload = {
                "connectionId": "CONNECTIONID",
                "method": "sendMessage",
                "params": [
                  "[email protected]",
                  {
                    "caption": "Teste"
                  }
                ]
              }
              data.append('data', JSON.stringify(payload));
      
              let config = {
                method: 'post',
                maxBodyLength: Infinity,
                url: 'https://api.whats2api.com/connections/request',
                headers: { 
                  'Authorization': 'Bearer YOUR_BEARER_TOKEN', 
                  ...data.getHeaders()
                },
                data : data
              };
      
              axios.request(config)
              .then((response) => {
                console.log(JSON.stringify(response.data));
              })
              .catch((error) => {
                console.log(error);
              });
            

Public url media

Another option is to use a public URL to send a media.

  • Sending videos!
    {
      "connectionId": "YOUR_CONNECTION_ID",
      "method": "sendMessage",
      "params": [
        "[email protected]",
        {
          "video": {
            "url": "A_PLUBLIC_URL_TO_GET_THE_VIDEO"
          },
          "caption": "This is optional, but you can send a caption with the video!"
        },
        {
          "mimetype": "video/mp4",
          "fileName": "somefile.mp4"
        }
      ]
    }
  • Sending Images!
    Accepts jpeg too
    {
      "method": "sendMessage",
      "params": [
        "[email protected]",
        {
          "image": {
            "url": "A_PLUBLIC_URL_TO_GET_THE_IMAGE"
          },
          "caption": "This is optional, but you can send a caption with the image!"
        },
        {
          "mimetype": "image/png",
          "fileName": "somefile.png"
        }
      ]
    }
  • Sending audio!
    can send mp3, mp4, & ogg
    the ptt send as audio note
    {
      "method": "sendMessage",
      "params": [
        "[email protected]",
        {
          "audio": {
            "url": "A_PLUBLIC_URL_TO_GET_THE_IMAGE"
          }
        },
        {
          "mimetype": "audio/mp3",
          "ptt": true,
          "fileName": "somefile.mp3"
        }
      ]
    }
  • Sending document!
    can almost anything
    {
      "connectionId": "YOUR_CONNECTION_ID",
      "method": "sendMessage",
      "params": [
        "[email protected]",
        {
          "document": {
            "url": "A_PLUBLIC_URL_TO_GET_THE_VIDEO"
          },
          "caption": "This is optional, but you can send a caption with the video!"
        },
        {
          "mimetype": "application/pdf",
          "fileName": "somefile.pdf"
        }
      ]
    }