Add attachments through API


I'm working on integrating the Freshdesk ticket system on the website of a client. It all looks quite promising. I like to create a new ticket directly from the website. This works great except I'm not able to add a file to my ticket. I don't see any documentation on how this should be done, so I assume this feature isn't available in the API just yet. Or am I missing something?

I guess I could send an email to the Freshdesk address from the webserver with the file attached, but that wouldn't be an ideal solution.

I very much would like to see some way attach a file to a ticket I create with the API. Any chance for this?

6 people have this question

Is this even possible via the API?

There's no mention of attachments in the API docs.  The Feedback widget allows attachments, but it doesn't use the API. 

Kind of strange that your own widget doesn't use your own API:  the widget posts to:


I while ago someone from Freshdesk told me by mail that it should work like this:


You can attach a file by converting it using base64 encoding and passing it to the api as follows:

<description>This is a test from Kevin</description>
<file type="file" name="trials.csv" content-type="application/octet-stream">


I tried this, but it didn't work for me. Maybe I'm did something wrong, maybe it just doesn't yet work as it should, who knows. At least it looks like this feature is at some level implemented into the API.

Hi Guys

CDATA option should work. If its not working, can you drop an Email to support with the API query you used, maybe I can check the logs and help you out further



Update for people following the google crumbs here. There's been a slight modification to the XML formatting for ticket creation with an attachment. Got the new details today and had some success with this format: 

  <description>SUPER very descriptive ticket description!</description>
  <attachments type="array">
      <resource type="file" name="clark.png" content-type="application/octet-stream"><![CDATA[base64 data]]></resource>

Also, this is a pretty functional Ruby library. Anyone found / cobbled together a python one?

Can this be done with JSON as well? What format should I use? Are there any examples for this available anywhere?


Please upload a similar request in JSON as well? I am trying to hit create ticket with attachment through Advanced Rest Client but no success till now.Can anyone help here?


Creating a ticket with attachment is very much possible using API. Please visit our official API documentation to know more :


I am not able to create a ticket with attachment using api. "<h2>Incomplete response received from application</h2>" error is coming . Please help 

I am also trying to create a ticket with attachment and I am also getting the "<h2>Incomplete response received from application</h2>" error

Please help

I was working on a freshdesk ticket. When I'm hitting the url through postman it is working fine and generating the ticket with the attachment. But when I'm integrating it and hitting the url through curl request in laravel it is showing a wondrous error : ""{"message":"We're sorry, but something went wrong."}"". Please do let me know that its an issue from freshdesk or if its my mistake then please guide me. This is my code :

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: multipart/form-data"
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$api_key:$password");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($ticketData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec($ch);
$info = curl_getinfo($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($server_output, 0, $header_size);
$response = substr($server_output, $header_size);

$request = $client->post($url, [
'allow_redirects' => true,
'timeout' => 2000,
'http_errors' => false,
'headers' => ['Content-Type' => 'application/json'],
'auth' => $auth,
'body' => \GuzzleHttp\json_encode($ticketData),

Login or Signup to post a comment