How can I download all attachments in a ticket?

Question

Can I download all ticket attachments in Zendesk Support?

Answer

Zendesk Support doesn't have a full download or export functionality for attachments. However, you can use the Zendesk API for both an individual ticket and for all tickets.

For an individual ticket

To retrieve the attachments of one ticket:

Find your attachment URLs within: https://subdomain.zendesk.com/api/v2/tickets/TICKET_ID/comments.json

Replace the subdomain with your actual subdomain and TICKET_ID with your ticket ID

Each comment has an attachments array attribute, which contains a link to any attachment included in that comment. To get the file associated with it, download the file linked at the content_url attribute.

For all tickets

To retrieve the attachments of all tickets:

Accounts with access to exports can perform a JSON export of tickets, which contains links to the various attachments as: https://subdomain.zendesk.com/api/v2/attachments/ATTACHMENT_ID.json

Note: The same attachment links will show up in the JSON export associated with user photos. If that user has been deleted or changed their photo, those links will fail to return files.

Replace the subdomain with your actual subdomain and ATTACHMENT_ID with the attachment ID

To download the attachments associated with each link, perform a GET request to that attachments endpoint

Then, download the file linked at the content_url attribute

Private attachments and authentication

For accounts created on or after December 5, 2024, or those that use messaging, attachments can be marked as private. This introduces specific requirements for programmatic access:

Authentication is required: Unlike public attachments, private attachments can't be accessed through a browser without an active session or through the API without valid credentials. You must use Basic Authentication, email or token, or an OAuth bearer token.

Token-based content URLs: The content_url provided by the API for private attachments is often a pre-signed, temporary URL

Link expiry: These URLs are short-lived. If you perform a bulk migration or download, you must download the file immediately after you access the attachment endpoint. Don't store the content_url for later use, as it will expire and return a 403 Forbidden error.

Permissions: The API credentials used must have the permissions of an agent or admin who has access to the specific ticket where the attachment resides