Developer Portal for YouTrack and Hub Help

Attach Files to an Issue

Use Case

Use the REST API to upload one or more files to an existing issue.

Summary

To attach a file to an issue:

  1. Get a list of issues to get the entity ID of the target issue.

  2. Attach files to the issue by sending a POST request to the following endpoint:

    /api/issues/{issueID}/attachments

Step-by-Step

  1. Get the list of issues in a target project.

    curl -X GET 'https://example.youtrack.cloud/api/issues?query=in:NP&$top=3&fields=id,idReadable,summary' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer perm:cm9vdA==.MjZGZWI=.WB02vjX0cM2ltLTJXUE3VOWHpJYYNx'

    The query request parameter lets us filter the list of issues by a search query. In this sample, we use the query to get only the issues that belong to the target project (NP).

    For this particular example, to shorten the list of returned issues, we use $top=3 parameter to get only first three found issues.

    In the fields request parameter, we instruct the server to return the following attributes for each issue found:

    • id and idReadable - both database entity ID and an ID of the issue in the project, respectively.

    • summary - issue's summary may help to identify the target issue.

    In the response to this request, the server returns the following data:

    [ { "summary": "Investigation task", "idReadable": "NP-56", "id": "99-356", "$type": "Issue" }, { "summary": "Marketing activities", "idReadable": "NP-39", "id": "99-303", "$type": "Issue" }, { "summary": "TODO for release", "idReadable": "NP-77", "id": "99-500", "$type": "Issue" } ]
  2. Locate the ID of the target issue. In this case, let's take the issue NP-77 with the database ID 99-500.

  3. To attach files to an issue, send a POST request with the file content to the following endpoint:

    /api/issues/{issueID}/attachments

    This endpoint expects file upload data in multipart/form-data format. Use this request pattern when you upload a file using multipart/form-data, for example with the cURL -F upload=@... option.

    For this use case, we use the following cURL command:

    curl -v -i -F upload=@/Users/jetbrains/Downloads/youtrack.txt \ -F upload=@/Users/jetbrains/Downloads/youtrack_new.jpeg \ -H 'Authorization: Bearer perm:cm9vdA==.MjZGZWI=.WB02vjX0cM2ltLTJXUE3VOWHpJYYNx' \ -H 'Content-Type: multipart/form-data' \ -X POST 'https://example.youtrack.cloud/api/issues/99-500/attachments?fields=id,name'

    Here are the key parts of this request:

    • -F upload=@/Users/jetbrains/Downloads/youtrack.txt uploads a file as a multipart form field named upload.

    • To attach multiple files in one request, repeat the -F upload=@... option for each file:

      -F upload=@/Users/jetbrains/Downloads/youtrack.txt \ -F upload=@/Users/jetbrains/Downloads/youtrack_new.jpeg
    • The @ prefix tells cURL to read the file content from the local filesystem.

    • Content-Type: multipart/form-data is the correct content type for this upload pattern.

    In the response, the server returns the name and database entity ID of the attached files:

    [ {"name":"youtrack.txt","id":"134-31","$type":"IssueAttachment"}, {"name":"youtrack_new.jpeg","id":"134-32","$type":"IssueAttachment"} ]

That’s it: we’ve attached all our files to the issue.

21 April 2026