Back to AsanaUpload An Attachment
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.
Input
type: object
properties:
parameters:
type: object
properties:
opt_pretty:
type: boolean
description: >-
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.
opt_fields:
type: array
items:
type: string
description: >-
Defines fields to return.
Some requests return *compact* representations of objects in order to
conserve resources and complete the request more efficiently. Other
times requests return more information than you may need. This option
allows you to list the exact set of fields that the API should be sure
to return for the objects. The field names should be provided as
paths, described below.
The id of included objects will always be returned, regardless of the
field options.
title: Parameters
data:
type: object
properties:
resource_subtype:
description: >
The type of the attachment. Must be one of the given values. If not
specified, a file attachment of type `asana` will be assumed. Note
that if the value of `resource_subtype` is `external`, a `parent`,
`name`, and `url` must also be provided.
type: string
example: external
enum:
- asana
- dropbox
- gdrive
- onedrive
- box
- vimeo
- external
file:
description: |
Required for `asana` attachments.
type: string
format: binary
parent:
description: >
Required identifier of the parent task, project, or project_brief, as
a string.
type: string
url:
description: >
The URL of the external resource being attached. Required for
attachments of type `external`.
type: string
name:
description: >
The name of the external resource being attached. Required for
attachments of type `external`.
type: string
connect_to_app:
description: >
*Optional*. Only relevant for external attachments with a parent task.
A boolean indicating whether the current app should be connected with
the attachment for the purposes of showing an app components widget.
Requires the app to have been added to a project the parent task is
in.
type: boolean
title: Data
Output
type: object
properties:
data:
type: object
properties:
gid:
description: Globally unique identifier of the resource, as a string.
type: string
readOnly: true
example: '12345'
x-insert-after: false
resource_type:
description: The base type of this resource.
type: string
readOnly: true
example: task
x-insert-after: gid
name:
description: The name of the file.
type: string
readOnly: true
example: Screenshot.png
resource_subtype:
description: >-
The service hosting the attachment. Valid values are `asana`,
`dropbox`, `gdrive`, `onedrive`, `box`, `vimeo`, and `external`.
type: string
example: dropbox
created_at:
description: The time at which this resource was created.
type: string
format: date-time
readOnly: true
example: '2012-02-22T02:06:58.147Z'
download_url:
description: >-
The URL containing the content of the attachment.
*Note:* May be null if the attachment is hosted by
[Box](https://www.box.com/) and will be null if the attachment is a
Video Message hosted by [Vimeo](https://vimeo.com/). If present, this
URL may only be valid for two minutes 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.
type: string
format: uri
readOnly: true
nullable: true
example: https://s3.amazonaws.com/assets/123/Screenshot.png
permanent_url:
description: ''
type: string
format: uri
readOnly: true
nullable: true
example: https://s3.amazonaws.com/assets/123/Screenshot.png
host:
description: >-
The service hosting the attachment. Valid values are `asana`,
`dropbox`, `gdrive`, `box`, and `vimeo`.
type: string
readOnly: true
example: dropbox
parent:
type: object
properties:
gid:
description: Globally unique identifier of the resource, as a string.
type: string
readOnly: true
example: '12345'
x-insert-after: false
resource_type:
description: The base type of this resource.
type: string
readOnly: true
example: task
x-insert-after: gid
name:
description: The name of the task.
type: string
example: Bug Task
resource_subtype:
type: string
description: >-
The subtype of this resource. Different subtypes retain many of
the same fields and behavior, but may render differently in Asana
or represent resources with different semantic meaning.
The resource_subtype `milestone` represent a single moment in
time. This means tasks with this subtype cannot have a start_date.
enum:
- default_task
- milestone
- section
- approval
example: default_task
nullable: true
size:
description: >-
The size of the attachment in bytes. Only present when the
`resource_subtype` is `asana`.
type: integer
readOnly: true
example: 12345
view_url:
description: >-
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. May be null
if no view URL exists for the service.
type: string
format: uri
readOnly: true
nullable: true
example: https://www.dropbox.com/s/123/Screenshot.png
connected_to_app:
description: >-
Whether the attachment is connected to the app making the request for
the purposes of showing an app components widget. Only present when
the `resource_subtype` is `external` or `gdrive`.
type: boolean
readOnly: true