Attachments

An attachment object represents any file attached to a task in Asana, whether it’s an uploaded file or one associated via a third-party service such as Dropbox or Google Drive.

Attachments have the following fields:

Field Description
id 1234 Read-only. Globally unique ID of the attachment.
created_at '2012-02-22T02:06:58.147Z' Read-only. The time at which this attachment was uploaded.
download_url 'https://www.dropbox.com/s/123/Screenshot.png?dl=1' null Read-only. The URL containing the content of the attachment.

Note: May be null if the attachment is hosted by box. If present, this URL may only be valid for 1 hour from the time of retrieval. You should avoid persisting this URL somewhere and just refresh it on demand to ensure you do not keep stale URLs.
host 'dropbox' Read-only. The service hosting the attachment. Valid values are asana, dropbox, gdrive and box.
name 'Screenshot.png' Read-only. The name of the file.
parent { id: 1234, name: 'Bug task' } Read-only. The task this attachment is attached to.
view_url 'https://www.dropbox.com/s/123/Screenshot.png' null Read-only. The URL where the attachment can be viewed, which may be friendlier to users in a browser than just directing them to a raw file.

GET SINGLE ATTACHMENT

GET    /attachments/attachment-id

Returns the full record for a single attachment.

Parameter Description
attachment 12357 Required: Globally unique identifier for the attachment.
# Request
curl -H "Authorization: Bearer <personal_access_token>" \
https://app.asana.com/api/1.0/attachments/5678

# Response
HTTP/1.1 200
{
  "data": {
    "name": "Screenshot.png",
    "parent": {
      "id": 1337,
      "name": "My Task"
    },
    "view_url": "https://www.dropbox.com/s/1234567890abcdef/Screenshot.png",
    "created_at": "",
    "download_url": "https://www.dropbox.com/s/1234567890abcdef/Screenshot.png?dl=1",
    "host": "dropbox",
    "id": 5678
  }
}

GET ALL ATTACHMENTS

GET    /tasks/task-id/attachments

Returns the compact records for all attachments on the task.

Parameter Description
task 124816 Required: Globally unique identifier for the task.
# Request
curl -H "Authorization: Bearer <personal_access_token>" \
https://app.asana.com/api/1.0/tasks/1234/attachments

# Response
HTTP/1.1 200
{
  "data": [
    {
      "id": 5678,
      "name": "Background.png"
    },
    {
      "id": 9012,
      "name": "New Design Draft.pdf"
    },
    "~..."
  ]
}

UPLOAD AN ATTACHMENT

POST    /tasks/task-id/attachments

This method uploads an attachment to a task and returns the compact record for the created attachment object. It is not possible to attach files from third party services such as Dropbox, Box & Google Drive via the API. You must download the file content first and then upload it as any other attachment.

The 100MB size limit on attachments in Asana is enforced on this endpoint.

This endpoint expects a multipart/form-data encoded request containing the full contents of the file to be uploaded.

Below is an example of what a well formed multipart/form-data encoded request might look like.

Authorization: Basic <BASE64_ENCODED_API_KEY>
Content-Type: multipart/form-data; boundary=<UNIQUE_BOUNDARY>
User-Agent: Java/1.7.0_76
Host: localhost
Accept: */*
Connection: keep-alive
Content-Length: 141

--<UNIQUE_BOUNDARY>
Content-Disposition: form-data; name="file"; filename="example.txt"
Content-Type: text/plain

<RAW_FILE_DATA>

--<UNIQUE_BOUNDARY>--

Requests made should follow the HTTP/1.1 specification that line terminators are of the form CRLF or \r\n outlined here in order for the server to reliably and properly handle the request.

Parameter Description
task 124816 Required: Globally unique identifier for the task.
file file.txt Required: The file you want to upload.

Note: When using curl:

Be sure to add an ‘@’ before the file path, and use the —form option instead of the -d option.

When uploading PDFs with curl, force the content-type to be pdf by appending the content type to the file path: —form “file=@file.pdf;type=application/pdf”.
# Request
curl -H "Authorization: Bearer <personal_access_token>" \
https://app.asana.com/api/1.0/tasks/1337/attachments \
--form "file=@file.txt"

# Response
HTTP/1.1 200
{
  "data": {
    "id": 5678,
    "name": "file.txt"
  }
}