How to add an attachment to a Jira Service Management Cloud ticket using the REST APIs

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

You want to add an attachment to a Jira Service Management Cloud using REST API.

Solution

Attaching files via REST API

To add attachment(s) to Jira Service Management issues, two (or more) different REST requests are needed.

The first one(s) to add the attachments to the Service Management calling the endpoint: servicedesk/{serviceDeskId}/attachTemporaryFile (2 requests to add 2 files in the below example):

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 REQUEST: curl -D- -u {USER}:{PASSWORD} -H "X-Atlassian-Token: nocheck" -H "X-ExperimentalApi: true" -F "file=@{/path/to/file/test2.txt}" -X POST https://{INSTANCE}.atlassian.net/rest/servicedeskapi/servicedesk/{SERVICE_DESK_ID}/attachTemporaryFile .... HTTP/1.1 100 Continue ..... HTTP/1.1 201 Created ......   RESPONSE: {"temporaryAttachments":[{"temporaryAttachmentId":"5ad41f7b-882a-4f12-8a08-9b401d6dd3bf","fileName":"test2.txt"}]} REQUEST: curl -D- -u {USER}:{PASSWORD} -H "X-Atlassian-Token: nocheck" -H "X-ExperimentalApi: opt-in" -F "file=@{/path/to/file/test3.txt}" -X POST https://INSTANCE.atlassian.net/rest/servicedeskapi/servicedesk/{SERVICE_DESK_ID}/attachTemporaryFile RESPONSE: {"temporaryAttachments":[{"temporaryAttachmentId":"3f9ff4f9-99a0-4ee0-868e-8b93c8c67bee","fileName":"test3.txt"}]}  

To obtain the {SERVICE_DESK_ID} either go to the browser, open the item that you want to update, and look at the URL for the ID, or run a get request to get the available ID(s) like the following example:

1 GET https://INSTANCE.atlassian.net/rest/servicedeskapi/servicedesk

For more information about this please check the documentation.

The second request is to add the temporary files attached to the Service Management at the previous step to a ticket by calling the endpoint: /rest/servicedeskapi/request/{issueIdOrKey}/attachment):

1 2 3 4 5 REQUEST: curl -D- -u {USER}:{PASSWORD} -H "Accept: application/json" -H "Content-Type: application/json" -H "X-ExperimentalApi: opt-in" -d '{"additionalComment": {"body": "BODY OF THE COMMENT, IF ANY"}, "public": "true","temporaryAttachmentIds": ["5ad41f7b-882a-4f12-8a08-9b401d6dd3bf", "3f9ff4f9-99a0-4ee0-868e-8b93c8c67bee"]}' -X POST https://{INSTANCE}.atlassian.net/rest/servicedeskapi/request/{ISSUE_ID}/attachment   RESPONSE: {"comment":{"_expands":["attachment","renderedBody"],"id":"10504","body":"BODY OF THE COMMENT, IF ANY: adding 2 attachments\n\n[^test2.txt] _(0.0 kB)_\n\n[^test3.txt] _(0.0 kB)_","public":true,...............}

The arguments to be passed with the request are:

    1. "public": Whether the attachment should be public (visible on the portal for the customer) or not. The accepted values are true or false. Mandatory

    2. "temporaryAttachmentIds": The ID(s) of the temporary file(s) received in the response(s) to the previous request(s)

    3. "additionalComment" : {"body": ".........."}: In case you want to add a comment you can add a string as the comment body. Otherwise you can just avoid using this block. This is not mandatory.

For further details please see:

Updated on April 14, 2025

Still need help?

The Atlassian Community is here for you.