# Upload and manage Jira attachments with the REST API

URL: https://goingstellar.ro/reference/atlassian-rest-api/jira-attachments/

POST /rest/api/3/issue/{issueIdOrKey}/attachments takes multipart/form-data with the file in a part named file. The request must carry X-Atlassian-Token: no-check. Without that header Jira answers 404 with the text XSRF check failed, which looks like a missing work item and is not.

## Endpoints

| Method | Path | What it does |
|---|---|---|
| POST | `/rest/api/3/issue/{issueIdOrKey}/attachments` | Uploads one or more files to a work item. |
| GET | `/rest/api/3/attachment/{id}` | Returns the metadata of an attachment. |
| DELETE | `/rest/api/3/attachment/{id}` | Deletes an attachment. |
| GET | `/rest/api/3/attachment/meta` | Returns whether attachments are enabled and the size limit. |

## Examples

### POST /rest/api/3/issue/{issueIdOrKey}/attachments

Uploads notes.txt as a multipart part named file but leaves out X-Atlassian-Token. The upload is blocked.

```bash
# notes.txt contains: hello
curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -F "file=@notes.txt" \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/attachments'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/attachments',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    files={"file": ('notes.txt', b'hello')},
)
print(r.status_code, r.text)
```

Response: HTTP 404

```
XSRF check failed
```

Sent to Atlassian Cloud on 29 Nov 2026.

### POST /rest/api/3/issue/{issueIdOrKey}/attachments

The same upload with X-Atlassian-Token: no-check. The response is an array with one entry per file.

```bash
# notes.txt contains: hello from the REST API
curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'X-Atlassian-Token: no-check' \
  -F "file=@notes.txt" \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/attachments'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/attachments',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json', 'X-Atlassian-Token': 'no-check'},
    files={"file": ('notes.txt', b'hello from the REST API')},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
[
 {
  "id": "10000",
  "filename": "notes.txt",
  "created": "2026-11-29T19:30:11.325+0200",
  "size": 23,
  "content": "https://your-domain.atlassian.net/rest/api/3/attachment/content/10000"
 }
]
```

Response headers:

```
X-Ratelimit-Limit: 200
```

Sent to Atlassian Cloud on 29 Nov 2026.

### GET /rest/api/3/attachment/meta

Reads the instance settings: attachments on, and the largest upload in bytes.

```bash
curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/attachment/meta'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/attachment/meta',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "enabled": true,
 "uploadLimit": 1073741824
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### GET /rest/api/3/attachment/{attachmentId}

Reads the metadata of the uploaded attachment by id.

```bash
curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/attachment/{attachmentId}'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/attachment/{attachmentId}',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "id": 10000,
 "filename": "notes.txt",
 "created": "2026-11-29T19:30:11.325+0200",
 "size": 23,
 "content": "https://your-domain.atlassian.net/rest/api/3/attachment/content/10000"
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### DELETE /rest/api/3/attachment/{attachmentId}

Deletes the attachment. Success has no body.

```bash
curl -X DELETE \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/attachment/{attachmentId}'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.delete(
    'https://your-domain.atlassian.net/rest/api/3/attachment/{attachmentId}',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)
```

Response: HTTP 204

No response body.

Sent to Atlassian Cloud on 29 Nov 2026.

## How it behaves

- Without X-Atlassian-Token: no-check the multipart upload was answered 404 with the plain text XSRF check failed, although the work item exists.
- A successful upload answered 200, not 201, and the body is a JSON array. Each entry has id, filename, size, created and a content URL under /rest/api/3/attachment/content/{id}.
- The id is a string in the upload response ("10000") and a number in GET /attachment/{id} (10000).
- GET /attachment/meta returned enabled true and uploadLimit 1073741824, which is 1 GiB in bytes.
- The attachment metadata call returns the author with a displayName and active flag but no emailAddress.

## Pitfalls

- Send the file as a multipart part named file, as the spec requires. A JSON body is not an upload.
- The header is required on every upload, from every client. Add it once in the HTTP layer instead of per call.
- A 404 on this endpoint can mean the missing header as well as a missing work item. Read the body before deciding.
- Keep the id from the upload response. DELETE and GET both address the attachment by that id and not by file name.

## Questions and answers

### Why does my attachment upload return 404 for a work item that exists?

The X-Atlassian-Token: no-check header is probably missing. The blocked request answered 404 with the text XSRF check failed.

### How large can an attachment be?

GET /rest/api/3/attachment/meta reports the limit in bytes. On this instance it was 1073741824.

## Related

- [X-Atlassian-Token: no-check](https://goingstellar.ro/reference/atlassian-rest-api/xsrf-no-check-header/)
- [Content-Type and 415](https://goingstellar.ro/reference/atlassian-rest-api/content-type-and-415/)
- [Attachments](https://goingstellar.ro/reference/atlassian-rest-api/confluence-attachments/)
- [Comments](https://goingstellar.ro/reference/atlassian-rest-api/issue-comments/)

## Sources

- [The Jira Cloud platform REST API v3 (Atlassian Developer)](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/)
- [Security for other integrations, Jira (Atlassian Developer)](https://developer.atlassian.com/cloud/jira/platform/security-for-other-integrations/)
- [Add attachment (Jira REST API v3)](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post)

