Audit
Content
Content - attachments
Content body
Content - children and descendants
Content - macro body
Content comments
Content labels
Content permissions
Content properties
Content restrictions
Content versions
Content watches
Dynamic modules
Group
Inline tasks
Label info
Long-running task
Relation
Search
Settings
Space
Space permissions
Space properties
Space settings
Template
Themes
Users

Rate this page:

Content - attachments

Get attachments

GET /wiki/rest/api/content/{id}/child/attachment

Returns the attachments for a piece of content.

By default, the following objects are expanded: metadata.

Permissions required: Permission to view the content. If the content is a blog post, 'View' permission for the space is required.

Connect app scope requiredREAD

OAuth scopes required
read:confluence-content.summary

Request

Path parameters
id Required

string

The ID of the content to be queried for its attachments.

Query parameters
expand

Array<string>

A multi-value parameter indicating which properties of the content to expand.

In addition, the following comment-specific expansions can be used:

  • extensions.inlineProperties returns inline comment-specific properties.
  • extensions.resolution returns the resolution status of each comment.
Style: form

Valid values: childTypes.all, childTypes.attachment, childTypes.comment, childTypes.page, container, metadata.currentuser, metadata.properties, metadata.labels, metadata.frontend, operations ...(Show more)

start

integer

The starting index of the returned attachments.

Default: 0, Minimum: 0, Format: int32
limit

integer

The maximum number of attachments to return per page. Note, this may be restricted by fixed system limits.

Default: 25, Minimum: 0, Format: int32
filename

string

Filter the results to attachments that match the filename.

mediaType

string

Filter the results to attachments that match the media type.

Example

1
2
3
4
curl --request GET \
  --url 'https://api.atlassian.com/ex/confluence/:cloudId:/wiki/rest/api/content/{id}/child/attachment' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Accept: application/json'

Responses

Returned if the requested attachments are returned.

Content typeValue
application/json

ContentArray

Create or update attachment

PUT /wiki/rest/api/content/{id}/child/attachment

Adds an attachment to a piece of content. If the attachment already exists for the content, then the attachment is updated (i.e. a new version of the attachment is created).

Note, you must set a X-Atlassian-Token: nocheck header on the request for this method, otherwise it will be blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.

The media type 'multipart/form-data' is defined in RFC 7578. Most client libraries have classes that make it easier to implement multipart posts, like the MultipartEntityBuilder Java class provided by Apache HTTP Components.

Note, according to RFC 7578, in the case where the form data is text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used in that part. In the case of this API endpoint, the comment body parameter should be sent with type=text/plain and charset=utf-8 values. This will force the charset to be UTF-8.

Example: This curl command attaches a file ('example.txt') to a piece of content (id='123') with a comment and minorEdits=true. If the 'example.txt' file already exists, it will update it with a new version of the attachment.

1
2
3
4
5
6
7
8
curl -D- \
  -u admin:admin \
  -X PUT \
  -H 'X-Atlassian-Token: nocheck' \
  -F 'file=@"example.txt"' \
  -F 'minorEdit="true"' \
  -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
  http://myhost/rest/api/content/123/child/attachment

Permissions required: Permission to update the content.

Connect app scope requiredWRITE

OAuth scopes required
write:confluence-file

Request

Path parameters
id Required

string

The ID of the content to add the attachment to.

Query parameters
status

string

The status of the content that the attachment is being added to. This should always be set to 'current'.

Default: current

Valid values: current, draft

Body parameters
Content typeValue
multipart/form-data

object

Example

1
2
3
4
curl --request PUT \
  --url 'https://api.atlassian.com/ex/confluence/:cloudId:/wiki/rest/api/content/{id}/child/attachment' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Accept: application/json'

Responses

Returned if the attachments were added to the content.

Content typeValue
application/json

ContentArray

Create attachment

POST /wiki/rest/api/content/{id}/child/attachment

Adds an attachment to a piece of content. This method only adds a new attachment. If you want to update an existing attachment, use Create or update attachments.

Note, you must set a X-Atlassian-Token: nocheck header on the request for this method, otherwise it will be blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.

The media type 'multipart/form-data' is defined in RFC 7578. Most client libraries have classes that make it easier to implement multipart posts, like the MultipartEntityBuilder Java class provided by Apache HTTP Components.

Note, according to RFC 7578, in the case where the form data is text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used in that part. In the case of this API endpoint, the comment body parameter should be sent with type=text/plain and charset=utf-8 values. This will force the charset to be UTF-8.

Example: This curl command attaches a file ('example.txt') to a container (id='123') with a comment and minorEdits=true.

1
2
3
4
5
6
7
8
curl -D- \
  -u admin:admin \
  -X POST \
  -H 'X-Atlassian-Token: nocheck' \
  -F 'file=@"example.txt"' \
  -F 'minorEdit="true"' \
  -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
  http://myhost/rest/api/content/123/child/attachment

Permissions required: Permission to update the content.

Connect app scope requiredWRITE

OAuth scopes required
write:confluence-file

Request

Path parameters
id Required

string

The ID of the content to add the attachment to.

Query parameters
status

string

The status of the content that the attachment is being added to.

Default: current

Valid values: current, draft

Body parameters
Content typeValue
multipart/form-data

object

Example

1
2
3
4
curl --request POST \
  --url 'https://api.atlassian.com/ex/confluence/:cloudId:/wiki/rest/api/content/{id}/child/attachment' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Accept: application/json'

Responses

Returned if the attachments were added to the content.

Content typeValue
application/json

ContentArray

Update attachment properties

PUT /wiki/rest/api/content/{id}/child/attachment/{attachmentId}

Updates the attachment properties, i.e. the non-binary data of an attachment like the filename, media-type, comment, and parent container.

Permissions required: Permission to update the content.

Connect app scope requiredWRITE

OAuth scopes required
write:confluence-file
,
write:confluence-props

Request

Path parameters
id Required

string

The ID of the content that the attachment is attached to.

attachmentId Required

string

The ID of the attachment to update.

Body parameters
version Required

object

The attachment version. Set this to the current version number of the attachment. Note, the version number only needs to be incremented when updating the actual attachment, not its properties.

id Required

string

The ID of the attachment to be updated.

type Required

string

Set this to attachment.

Valid values: attachment

title

string

The updated name of the attachment.

Max length: 255
metadata

object

container

object

The new content to attach the attachment to.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
curl --request PUT \
  --url 'https://api.atlassian.com/ex/confluence/:cloudId:/wiki/rest/api/content/{id}/child/attachment/{attachmentId}' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "version": {
    "number": 19
  },
  "id": "<string>",
  "type": "attachment",
  "title": "<string>",
  "metadata": {
    "mediaType": "<string>",
    "comment": "<string>"
  },
  "container": {
    "id": "<string>",
    "type": "<string>"
  }
}'

Responses

Returned if the attachment is updated.

Content typeValue
application/json

Content

Update attachment data

POST /wiki/rest/api/content/{id}/child/attachment/{attachmentId}/data

Updates the binary data of an attachment, given the attachment ID, and optionally the comment and the minor edit field.

This method is essentially the same as Create or update attachments, except that it matches the attachment ID rather than the name.

Note, you must set a X-Atlassian-Token: nocheck header on the request for this method, otherwise it will be blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.

The media type 'multipart/form-data' is defined in RFC 7578. Most client libraries have classes that make it easier to implement multipart posts, like the MultipartEntityBuilder Java class provided by Apache HTTP Components.

Note, according to RFC 7578, in the case where the form data is text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used in that part. In the case of this API endpoint, the comment body parameter should be sent with type=text/plain and charset=utf-8 values. This will force the charset to be UTF-8.

Example: This curl command updates an attachment (id='att456') that is attached to a piece of content (id='123') with a comment and minorEdits=true.

1
2
3
4
5
6
7
8
curl -D- \
  -u admin:admin \
  -X POST \
  -H 'X-Atlassian-Token: nocheck' \
  -F 'file=@"example.txt"' \
  -F 'minorEdit="true"' \
  -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
  http://myhost/rest/api/content/123/child/attachment/att456/data

Permissions required: Permission to update the content.

Connect app scope requiredWRITE

OAuth scopes required
write:confluence-file

Request

Path parameters
id Required

string

The ID of the content that the attachment is attached to.

attachmentId Required

string

The ID of the attachment to update.

Body parameters
Content typeValue
multipart/form-data

object

Example

1
2
3
4
curl --request POST \
  --url 'https://api.atlassian.com/ex/confluence/:cloudId:/wiki/rest/api/content/{id}/child/attachment/{attachmentId}/data' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Accept: application/json'

Responses

Returned if the attachment is updated.

Content typeValue
application/json

Content

Get URI to download attachment

GET /wiki/rest/api/content/{id}/child/attachment/{attachmentId}/download

Redirects the client to a URL that serves an attachment's binary data.

Connect app scope requiredREAD

OAuth scopes required
readonly:content.attachment:confluence

Request

Path parameters
id Required

string

The ID of the content that the attachment is attached to.

attachmentId Required

string

The ID of the attachment to download.

Query parameters
version

integer

The version of the attachment. If this parameter is absent, the redirect URI will download the latest version of the attachment.

Example

1
2
3
curl --request GET \
  --url 'https://api.atlassian.com/ex/confluence/:cloudId:/wiki/rest/api/content/{id}/child/attachment/{attachmentId}/download' \
  --header 'Authorization: Bearer <access_token>'

Responses

Returned if download URL is found.

A schema has not been defined for this response code.

Rate this page: