File Upload

You have two options to add a file to a message. You can do it with a custom webhook (easier) or you can use a normal user account and use a special API endpoint.

In both cases, only file should be added per message. To send multiple files, send multiple messages, each with one file attached.

File upload via custom webhook

Create a custom webhook. The documentation will be shown to you after creating the webhook.

File upload via file upload API and RPC API

  1. HTTP POST the image to /chat/upload

    • Authentication needed. See “Authentication”
    • HTTP headers
      • Content-Type: multipart/form-data; ....
    • Payload
      • file - the file
      • organization - organization id
  2. When the upload is finished, you will receive an answer:

        "category": "image",
        "name": "grape.png",
        "url": "/media/organizations/1/8df284743ebc11e6b7400800273a6284/grape.png",
        "thumbnail_width": 384,
        "thumbnail_url": "/media/cache/b9/ce/b9ce7e02ce08fd9d0de4a1ffa9d9375c.png",
        "time": "2016-06-30T12:17:03.763365",
        "thumbnail_height": 240,
        "type": "image/png",
        "id": "8df284743ebc11e6b7400800273a6284",
        "mime_type": "image/png"
    • the thubnail is generated by the server if the file is an image file and the file type is supported
    • the important part is the id
  3. Send an empty message (via RPC channels/post) to the chat with one additional parameter:

    • Object, containing attachments: Array containing the uploaded file id.

    in this example:

        attachments: ["0c82819e18c511e5b7ba0800273a6284"]