Reply Ticket via API


I managed to update the status of a ticket through the examples I've found and it works perfect.

The problem is that now I want to answer the ticket via API, so that the response is recorded and in turn the ticket is updated to closed state.

The data sent are:

    $f_url_connection = "$f_url_dominio_freshdesk/helpdesk/tickets/$p_ticket_freshdesk.json";

$f_data = array(
"helpdesk_ticket" => array(
"description" => $p_email_txt,
"description_html" => $p_email_html,
"status" => 5

$f_json_body = json_encode($f_data, JSON_FORCE_OBJECT | JSON_PRETTY_PRINT);
$f_header[] = "Content-type: application/json";
$f_connection = curl_init ($f_url_connection);

curl_setopt($f_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($f_connection, CURLOPT_HTTPHEADER, $f_header);
curl_setopt($f_connection, CURLOPT_HEADER, false);
curl_setopt($f_connection, CURLOPT_USERPWD, "$f_email_freshdesk:$f_contrasena_freshdesk");
curl_setopt($f_connection, CURLOPT_POSTFIELDS, $f_json_body);
curl_setopt($f_connection, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($f_connection, CURLOPT_VERBOSE, 1);
$f_response = curl_exec ($f_connection);
curl_close ($f_connection);

The problem is that the API does not work, it returns NULL, even connects to update the ticket.

This topic has been closed for comments

15 replies


There is no such API to add a reply to a ticket. However we do have API to add a note to a ticket.

Add Note :

Hope this sample will help you get started.


are there any plans for answering a ticket via api? We want to realise a feature to send an invoice to our customers after generating it in another external system.



Hello Sven, 

This is a feature that is on our roadmap and we plan to take it up shortly. I will update this post once it's out.


+1 This would be really nice to have

This API is currently in development. Will update this post once it's out.

Hello, IS this feature ready where a ticket can be replied through API. If so I request you guys to make it as easy as updating the description in update API

 where the description is sent as a response . 

+1 for this api. i'm looking forfward to see it release out.

Hello Everyone, We have released the public beta for the v2.0 APIs and this endpoint has been included there -

Thank you so much for your patience.

api v2 is great.

1. no more { helpdesk_ticket: .. } needed

2. attachments[][resource] turn to attachments[] ... (why design like that in v1? )

3. we can reply now!

I updated my GasFreshdesk to v2, welcome to use it. (only work inside gas now)

# GasFreshdesk - OO Class for Freshdesk API(v2)

GasFreshdesk is a simple Freshdesk API Class for GAS(Google Apps Script).


var MyFreshdesk = new Freshdesk('', 'token')

var ticket = new MyFreshdesk.Ticket({
description:'A description'
, subject: 'A subject'
, email: ''

body: 'Hi tom, Still Angry'
, private: true
body: 'Hi tom, Still Angry'
, cc_emails: ['']


Logger.log('ticket #' + ticket.getId() + ' was set!')


As I'm working on a migration tool for moving our existing issues from Jira into Freshdesk, I'm still missing one feature; to be able to add a comment with an author email rather than a userId - in many cases the user may not yet exist and I would not have to go through the hassle of looking up his userId from his email. So: please add userEmail to the reply interface.

@mats how about use ticket.reply?

you can specify cc_emails when you send a reply.

Yes, I realize I can *kind of* model it that way, but in the GUI it would still say the reply was made *by* me, with the CC's added. Not quite what I'd like.

Did you try to create a new contact before you create note? Then your user will exist.

After that, you can create note with the exist user_id.


I'm stuck using the reply API while trying to send a message in HTML combined with attachments.

Because of attachments you have to use the form/data version, but then HTML is or rejected, or it prepends a "<div>&quote;</div>" in the body.

Could you post an example of a curl request with HTML AND attachments combined?

Thank you.

PS : alternatively, it would be nice if in the reply API had an option to add the user's html signature stored in Freshdesk instead of having to send it each time.

Replying to self:

the issue was occurring because the HTML I was sending began with a tag. The first character cannot be an opening tag. Simply prepending a blank to the html solved the issue.