Skip to content

Instantly share code, notes, and snippets.

@hdornier
hdornier / attachments.md
Last active January 29, 2024 20:30
Front API Attachment Example

When you want to send files through the API, your request needs to be sent using the Content-Type HTTP header set to multipart/form-data. The JSON data you would normally send in the request body needs to be split in multiple form fields (one for each property) named after the property key. If the property is an array, the name should include the index of the data (ie: {"to": [email1@example.com, email1@example.com]} would be split in two fields named to[0], to[1]).

Below is an example template demonstrating how to send a message via Front's Create conversation API endpoint:

curl -X POST 'https://api2.frontapp.com/channels/FRONT_CHANNEL_ID/messages' \
-H 'Authorization: Bearer YOUR_FRONT_API_TOKEN' \
-H 'Content-Type: multipart/form-data' \
--form 'author_id=AUTHOR_ID' \