Attachments

This API is for attachments in tickets and forum posts in the Web portal. For attachments in Help Center articles, see Article Attachments in the Help Center API documentation.

JSON Format

Attachments are represented as JSON objects with the following keys:

Name Type Read-only Comment
id integer yes Automatically assigned when created
file_name string yes The name of the image file
content_url string yes A full URL where the attachment image file can be downloaded
content_type string yes The content type of the image. Example value: image/png
size integer yes The size of the image file in bytes
thumbnails array yes An array of Photo objects. Note that thumbnails do not have thumbnails.
Example
{
  "id":           928374,
  "file_name":    "my_funny_profile_pic.png",
  "content_url":  "https://company.zendesk.com/attachments/my_funny_profile_pic.png",
  "content_type": "image/png",
  "size":         166144,
  "thumbnails": [
    {
      "id":           928375,
      "file_name":    "my_funny_profile_pic_thumb.png",
      "content_url":  "https://company.zendesk.com/attachments/my_funny_profile_pic_thumb.png",
      "content_type": "image/png",
      "size":         58298
    }
  ]
}

Uploading files

POST /api/v2/uploads.json

Adding multiple attachments to the same upload is handled by splitting requests and passing the API token received from the first request to each subsequent request.

Note: Until the upload token is consumed, uploaded files are visible to any authenticated user. Once an attachment is associated with a ticket or post, visibility is restricted to users with access to the ticket or post with the attachment.

Allowed For
  • End Users
Using curl
 curl -u username:password -H "Content-Type: application/binary" \
   --data-binary @file.dat -X POST \
   "https://helpdesk.zendesk.com/api/v2/uploads.json?filename=myfile.dat&token={optional_token}"
Example Response
Status: 201 Created
Location: https://helpdesk.zendesk.com/api/v2/attachments/498483.json

{
  "upload": {
    "token": "6bk3gql82em5nmf",
    "attachment": {
      "id":           498483,
      "name":         "crash.log",
      "content_url":  "https://company.zendesk.com/attachments/crash.log",
      "content_type": "text/plain",
      "size":         2532,
      "thumbnails":   []
    },
    "attachments": [
      {
        "id":           498483,
        "name":         "crash.log",
        "content_url":  "https://company.zendesk.com/attachments/crash.log",
        "content_type": "text/plain",
        "size":         2532,
        "thumbnails":   []
      }
    ]
  }
}

Deleting Uploads

DELETE /api/v2/uploads/{token}.json

Allowed For
  • Agents
Using curl
 curl -u username:password -X DELETE https://helpdesk.zendesk.com/api/v2/uploads/{token}.json
Example Response
200 OK

Getting Attachments

GET /api/v2/attachments/{id}.json

Allowed For
  • Agents
Using curl
 curl -u username:password https://helpdesk.zendesk.com/api/v2/attachments/{id}.json
Example Response
{
  "attachment": {
    "id":           498483,
    "name":         "myfile.dat",
    "content_url":  "https://company.zendesk.com/attachments/myfile.dat",
    "content_type": "application/binary",
    "size":         2532,
    "thumbnails":   [],
    "url":          "https://company.zendesk.com/api/v2/attachments/498483.json",
  }
}

Deleting Attachments

DELETE /api/v2/attachments/{id}.json

Currently, only attachments on forum posts are allowed to be deleted.

Allowed For
  • Agents
Using curl
 curl -u username:password -X DELETE https://helpdesk.zendesk.com/api/v2/attachments/{id}.json
Example Response
200 OK

Redacting comment attachments

PUT /api/v2/tickets/{ticket_id}/comments/{comment_id}/attachments/{attachment_id}/redact.json

Redaction allows you to permanently remove attachments from an existing comment on a ticket. Once removed from a comment, the attachment is replaced with a placeholder, "redacted.txt" file.

Please note that redaction is permanent. It is not possible to undo redaction or see what was removed. Once a ticket is closed the redaction of its attachments is no longer possible.

Allowed for
  • Admins
Using curl
curl https://{subdomain}.zendesk.com/api/v2/tickets/{ticked_id}/comments/{comment_id}/attachments/{id}/redact.json \
  -H "Content-Type: application/json" -v -u {email_address}:{password} -X PUT -d '{}'
Example Response
Status: 200 OK

{
  "attachment": {
    "id": 65432
    ...
  }
}