Overview
This article will cover how to attach files, such as photos, to a ticket using the Zendesk API.
Conditions
When a file is attached to a ticket, 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 three days.
Note: If step 2 below is not completed, the uploaded files will be deleted and will appear missing (returning a
404 not found
error) when the upload token expires.Procedure
1. Use our Uploading files API, which returns a token.
2. Include the token in a ticket comment via the uploads
array while creating or updating a ticket.
Example:
{ "ticket": { "comment": { "body": "See screenshot.", "uploads": ["vz7ll9ud8oofowy"] } } }
32 Comments
Hello Chris,
Can we attach other file formats to a ticket? For example, users can attach documents and videos to a ticket.
This resource is rather sparse! Might as well go straight to https://developer.zendesk.com/rest_api/docs/core/attachments#uploading-files :p
Hi Clare-
You can use the upload attachment API to upload the same type of files as you can via the agent interface.
I am using attachment API to upload any files to create ticket.When I check ticket and download that attachemnt , it is not download.
Note : filename like abc.png is in my system .
const url = "https://fyttest.zendesk.com/api/v2/uploads.json?filename="+filename;
Request json :
{
"attachment": {
"size": size
}
};
Ques : Is there anything missing in Request json fields?
Hi Vaishali,
I'm afraid I'm not understanding your question. It looks like you've already reached out to support@zendesk.com with a very similar question. I'll see that someone reaches out to you on that ticket as we may need to get more clarification/examples to see what's going on here.
Thanks,
Does this work creating ticket as requester? because i am trying to do it and image is not showing on my support zendesk.
Hi Ricardo,
The syntax you sent there looks correct to me! Is it possible that the upload-token has already been consumed? If it's already been used in a given ticket-comment, it's attached to that ticket and subsequent requests using that same token will not attach it to tickets. In that case, it should be possible to reference the attachment URL from the original comment, but this requires permission to access the original location.
If you'd like us to look into your case more closely, please feel free to reach out to support@zendesk.com or I'd be happy to take this conversation into a ticket for privacy.
Hi Folks,
I am trying to post an attachment through API to a newly created ticket. I read all the material on the Support but still could not find how this can be done without an ID.
Can anyone please help ? My Use Case is as below.
Get Comment and Attachment from DW
Create a ticket in Zendesk with Attachment
Thanks in Advance,
Chinmay
Hi Chinmay,
It is currently only possible to include attachments to tickets via the API by first uploading the required attachment using the Uploading files API.
Once uploaded, you can use the resulting token ID to include this in any ticket where required.
In your particular use case, you'd need to follow these steps for this to work:
It is not currently possible to create a ticket and upload a new file as an attachment in a single request.
Hope this helps clarify!
- Dylan
Hi Dylan,
Thank you for the quick response.
Could you please share the syntax to upload a file followed by getting the token? I am new to this and I could not find anything where we can directly upload a file without ID and then get the token number ?
Thanks in advance.
Chinmay
Hey Chinmay,
I'm going to take this into a ticket and email you directly to help troubleshoot any issues you're currently having uploading files to then use as attachments.
Look out for an email from me shortly!
- Dylan
Hi, Dylan,
I used your ZDKRequestAttachment API and it's OK. But I have some questions:
- How to find out that it's a first request message (support conversations just started); maybe message count in support session could be requested
- Is it possible to attach just URL (or maybe initialize request message text with initial text data)
- How to use static method HelpCenterActivity::isShowingHelp and is it possible to do the same on iOS?
Best regards,
Vyacheslav
Hello Vyacheslav Meshkov -- this looks like a mobile development question. This article is focused just on the REST attachment APIs. For mobile specific community questions, please post here:
https://develop.zendesk.com/hc/en-us/community/topics/360000018828-Zendesk-Mobile-SDKs
If you don't get a timely response, feel free to submit a ticket.
Hi Bryan,
I am upload a picture through API and it uploaded successfully but when I see that attachment on agent portal it does not show. It seems like a corrupted image.
Hi raghees. Can you give a detailed example of the command you're using to upload the file? Know that when uploading an image file, make sure Content-Type: application/binary is used.
Also, if you happen to be writing an Apps framework app, files and binary content cannot be uploaded or downloaded via the client.request command.
Thanks Bryan, I am using 'POST /api/v2/uploads.json' command for uploading files which is allowed for end users. I am using a node server to upload images with request client called 'request-promise' with the header Content-type: application/binary .
As you have mentioned that binary content cannot be uploaded via client.request command. Is their any example with javascript or any workaround ?
Moved above attachment upload conversation to other community post: https://support.zendesk.com/hc/en-us/community/posts/360038177733-Attach-images-are-broken-in-agent-s-portal?page=1#community_comment_360010148893
Hi Bryan,
What is the API URL to attach file to ticket. I am trying this api/v2/tickets/{id}/related.json, but couldn't see attachment in ticket. I have followed the sequence like first to upload an attachment and then using the token received, i am calling above mention API.
Hi Vijay Kumar! The endpoint that you're using there is only available for a GET, so you can not attach the attachment token to the ticket with that. You would need to use a create or update type of endpoint, such as this one.
Hi,
Is it possible to add an attachment to an internal note - comment ?
This is my case :
I have a python program which scans ticket and attachment when a ticket is created. There are files that need to be converted in order for us to work on it. I would like to automate the conversion of the original file by adding a function in the python program which converts the original file and add the converted file to an internal note.
Is it possible with the API "upload files" ? : https://developer.zendesk.com/rest_api/docs/support/attachments#upload-files
Is there another way to do it ?
Hi Antoine Morel -- check out this other community post. It talks about file uploads using Python. Perhaps this would help get you to your next step: Python file upload
Hi @...,
I could attach the file which is an image but when I go to the support there is a png file attached and when I click it doesn't show anything...
I uploaded the file via upload.json API, and then I call requests.json API like this:
{
"request": {
"subject": "test",
"comment": {
"body": "testing",
"uploads": ["O5wcPtlQLMy7vUklJF2sz6BEO"]
},
"requester": {
"name": "test",
"email": "test@test.com",
"locale": "en-GB",
"locale_id": 1
}
}
Thanks
Hi Gemma,
This sounds like a misbehavior to me. Please raise a ticket with our Support team to look into this further as I suspect they'll want to look through logs and settings specific to your account.
Thanks!
Hey Gemma,
Looks like you already have a ticket open related to this issue. We will continue working with you there to troubleshoot further.
Thanks for taking the time to share this with us!
Hi Brett,
Any update regarding this issue. As i am also facing the same issue, Unable to view the attachment same as Gemma.Garcias. When can i expect the fix for this ?
Hello Ganesh Kumar,
Right now, we don't have an estimate on a fix for this issue, but I would recommend reaching out to our Advocacy team via Chat so they can look into this issue for you.
Best regards.
I also am not able to view uploaded images when attaching tokens in `comment.uploads` array.
Looked through a ton or articles and can't find the answer as to why the attachment doesn't show up in the ticket. I do not have auth required to view the images either.
Can anyone point me in the right direction here?
Hey Chris,
Looks like you haven't received a response yet. Are you still running into issues uploading images? If so, I'll need to create a ticket on your behalf so our team can look into this further with you.
Let me know!
Hello,
Is it possible to upload files using jQuery AJAX Http post method? If yes, can anyone help with a code sample?
Thank you,
Holly
Hi Holly C,
If you want to upload a file using POST /api/v2/uploads.json in an Apps framework app (aka "ZAF app"), here's example ticket_sidebar code. This is a slightly modified version of a great comment from this older community post.
Example/unsupported code:
Know that file uploading is affected by this setting:
If you have this *unchecked*, you'll need to provide an Authorization header with an OAuth/Bearer token as mentioned in the example code above.
Hope this helps get you to your next step!
Please sign in to leave a comment.