Skip to content
atlassian-dc-mcp
Esc
↑↓navigate↵open⌘Jpreview

Create attachments

Add one or more attachments to a Confluence Content entity, with optional comments.

Comments are optional, but if included there must be as many comments as there are files, and the comments must be in the same order as the files.

This resource expects a multipart post. The media-type multipart/form-data is defined in RFC 1867. Most client libraries have classes that make dealing with multipart posts simple. For instance, in Java the Apache HTTP Components library provides a MultiPartEntity that makes it simple to submit a multipart POST.

In order to protect against XSRF attacks, because this method accepts multipart/form-data, it has XSRF protection on it. This means you must submit a header of X-Atlassian-Token: nocheck with the request, otherwise it will be blocked.

The name of the multipart/form-data parameter that contains attachments must be ‘file’.

POST/rest/api/content/{id}/child/attachment
Path parameters
idstringrequired

The id of the content the attachment is on.

Query parameters
expandstring

(optional) a comma separated list of properties to expand on the Attachments returned. Optional.

allowDuplicatedstring

(optional) allows to upload an attachment with an existing filename.

statusstring

a string containing the status of the attachments content container, supports current or draft, defaults to current

Request body
multipart/form-data

The attachments to be added. The name of the multipart/form-data parameter that contains attachments must be 'file'.

filestring

The name of the multipart/form-data parameter that contains attachments must be "file".

commentstring

(optional) a list of "comments" matching the list of attachment data.\nIf supplied, the size of this list must match the size of the fileParts list.

minorEditboolean

(optional) form parameter indicating whether the attachments should be "minorEdits".If "minorEdits" is set to true, no notification email will be generated for that attachment.

hiddenboolean

(optional) form parameter indicating whether the attachments should be "hidden".If "hidden" is set to true, no notification email or activity stream will be generated for that attachment.

Responses
200

returns a JSON representation of the attachments added.

idstring
typestring
statusstring
titlestring
linksobject
spaceSpace
Show properties
idinteger<int64>
keystring
namestring
statusstring
iconReferenceIcon
Show properties
expandedboolean
idPropertiesobject
descriptionobject
homepageReferenceContent
Show properties
expandedboolean
idPropertiesobject
linksobject
typestring
metadataobject
retentionPolicyReferenceSpaceRetentionPolicy
Show properties
expandedboolean
idPropertiesobject
historyHistory
Show properties
previousVersionReferenceVersion
Show properties
expandedboolean
idPropertiesobject
nextVersionReferenceVersion
Show properties
expandedboolean
idPropertiesobject
lastUpdatedReferenceVersion
Show properties
expandedboolean
idPropertiesobject
latestboolean
createdByPerson
Show properties
profilePictureIcon
Show properties
pathstring
widthinteger<int32>
heightinteger<int32>
isDefaultboolean
displayNamestring
typestring
createdDatestring<date-time>
contributorsReferenceContributors
Show properties
expandedboolean
idPropertiesobject
lastUpdatedRefReferenceVersion
Show properties
expandedboolean
idPropertiesobject
nextVersionRefReferenceVersion
Show properties
expandedboolean
idPropertiesobject
previousVersionRefReferenceVersion
Show properties
expandedboolean
idPropertiesobject
contentParentRefReferenceContent
Show properties
expandedboolean
idPropertiesobject
versionVersion
Show properties
byPerson
Show properties
profilePictureIcon
displayNamestring
typestring
whenstring<date-time>
messagestring
numberinteger<int32>
minorEditboolean
hiddenboolean
syncRevstring
contentReferenceContent
Show properties
expandedboolean
idPropertiesobject
contentRefReferenceContent
Show properties
expandedboolean
idPropertiesobject
ancestorsContent[]
Show properties
Array of Content
Circular reference to Content.
positioninteger<int32>
operationsOperationCheckResult[]
Show properties
Array of OperationCheckResult
operationstring
targetTypestring
childrenobject
descendantsobject
containerContainer
bodyobject
metadataobject
extensionsobject
restrictionsobject
historyRefReferenceHistory
Show properties
expandedboolean
idPropertiesobject
spaceRefReferenceSpace
Show properties
expandedboolean
idPropertiesobject
containerRefReferenceContainer
Show properties
expandedboolean
idPropertiesobject
versionRefReferenceVersion
Show properties
expandedboolean
idPropertiesobject
403

Returned if attachments is disabled or if you don't have permission to add attachments to this content.

statusCodeinteger<int32>
dataValidationResult
Show properties
authorizedboolean
validboolean
errorsobject
successfulboolean
allowedInReadOnlyModeboolean
messagestring
reasonstring
404

Returned if the requested content is not found, the user does not have permission to view it, or if the attachments exceeds the maximum configured attachment size.

statusCodeinteger<int32>
dataValidationResult
Show properties
authorizedboolean
validboolean
errorsobject
successfulboolean
allowedInReadOnlyModeboolean
messagestring
reasonstring
Try it
Server
Parameters
Bodymultipart/form-data
Request
curl -X POST 'http://example.com:7990/confluence/rest/api/content/string/child/attachment' \
  -H 'Accept: application/json' \
  --form-string 'file=string' \
  --form-string 'comment=string' \
  --form-string 'minorEdit=true' \
  --form-string 'hidden=true'
Response
{
  "id": "123456",
  "type": "page",
  "status": "current",
  "title": "My Page",
  "links": {},
  "space": {
    "id": 123456,
    "key": "TEST",
    "name": "Test Space",
    "status": "current",
    "icon": {
      "expanded": true,
      "idProperties": {}
    },
    "description": {},
    "homepage": {
      "expanded": true,
      "idProperties": {}
    },
    "links": {},
    "type": "global",
    "metadata": {
      "labels": [
        "label1",
        "label2"
      ]
    },
    "retentionPolicy": {
      "expanded": true,
      "idProperties": {}
    }
  },
  "history": {
    "previousVersion": {
      "expanded": true,
      "idProperties": {}
    },
    "nextVersion": {
      "expanded": true,
      "idProperties": {}
    },
    "lastUpdated": {
      "expanded": true,
      "idProperties": {}
    },
    "latest": true,
    "createdBy": {
      "profilePicture": {
        "path": "http://www.example.com/path/to/image.png",
        "width": 16,
        "height": 16,
        "isDefault": true
      },
      "displayName": "Joe Smith",
      "type": "string"
    },
    "createdDate": "2020-01-01T00:00:00Z",
    "contributors": {
      "expanded": true,
      "idProperties": {}
    },
    "lastUpdatedRef": {
      "expanded": true,
      "idProperties": {}
    },
    "nextVersionRef": {
      "expanded": true,
      "idProperties": {}
    },
    "previousVersionRef": {
      "expanded": true,
      "idProperties": {}
    },
    "contentParentRef": {
      "expanded": true,
      "idProperties": {}
    }
  },
  "version": {
    "by": {
      "profilePicture": {
        "path": "http://www.example.com/path/to/image.png",
        "width": 16,
        "height": 16,
        "isDefault": true
      },
      "displayName": "Joe Smith",
      "type": "string"
    },
    "when": "2020-01-01T00:00:00Z",
    "message": "A message",
    "number": 1,
    "minorEdit": true,
    "hidden": true,
    "syncRev": "123456",
    "content": {
      "expanded": true,
      "idProperties": {}
    },
    "contentRef": {
      "expanded": true,
      "idProperties": {}
    }
  },
  "ancestors": [
    {}
  ],
  "position": 1,
  "operations": [
    {
      "operation": "read",
      "targetType": "page"
    }
  ],
  "children": {},
  "descendants": {},
  "container": null,
  "body": {},
  "metadata": {
    "key": "value"
  },
  "extensions": {
    "key": "value"
  },
  "restrictions": {
    "use": {
      "operation": "use",
      "restrictions": []
    }
  },
  "historyRef": {
    "expanded": true,
    "idProperties": {}
  },
  "spaceRef": {
    "expanded": true,
    "idProperties": {}
  },
  "containerRef": {
    "expanded": true,
    "idProperties": {}
  },
  "versionRef": {
    "expanded": true,
    "idProperties": {}
  }
}

Was this page helpful?