Home/Atlassian REST API reference
Jira and Confluence Cloud REST API
Upload and list Confluence attachments by REST API
Upload is a v1 multipart POST to /wiki/rest/api/content/{id}/child/attachment and needs the X-Atlassian-Token header. Listing and deleting use v2. A call without the header is refused with 403 XSRF check failed.
Endpoints
| Method | Path | What it does |
|---|---|---|
POST | /wiki/rest/api/content/{id}/child/attachment | v1: adds an attachment, multipart/form-data. |
GET | /wiki/api/v2/pages/{id}/attachments | v2: lists the attachments of a page. |
DELETE | /wiki/api/v2/attachments/{id} | v2: deletes an attachment. |
Examples
POST /wiki/rest/api/content/{pageId}/child/attachment
Uploads a small text file with the XSRF header set.
curl
# 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/wiki/rest/api/content/{pageId}/child/attachment'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/wiki/rest/api/content/{pageId}/child/attachment',
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
{
"results": [
{
"id": "att33587425",
"type": "attachment",
"status": "current",
"title": "notes.txt",
"version": {
"number": 1
},
"container": {
"id": "33653083",
"type": "page"
}
}
],
"size": 1
}Sent to Atlassian Cloud on .
POST /wiki/rest/api/content/{pageId}/child/attachment
The same kind of upload without the header.
curl
# other.txt contains: x
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-F "file=@other.txt" \
'https://your-domain.atlassian.net/wiki/rest/api/content/{pageId}/child/attachment'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/wiki/rest/api/content/{pageId}/child/attachment',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
files={"file": ('other.txt', b'x')},
)
print(r.status_code, r.text)Response: HTTP 403
{
"statusCode": 403,
"message": "com.atlassian.confluence.mvc.rest.common.exception.StacklessResponseStatusException: 403 FORBIDDEN \"XSRF check failed\""
}Sent to Atlassian Cloud on .
GET /wiki/api/v2/pages/{pageId}/attachments
Lists the attachments of the page with v2.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/wiki/api/v2/pages/{pageId}/attachments'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/wiki/api/v2/pages/{pageId}/attachments',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"results": [
{
"version": {
"number": 1
},
"pageId": "33653083",
"mediaType": "application/octet-stream",
"downloadLink": "/rest/api/content/33653083/child/attachment/att33587425/download",
"title": "notes.txt",
"fileSize": 23,
"id": "att33587425"
}
]
}Sent to Atlassian Cloud on .
DELETE /wiki/api/v2/attachments/{attachmentId}
Deletes the attachment by its id.
curl
curl -X DELETE \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/wiki/api/v2/attachments/{attachmentId}'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.delete(
'https://your-domain.atlassian.net/wiki/api/v2/attachments/{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 .
POST /wiki/rest/api/content/{pageId}/child/attachment
The same upload with the header value spelled nocheck, as the v1 spec writes it. Confluence accepts it.
curl
# nocheck.txt contains: header written as nocheck
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'X-Atlassian-Token: nocheck' \
-F "file=@nocheck.txt" \
'https://your-domain.atlassian.net/wiki/rest/api/content/{pageId}/child/attachment'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/wiki/rest/api/content/{pageId}/child/attachment',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json', 'X-Atlassian-Token': 'nocheck'},
files={"file": ('nocheck.txt', b'header written as nocheck')},
)
print(r.status_code, r.text)Response: HTTP 200
{
"results": [
{
"id": "att33620351",
"type": "attachment",
"title": "nocheck.txt"
}
]
}Sent to Atlassian Cloud on .
How it behaves
- The upload with X-Atlassian-Token: no-check answers 200 with a results array; the attachment id has the form att33587425 (conf-attachment-add).
- Without the header the answer is 403 with the message "XSRF check failed" (conf-attachment-add-no-token).
- The v2 list shows fileSize 23 for the 23-byte file and mediaType application/octet-stream for a .txt upload (conf-attachments-list).
- Delete answers 204 and the id is the same att... id (conf-attachment-delete).
Pitfalls
- Send the header on every multipart call. The 403 body has statusCode and message, not the errors array of v2.
- The attachment id in v2 starts with att. Use that value as it is.
- mediaType in the list was application/octet-stream for a text file. Set the type in the multipart part if the file type matters.
Questions and answers
Can v2 upload files?
The v2 spec has no upload path.
Is nocheck or no-check right?
Both spellings work. The spec text writes nocheck, other Atlassian pages write no-check, and an upload with each value got 200 on 29 Nov 2026.
Related
- Get a page
- Footer comments
- Content properties
- Confluence REST API v1 vs v2
- The current user in Confluence