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

# Create large file attachment upload session from user

`POST /users/{userIdentifier}/messages/{messageId}/attachments/createUploadSession`

Create an upload session that allows an app to iteratively upload ranges of a file to attach to a message in a specific user's mailbox.

## 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/revisions/af62694b9f2d/schema)
