Create taskFileAttachment

Namespace: microsoft.graph


APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.

Add a new taskFileAttachment object to a todoTask.

This operation limits the size of the attachment you can add to under 3 MB. If the size of the file attachments is more than 3 MB, create an upload session to upload the attachments.

This API is available in the following national cloud deployments.

Global service US Government L4 US Government L5 (DOD) China operated by 21Vianet


Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

Permission type Least privileged permissions Higher privileged permissions
Delegated (work or school account) Tasks.ReadWrite Not available.
Delegated (personal Microsoft account) Tasks.ReadWrite Not available.
Application Not supported. Not supported.

HTTP request

POST /me/todo/lists/{id}/tasks/{id}/attachments
POST /users/{id}/todo/lists/{id}/tasks/{id}/attachments

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.
Content-Type application/json. Required.

Request body

In the request body, supply a JSON representation of the taskFileAttachment object.

When you create a file attachment, include "@odata.type": "#microsoft.graph.taskFileAttachment" and the required properties.

Property Type Description
contentBytes Binary The base64-encoded contents of the file. Required.
contentType String The content type of the attachment.
name String The name of the text displayed under the icon that represents the embedded attachment. This does not need to be the actual file name. Required.
size Int32 The size in bytes of the attachment.


If successful, this method returns a 201 Created response code and a taskFileAttachment object in the response body.



The following is an example of a request.

Content-Type: application/json

  "@odata.type": "#microsoft.graph.taskFileAttachment",
  "name": "smile",
  "contentBytes": "a0b1c76de9f7=",
  "contentType": "image/gif"


The following example shows the response.

Note: The response object shown here might be shortened for readability.

HTTP/1.1 201 Created
Content-Type: application/json

  "@odata.type": "#microsoft.graph.taskFileAttachment",
  "id": "AAMkADNkN2R",
  "lastModifiedDateTime": "2017-01-26T08:48:28Z",
  "name": "smile",
  "contentType": "image/gif",
  "size": 1008