Attachments - Create

Uploads an attachment.

On accounts with higher attachment upload limits (>130MB), you will need to use chunked upload. To upload an attachment in multiple chunks, you first need to Start a Chunked Upload and then follow the example from the Upload Chunk section.

POST https://dev.azure.com/{organization}/{project}/_apis/wit/attachments?api-version=6.0
POST https://dev.azure.com/{organization}/{project}/_apis/wit/attachments?fileName={fileName}&uploadType={uploadType}&areaPath={areaPath}&api-version=6.0

URI Parameters

Name In Required Type Description
organization
path True

string

The name of the Azure DevOps organization.

project
path

string

Project ID or project name

api-version
query True

string

Version of the API to use. This should be set to '6.0' to use this version of the api.

areaPath
query

string

Target project Area Path

fileName
query

string

The name of the file

uploadType
query

string

Attachment upload type: Simple or Chunked

Request Body

Media Types: "application/octet-stream"

Name Type Description
body

string

Stream to upload

Responses

Name Type Description
200 OK

AttachmentReference

successful operation

Security

oauth2

Type: oauth2
Flow: accessCode
Authorization URL: https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL: https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer

Scopes

Name Description
vso.work_write Grants the ability to read, create, and update work items and queries, update board metadata, read area and iterations paths other work item tracking related metadata, execute queries, and to receive notifications about work item events via service hooks.

Examples

Start a Chunked Upload
Upload a binary file
Upload a text file

Start a Chunked Upload

Sample request

POST https://dev.azure.com/fabrikam/_apis/wit/attachments?fileName=largefile.zip&uploadType=chunked&api-version=6.0

Sample response

{
  "id": "de471719-27b2-40ab-ac40-4890f3eb1443",
  "url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/de471719-27b2-40ab-ac40-4890f3eb1443?fileName=test.txt"
}

Upload a binary file

Sample request

POST https://dev.azure.com/fabrikam/_apis/wit/attachments?fileName=imageAsFileAttachment.png&api-version=6.0

"[BINARY FILE CONTENT]"

Sample response

{
  "id": "a5cedde4-2dd5-4fcf-befe-fd0977dd3433",
  "url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/a5cedde4-2dd5-4fcf-befe-fd0977dd3433?fileName=imageAsFileAttachment.png"
}

Upload a text file

Sample request

POST https://dev.azure.com/fabrikam/_apis/wit/attachments?fileName=textAsFileAttachment.txt&api-version=6.0

"User text content to upload"

Sample response

{
  "id": "6b2266bf-a155-4582-a475-ca4da68193ef",
  "url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/6b2266bf-a155-4582-a475-ca4da68193ef?fileName=textAsFileAttachment.txt"
}

Definitions

AttachmentReference

Name Type Description
id

string

url

string