How to Attach a File to a Message with GraphQL



In this guide, we will walk you through the process of attaching a file to a message using GraphQL. This process involves three main steps and utilizes the Upload Information Type and Message Type .

Step-by-Step Guide



First, use the attachmentUpload mutation to obtain an uploadUrl , headers , and attachmentId in the response. Make sure to store all three values, as you'll need them later.

Step 2: Upload the File


This step depends on your specific platform. Upload the file to the uploadUrl obtained in Step 1. Remember to include the headers from the response of the previous step.

Step 3: Send the Message


This step uses the attachmentId from Step 1. Pass it into the mutation's variables as the blobOrAttachmentId . In this example, we are using templateProactiveMessageCreate to create a proactive message to a user using a template. The same workflow applies for Media Message Create .

This uses the MessageProactiveTemplateCreateInput input type .

In your variables, $input could look like this: