REST API - Attachments


Get attachments

Please read official documentation Confluence REST API Documentation - getAttachments

 


Get all versions of attachment

Available only for:

  • users in group confluence-administrators

  • users who can VIEW the page with this attachment

This API supports Pagination

Method type: GET

URL: {CONFLUENCE_URL}/rest/extender/1.0/content/attachment/{ATTACHMENT_ID}/versions

  • where {ATTACHMENT_ID} is the attachment id

Response format: JSON

Example response:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 { "total": 5, "versions": [ { "fileSize": 10342, "creatorName": "admin", "comment": "", "creationDate": 1657610335026, "version": 5, "fileSizeNice": "10 kB" }, { "fileSize": 10342, "creatorName": "admin", "comment": "", "creationDate": 1657610331450, "version": 4, "fileSizeNice": "10 kB" }, { "fileSize": 10342, "creatorName": "admin", "comment": "", "creationDate": 1657610327882, "version": 3, "fileSizeNice": "10 kB" }, { "fileSize": 10342, "creatorName": "admin", "comment": "", "creationDate": 1657610312649, "version": 2, "fileSizeNice": "10 kB" }, { "fileSize": 10342, "creatorName": "admin", "comment": "", "creationDate": 1657610309971, "version": 1, "fileSizeNice": "10 kB" } ], "fileExtension": "xlsx", "maxResults": 100, "name": "Book1.xlsx", "id": 819207, "startAt": 0 }

 


Delete attachment

Removes an Attachment and its data from the server and data store (and all of its versions)

Available only for:

  • users in group confluence-administrators

  • users who can EDIT the page with this attachment AND has the right to delete attachments for the space where the attachment is located

Method type: DELETE

URL: {CONFLUENCE_URL}/rest/extender/1.0/content/attachment/{ATTACHMENT_ID}/delete

  • where {ATTACHMENT_ID} is the attachment id

Response format: JSON

Example response:

1 2 3 { "message": "attachment with id '1441802' does not exist" }
1 2 3 4 { "message": "Attachment 'Book1.xlsx' deleted.", "status": "success" }

 


Delete specific versions of an attachment

Removes the given version of the Attachment and its data from the server and data store.

Available only for:

  • users in group confluence-administrators

  • users who can VIEW the page with this attachment AND has space administrator rights

Method type: DELETE

URL: {CONFLUENCE_URL}/rest/extender/1.0/content/attachment/{ATTACHMENT_ID}/delete/{VERSION_ID}

  • where {ATTACHMENT_ID} is the attachment id

  • where {VERSION_ID} is the version id

Response format: JSON

Example response:

1 2 3 { "message": "attachment with id '1638412' does not exist" }
1 2 3 4 { "message": "version '3' of the 'Book1.xlsx' attachment has been removed", "status": "success" }
1 2 3 { "message": "version '3' of the 'Book1.xlsx' attachment does not exist" }

 


Pagination

This REST API uses pagination to improve performance for all users. Pagination is enforced for methods that could return a large collection of items. When you make a request to a paged API, the response will wrap the returned array of values in a JSON object with paging metadata, for example:

1 2 3 4 5 6 7 8 9 10 {     "startAt" : 0,     "maxResults" : 10,     "total": 200,     "objects": [         { /* result 0 */ },         { /* result 1 */ },         { /* result 2 */ }     ] }

 

Where:

  • startAt is the index of the first item returned in the page of results.

  • maxResults is the maximum number of items that can be returned per page. Each API endpoint may have a different limit for the number of items returned, and these limits may change without notice. (default value - 100)

  • total is the total number of items contained in all pages. This number may change as the client requests the subsequent pages, therefore the client should always assume that the requested page can be empty.