How to Attach Files to Topics using the Zendesk API

It seems to be undocumented in the API but through some questions on the forums I got it working. Here is a guide for someone else looking to do it as well.

Process

  • First you upload the file you need to attach to the topic:
curl https://yourcompany.zendesk.com/api/v2/uploads.json?filename=binary.bin \
  -H "Content-Type: application/binary" \
  --data-binary path/to/binary.bin \
  -v -u email@yourcompany.com:password
  • Next you need to grab the “token” from the returned JSON string. It will be a 15 character string i.e. “brztup9rng1ywaw”. You can do this many times to attach all the files at once.
  • Finally you update the topic you want to attach the files to. This assumes you have the topic id you want to update i.e. “24982733” in this example, if you don’t you would have to find that first.
curl https://yourcompany.zendesk.com/api/v2/topics/24982733.json \
  -H "Content-Type: application/json" \
  -d '{"topic":{"uploads":["brztup9rng1ywaw"]}}' \
  -v -u email@yourcompany.com:password -X PUT
comments powered by Disqus