Skip to main content
Answered

Darshan Hiranandani : How to Upload Images or Attachments via REST API?


Hello everyone,

I’m Darshan Hiranandani, I’ve been working on an API that allows me to create articles with titles and main content. So far, I’ve been able to create articles successfully, but I’m facing a challenge when it comes to uploading images or attachments to these articles.

I know some platforms like Intercom have hosting services that allow you to upload and store attachments, but I’m not sure if they offer something similar for direct image uploads.

Can anyone share their experience or suggestions on how to upload images or attachments via REST API? Any help or ideas on how to handle this would be greatly appreciated!

Thanks in advance!

Regards

Darshan Hiranandani

Best answer by Jacques Reynolds

Hey ​@darshanhiranandani 👋 Jacques here from Support Engineering. I hope you are doing well today! :)

You can upload images or attachments to articles via the Intercom API, if the content is hosted publicly and accessible via a URL. Intercom does not support direct uploads of files; instead, you must provide a URL to the file in your API request.

Here's how you can format your request:

  1. Image Tag for Articles: Use an <img> tag with the image URL as the src attribute. Ensure the URL is complete and publicly accessible. Supported file types include PNG, JPEG, SVG, and GIF .
  2. Attachment Attributes: When uploading attachments, specify the following attributes in your JSON payload:
    • type: Set to "upload".
    • name: The name of the file, e.g., "example.png".
    • url: The public URL of the file.
    • content_type: The MIME type, e.g., "image/png".
    • filesize: The size in bytes.
    • width and height: Dimensions for image files .

Ensure your files are hosted on a platform that allows public access, as Intercom requires that URL to fetch and display the content.

Hope this is clear!

View original
Did this topic help you find an answer to your question?

2 replies

  • New Participant
  • 3 replies
  • January 16, 2025

Jacques Reynolds
Intercom Team
Forum|alt.badge.img+4

Hey ​@darshanhiranandani 👋 Jacques here from Support Engineering. I hope you are doing well today! :)

You can upload images or attachments to articles via the Intercom API, if the content is hosted publicly and accessible via a URL. Intercom does not support direct uploads of files; instead, you must provide a URL to the file in your API request.

Here's how you can format your request:

  1. Image Tag for Articles: Use an <img> tag with the image URL as the src attribute. Ensure the URL is complete and publicly accessible. Supported file types include PNG, JPEG, SVG, and GIF .
  2. Attachment Attributes: When uploading attachments, specify the following attributes in your JSON payload:
    • type: Set to "upload".
    • name: The name of the file, e.g., "example.png".
    • url: The public URL of the file.
    • content_type: The MIME type, e.g., "image/png".
    • filesize: The size in bytes.
    • width and height: Dimensions for image files .

Ensure your files are hosted on a platform that allows public access, as Intercom requires that URL to fetch and display the content.

Hope this is clear!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings