How to get ticket attachment by API (PHP)


  • Satria Faestha

    Okay. I got the answer from

    But I still need to modify Zendesk/API/Resources/Core/Attachments.php to add new function 'comments'. it seems the naming not good and confusing but it's working for me.

    protected function setUpRoutes()
          'upload' => "uploads.json",
          'deleteUpload' => "uploads/{token}.json",
          'show' => "attachments/{id}.json",
          'comments' => "tickets/{id}/comments.json"

    public function comments($id=null)
       $response = Http::send(
          $this->getRoute(__FUNCTION__, ['id' => $id]),
          ['method' => 'GET']

       return $response;

    Then I call the function like this:
    $attachments = $client->attachments()->comments($ticketId);

  • Greg - Community Manager
    Zendesk Developer Support

    Thank you for sharing your solution, Satria Faestha! IF you've moved this into further testing/production, could you let us know if you've run into any problems with this? If so, please let us know to see if we can help.


Please sign in to leave a comment.

Powered by Zendesk