Question
Can I attach files such as photos to a ticket using the Zendesk application programming interface (API)?
Answer
Yes. When you attach a file to a ticket and the account requires authentication to download attachments, Zendesk restricts the attachment visibility only to users who have access to the ticket. Until you associate the attachment with a ticket, any authenticated user can view the attachment using the content_URL. The attachment token expires after 60 minutes.
To attach a file:
- Use the Upload Files API endpoint that returns a token
- Include the token in a ticket comment using the
uploadsarray when you create or update a ticket. If you don't complete this step, Zendesk deletes the uploaded files and displays a404 not founderror when the token expires.
Example
{
"ticket": {
"comment": { "body": "See screenshot.", "uploads": ["vz7ll9ud8oofowy"] }
}
}
Note: Private attachments are available in tickets in messaging 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 might restrict the file types that you can upload in the account using the Allowed file types settings in Admin Center. These restrictions apply to ticket attachments and files that you upload through the API. For more information, see Restrict ticket attachments to Zendesk-recommended file types.