---
title: "Create large file attachment upload session"
method: POST
path: "/me/messages/{messageId}/attachments/createUploadSession"
tags: ["me.message"]
---

# Create large file attachment upload session

`POST /me/messages/{messageId}/attachments/createUploadSession`

Create an upload session that allows an app to iteratively upload ranges of a file, so as to attach the file to the specified message. Use this approach to attach a file if the file size is between 3 MB and 150 MB. To attach a file smaller than 3 MB, do a POST on the attachments navigation property instead. As part of the response, this action returns an upload URL that you can use in subsequent sequential PUT queries.

## Request body

- AttachmentsCreateUploadSessionBody
  - `AttachmentItem` MicrosoftGraphAttachmentItem
    - `size` number, nullable — The length of the attachment in bytes. Required
    - `attachmentType` union — The type of attachment. The possible values are: file, item, reference. Required
      - 'file' | 'item' | 'reference'
      - object, nullable
    - `@odata.type` string
    - `contentId` string, nullable — The CID or Content-Id of the attachment for referencing for the in-line attachments using the <img src='cid:contentId'> tag in HTML messages. Optional
    - `name` string, nullable — The display name of the attachment. This can be a descriptive string and doesn't have to be the actual file name. Required
    - `isInline` boolean, nullable — true if the attachment is an inline attachment; otherwise, false. Optional
    - `contentType` string, nullable — The nature of the data in the attachment. Optional

## Response `2XX`

Success - returns an upload session

- union
  - MicrosoftGraphUploadSession
    - `expirationDateTime` string, date-time, nullable — The date and time in UTC that the upload session expires. The complete file must be uploaded before this expiration time is reached. Each fragment uploaded during the session extends the expiration time
    - `uploadUrl` string, nullable — The URL endpoint that accepts PUT requests for byte ranges of the file
    - `@odata.type` string
    - `nextExpectedRanges` string[] — A collection of byte ranges that the server is missing for the file. These ranges are zero indexed and of the format 'start-end' (e.g., '0-26' to indicate the first 27 bytes of the file). When uploading files as Outlook attachments, instead of a collection of ranges, this property always indicates a single value '{start}', the location in the file where the next upload should begin
  - UploadSessionCompletedResponse, nullable

## Other responses

- `4XX` — error
- `5XX` — error

---

[API](https://skmtc.net/ballerina-platform/apis/microsoft-graph-mail-api.md) · [All operations](https://skmtc.net/ballerina-platform/apis/microsoft-graph-mail-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/ballerina-platform/microsoft-graph-mail-api/versions/af62694b9f2d/schema)
