Search + K

Command Palette

Search for a command to run...

Sign In

Upload an attachment

POST /attachments
Copy endpoint
https://app.asana.com/api/1.0

Required scope: attachments:write

Upload an attachment.

This method uploads an attachment on an object and returns the compact record for the created attachment object. This is possible by either:

  • Providing the URL of the external resource being attached, or
  • Downloading the file content first and then uploading it as any other attachment. Note that it is not possible to attach files from third party services such as Dropbox, Box, Vimeo & Google Drive via the API

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.

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.

For file names that contain non-ASCII characters, the file name should be URL-encoded. For example, a file named résumé.pdf should be encoded as r%C3%A9sum%C3%A9.pdf and the filename parameter in the Content-Disposition header should be set to the encoded file name.

Below is an example of a cURL request with the Content-Disposition header:

export ASANA_PAT="<YOUR_ASANA_PERSONAL_ACCESS_TOKEN>"
export PARENT_ID="<PARENT_GID>"
export ENCODED_NAME="r%C3%A9sum%C3%A9.pdf"
curl --location 'https://app.asana.com/api/1.0/attachments' \
  --header 'Content-Type: multipart/form-data' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $ASANA_PAT" \
  --form "parent=$PARENT_ID" \
  --form "file=@/Users/exampleUser/Downloads/résumé.pdf;headers=\"Content-Disposition: form-data; name="file"; filename="$ENCODED_NAME.pdf"; filename*=UTF-8''$ENCODED_NAME.pdf\""

Parameters

query Query Parameters

Name Type
opt_fields

This endpoint returns a resource which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include.

("connected_to_app" | "created_at" | "download_url" | "host" | "name" | "parent" | "parent.created_by" | "parent.name" | "parent.resource_subtype" | "permanent_url" | "resource_subtype" | "size" | "view_url")[]
opt_pretty

Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging.

boolean

Request Body

multipart/form-data

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".

interface AttachmentRequest {
resource_subtype?: "asana" | "external";
file?: string;
parent: string;
url?: string;
name?: string;
connect_to_app?: boolean;
}

Responses

200 application/json

Successfully uploaded the attachment to the parent object.

{ data?: AttachmentResponse
type AttachmentResponse = AttachmentBase & {
created_at?: string;
download_url?: string | null;
permanent_url?: string | null;
host?: string;
parent?: { resource_subtype?: string | null; } & TaskCompact | null & TaskCompact;
size?: number;
view_url?: string | null;
connected_to_app?: boolean;
}
; }

Client Errors

400 application/json

This usually occurs because of a missing or malformed parameter. Check the documentation and the syntax of your request and try again.

interface ErrorResponse {
errors?: Error
interface Error {
message?: string;
help?: string;
phrase?: string;
}
[]
;
}
401 application/json

A valid authentication token was not provided with the request, so the API could not associate a user with the request.

interface ErrorResponse {
errors?: Error
interface Error {
message?: string;
help?: string;
phrase?: string;
}
[]
;
}
403 application/json

The authentication and request syntax was valid but the server is refusing to complete the request. This can happen if you try to read or write to objects or properties that the user does not have access to.

interface ErrorResponse {
errors?: Error
interface Error {
message?: string;
help?: string;
phrase?: string;
}
[]
;
}
404 application/json

Either the request method and path supplied do not specify a known action in the API, or the object specified by the request does not exist.

interface ErrorResponse {
errors?: Error
interface Error {
message?: string;
help?: string;
phrase?: string;
}
[]
;
}

Server Errors

500 application/json

There was a problem on Asana’s end. In the event of a server error the response body should contain an error phrase. These phrases can be used by Asana support to quickly look up the incident that caused the server error. Some errors are due to server load, and will not supply an error phrase.

interface ErrorResponse {
errors?: Error
interface Error {
message?: string;
help?: string;
phrase?: string;
}
[]
;
}