Add attachment

Important: APIs under the /beta version in Microsoft Graph are in preview and are subject to change. Use of these APIs in production applications is not supported.

Use this API to create a new Attachment.

An attachment can be one of the following types:

All these types of attachment resources are derived from the attachment resource.

Permissions

One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.

Permission type Permissions (from least to most privileged)
Delegated (work or school account) Mail.ReadWrite
Delegated (personal Microsoft account) Mail.ReadWrite
Application Mail.ReadWrite

HTTP request

POST /me/messages/{id}/attachments
POST /users/{id|userPrincipalName}/messages/{id}/attachments

Request headers

Name Type Description
Authorization string Bearer {token}. Required.
Content-Type string Nature of the data in the body of an entity. Required.

Request body

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

Response

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

Example (file attachment)

Request

Here is an example of the request.

POST https://graph.microsoft.com/beta/me/messages/{id}/attachments
Content-type: application/json

{
  "@odata.type": "#Microsoft.OutlookServices.FileAttachment",
  "name": "name-value",
  "contentType": "contentType-value",
  "isInline": false,
  "contentLocation": "contentLocation-value",
  "contentBytes": "contentBytes-value"
}
Response

Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.

HTTP 201 Created

Example (item attachment)

Request
POST https://graph.microsoft.com/v1.0/me/events/{id}/attachments
Content-type: application/json

{
  "@odata.type": "#Microsoft.OutlookServices.ItemAttachment",
  "name": "name-value",
  "item": "message or event entity"
}
Response

Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.

HTTP 201 Created