Attachments

This API is for tickets attachments. 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 properties:

Name Type Read-only Mandatory Description
content_type string true false The content type of the image. Example value: "image/png"
content_url string true false A full URL where the attachment image file can be downloaded
deleted boolean true false If true, the attachment has been deleted
file_name string true false The name of the image file
id integer true false Automatically assigned when created
inline boolean true false If true, the attachment is excluded from the attachment list and the attachment's URL can be referenced within the comment of a ticket. Default is false
mapped_content_url string true false The URL the attachment image file has been mapped to
size integer true false The size of the image file in bytes
thumbnails array true false An array of attachment objects. Note that photo thumbnails do not have thumbnails
url string true false A URL to access the attachment details

A file represented as an Attachment Attachment object

Example
{
  "content_type": "image/png",
  "content_url": "https://company.zendesk.com/attachments/my_funny_profile_pic.png",
  "file_name": "my_funny_profile_pic.png",
  "id": 928374,
  "size": 166144,
  "thumbnails": [
    {
      "content_type": "image/png",
      "content_url": "https://company.zendesk.com/attachments/my_funny_profile_pic_thumb.png",
      "file_name": "my_funny_profile_pic_thumb.png",
      "id": 928375,
      "size": 58298
    }
  ]
}

Show Attachment

  • GET /api/v2/attachments/{attachment_id}
Allowed for
  • Agents
Parameters
Name Type In Required Description
attachment_id integer Path true The ID of the attachment
Using curl
curl https://{subdomain}.zendesk.com/api/v2/attachments/{attachment_id} \
  -v -u {email_address}:{password}
Example Response
Status 200 OK

{
  "attachment": {
    "content_type": "application/binary",
    "content_url": "https://company.zendesk.com/attachments/myfile.dat",
    "file_name": "myfile.dat",
    "id": 498483,
    "size": 2532,
    "thumbnails": [],
    "url": "https://company.zendesk.com/api/v2/attachments/498483.json"
  }
}

Redact Comment Attachment

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

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

The redaction is permanent. It is not possible to undo redaction or see what was removed. Once a ticket is closed, redacting its attachments is no longer possible.

Also, if you want to redact an inline attachment, you can use the include_inline_images parameter in the List Comments operation to obtain the inline attachment ID, and use it in the request URL.

Allowed For
Parameters
Name Type In Required Description
attachment_id integer Path true The ID of the attachment
comment_id integer Path true The ID of the comment
ticket_id integer Path true The ID of the ticket
Using curl
curl https://{subdomain}.zendesk.com/api/v2/tickets/{ticket_id}/comments/{comment_id}/attachments/{attachment_id}/redact \
  -H "Content-Type: application/json" -v -u {email_address}:{password} -X PUT -d '{}'
Example Response
Status 200 OK

{
  "attachment": {
    "content_type": "application/binary",
    "content_url": "https://company.zendesk.com/attachments/myfile.dat",
    "file_name": "myfile.dat",
    "id": 498483,
    "size": 2532,
    "thumbnails": [],
    "url": "https://company.zendesk.com/api/v2/attachments/498483.json"
  }
}

Upload Files

  • POST /api/v2/uploads

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. The token is valid for 3 days.

Note: Even if private attachments are enabled in the Zendesk Support instance, uploaded files are visible to any authenticated user at the content_URLspecified in the JSON response until the upload token is consumed. 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 "https://{subdomain}.zendesk.com/api/v2/uploads?filename=myfile.dat&token={optional_token}" \
  -data-binary @file.dat \
  -v -u {email_address}:{password} \
  -H "Content-Type: application/binary" \
  -X POST
Example Response
Status 201 Created

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

Delete Upload

  • DELETE /api/v2/uploads/{token}
Allowed for
  • End Users
Parameters
Name Type In Required Description
token string Path true The token of the uploaded attachment
Using curl
curl https://{subdomain}.zendesk.com/api/v2/uploads/{token} \
  -v -u {email_address}:{password} -X DELETE
Example Response
Status 204 No Content