Files

File message examples shown for each supported platform

All examples below must be sent within the body field of a message as shown below

{
 "receiver": {
   "contacts": [
     {
       "identifierValue": "+31612345678"
     }
   ]
 },
 "body": {...}
}

Single file message

Body

{
  "type": "file",
  "file": {
    "files": [
      {
        "contentType": "video/mp4",
        "mediaUrl": "https://www.messagebird.com/videos/video.mp4"
      }
    ]
  }
} 

MMS

Only SMS channels that are MMS capable support file messages. See here

WhatsApp

Facebook

Instagram

Single file message with text

Body

{
  "type": "file",
  "file": {
    "text": "Single file message",
    "files": [
      {
        "contentType": "video/mp4",
        "mediaUrl": "https://www.messagebird.com/videos/video.mp4"
      }
    ]
  }
} 

MMS

Only SMS channels that are MMS capable support file messages. See here

WhatsApp

Facebook

Multiple file message

Multiple files message

Body

{
  "type": "file",
  "file": {
    "text": "Multiple files message",
    "files": [
      {
        "contentType": "video/mp4",
        "mediaUrl": "https://www.messagebird.com/videos/video.mp4"
      },
      {
        "contentType": "audio/mpeg",
        "mediaUrl": "https://www.messagebird.com/audio/file_example_MP3_700KB.mp3"
      }
    ]
  }
}

MMS

Only SMS channels that are MMS capable support file messages. See here

WhatsApp

Facebook

Instagram

Audio/mpeg not supported on Instagram. Audio/wav used in this example

Multiple files message with filename

Body

{
  "type": "file",
  "file": {
    "text": "Multiple files message",
    "files": [
      {
        "contentType": "video/mp4",
        "mediaUrl": "https://www.messagebird.com/videos/video.mp4"
      },
      {
        "contentType": "application/pdf",
        "mediaUrl": "https://www.messagebird.com/documents/file-sample_150kB.pdf",
        "filename": "passport.pdf"
      }
    ]
  }
}

WhatsApp

Facebook

Single file message with actions

Body

{
  "type": "file",
  "file": {
    "text": "Single file message",
    "files": [
      {
        "contentType": "video/mp4",
        "mediaUrl": "https://www.messagebird.com/videos/video.mp4"
      }
    ],
    "actions": [
      {
        "type": "postback",
        "postback": {
          "text": "Postback action"
        }
      },
      {
        "type": "reply",
        "reply": {
          "text": "Reply action"
        }
      }
    ]
  }
}

WhatsApp

Facebook

Instagram

Multiple file message with actions

Miltiple files mesage with 2 postback actions and 1 reply action

Body

{
  "type": "file",
  "file": {
    "text": "Multiple files message",
    "files": [
      {
        "contentType": "video/mp4",
        "mediaUrl": "https://www.messagebird.com/videos/video.mp4"
      },
      {
        "contentType": "application/pdf",
        "mediaUrl": "https://www.messagebird.com/documents/file-sample_150kB.pdf",
        "filename": "passport.pdf"
      }
    ],
    "actions": [
      {
        "type": "postback",
        "postback": {
          "text": "Postback action 1",
          "payload": "postback-payload-1"
        }
      },
      {
        "type": "postback",
        "postback": {
          "text": "Postback action 2",
          "payload": "postback-payload-2"
        }
      },
      {
        "type": "reply",
        "reply": {
          "text": "Reply action"
        }
      }
    ]
  }
}

WhatsApp

Facebook

Instagram

*PDF not supported. Example using audio/wav file

Multiple files message with 4 postback actions

Body

{
  "type": "file",
  "file": {
    "files": [
      {
        "contentType": "video/mp4",
        "altText": "First file label",
        "mediaUrl": "https://file-examples.com/storage/fe8109a782637e9df99d7a0/2017/04/file_example_MP4_480_1_5MG.mp4",
        "filename": "recording.mp4"
      },
      {
        "contentType": "application/pdf",
        "altText": "Second file label",
        "mediaUrl": "https://file-examples.com/storage/fe8109a782637e9df99d7a0/2017/10/file-sample_150kB.pdf",
        "filename": "passport.pdf"
      }
    ],
    "text": "Multiple files message with postback actions",
    "actions": [
      {
        "type": "postback",
        "postback": {
          "payload": "postback-payload-1",
          "text": "Postback action 1"
        }
      },
      {
        "postback": {
          "payload": "postback-payload-2",
          "text": "Postback action 2"
        },
        "type": "postback"
      },
      {
        "postback": {
          "payload": "postback-payload-3",
          "text": "Postback action 3"
        },
        "type": "postback"
      },
      {
        "postback": {
          "payload": "postback-payload-4",
          "text": "Postback action 4"
        },
        "type": "postback"
      }      
    ]
  }
}

Facebook

Instagram

*PDF not supported. Example using audio/wav file

Last updated