Question

Can I attach files, such as photos, to a ticket using the Zendesk API?

Answer

Yes, when a file is attached to a ticket, and if the account requires authentication to download attachments, the attachment's visibility becomes restricted to only users with access to the ticket. Until the attachment is associated with a ticket, any authenticated user can view an attachment using its content_URL. The attachment's token expires after 60 minutes.

To do this

  1. Use the Upload Files API end point, which returns a token.
  2. Include the token in a ticket comment by the uploads array while creating or updating a ticket. If you don't complete this step, Zendesk will delete the uploaded files and display a 404 not found error when the upload token expires.

Example

{
  "ticket": {
    "comment":  { "body": "See screenshot.", "uploads":  ["vz7ll9ud8oofowy"] }
  }
}
Note: Private attachments are available in messaging tickets for end users and ticket assignees. These attachments provide a higher level of security, and users have limited access to these types of attachments.
Tip: If an upload fails for certain file extensions, an admin may have restricted which file types can be uploaded in the account using the Allowed file types settings in Admin center. These restrictions apply to ticket attachments, including files uploaded through the API. For more information, see this article: Restricting ticket attachments to Zendesk-recommended file types.
Powered by Zendesk