Microsoft Word Content API

Operations for uploading and downloading file content

Documentation

Specifications

SDKs

Code Examples

Schemas & Data

📊
JSONSchema
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-schema/graph-api-drive-item-schema.json
📊
JSONSchema
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-schema/graph-api-permission-schema.json
📊
JSONStructure
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-structure/graph-api-drive-item-structure.json
📊
JSONStructure
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-structure/graph-api-permission-structure.json
📊
JSONSchema
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-schema/javascript-api-paragraph-schema.json
📊
JSONSchema
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-schema/javascript-api-content-control-schema.json
📊
JSONSchema
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-schema/javascript-api-table-schema.json
📊
JSONSchema
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-schema/javascript-api-comment-schema.json
📊
JSONStructure
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-structure/javascript-api-paragraph-structure.json
📊
JSONStructure
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-structure/javascript-api-content-control-structure.json
📊
JSONStructure
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-structure/javascript-api-table-structure.json
📊
JSONStructure
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-structure/javascript-api-comment-structure.json
📊
JSONSchema
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-schema/open-xml-sdk-document-properties-schema.json
📊
JSONStructure
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-structure/open-xml-sdk-document-properties-structure.json

Other Resources

🔗
SDKs
https://www.nuget.org/packages/Microsoft.Graph
🔗
SDKs
https://pypi.org/project/msgraph-sdk/
🔗
SDKs
https://www.npmjs.com/package/@microsoft/microsoft-graph-client
🔗
SDKs
https://github.com/microsoftgraph/msgraph-sdk-java
🔗
SDKs
https://github.com/microsoftgraph/msgraph-sdk-go
🔗
SDKs
https://github.com/microsoftgraph/msgraph-sdk-php
🔗
JSONLD
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-ld/microsoft-word-graph-api-context.jsonld
🔗
Examples
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/examples/graph-api-drive-item-example.json
🔗
Examples
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/examples/graph-api-permission-example.json
🔗
Tutorials
https://learn.microsoft.com/en-us/office/dev/add-ins/tutorials/word-tutorial
🔗
JSONLD
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-ld/microsoft-word-javascript-api-context.jsonld
🔗
Examples
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/examples/javascript-api-paragraph-example.json
🔗
Examples
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/examples/javascript-api-content-control-example.json
🔗
Examples
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/examples/javascript-api-table-example.json
🔗
Examples
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/examples/javascript-api-comment-example.json
🔗
SDKs
https://www.nuget.org/packages/DocumentFormat.OpenXml
🔗
JSONLD
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/json-ld/microsoft-word-open-xml-sdk-context.jsonld
🔗
Examples
https://raw.githubusercontent.com/api-evangelist/microsoft-word/refs/heads/main/examples/open-xml-sdk-document-properties-example.json

OpenAPI Specification

microsoft-word-content-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Microsoft Graph Word Body Content API
  description: REST API for interacting with Word documents in Microsoft 365 and OneDrive via the Microsoft Graph unified endpoint. Provides operations for file management, content access, sharing, permissions, versioning, and document metadata for DriveItem resources.
  version: 1.0.0
  contact:
    name: Microsoft Graph Support
    url: https://developer.microsoft.com/graph/support
  license:
    name: Microsoft API License
    url: https://www.microsoft.com/en-us/legal/terms-of-use
  x-generated-from: documentation
  x-last-validated: '2026-04-18'
servers:
- url: https://graph.microsoft.com/v1.0
  description: Microsoft Graph v1.0 production endpoint
security:
- oauth2: []
tags:
- name: Content
  description: Operations for uploading and downloading file content
paths:
  /me/drive/items/{item-id}/content:
    get:
      operationId: downloadContent
      summary: Microsoft Word Download Content
      description: Download the contents of the primary stream (file) of a DriveItem.
      tags:
      - Content
      parameters:
      - $ref: '#/components/parameters/itemId'
      responses:
        '200':
          description: Successfully retrieved the file content.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '302':
          description: Redirect to pre-authenticated download URL.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    put:
      operationId: uploadContent
      summary: Microsoft Word Upload Content
      description: Upload the contents of a file. Supports files up to 4MB in size.
      tags:
      - Content
      parameters:
      - $ref: '#/components/parameters/itemId'
      requestBody:
        required: true
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '200':
          description: Successfully uploaded the file.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DriveItem'
        '201':
          description: Successfully created a new file.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DriveItem'
        '401':
          $ref: '#/components/responses/Unauthorized'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /me/drive/items/{item-id}/createUploadSession:
    post:
      operationId: createUploadSession
      summary: Microsoft Word Create Upload Session
      description: Create an upload session to allow uploading files up to the maximum file size in resumable chunks.
      tags:
      - Content
      parameters:
      - $ref: '#/components/parameters/itemId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUploadSessionRequest'
      responses:
        '200':
          description: Successfully created upload session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadSession'
        '401':
          $ref: '#/components/responses/Unauthorized'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  schemas:
    ErrorResponse:
      type: object
      description: Error response from the API.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code.
              example: itemNotFound
            message:
              type: string
              description: Human-readable error message.
              example: The resource could not be found.
            innerError:
              type: object
              properties:
                request-id:
                  type: string
                  description: Request correlation ID.
                  example: b0c6a5b0-4c0a-4c8e-9b0a-1234567890ab
                date:
                  type: string
                  format: date-time
                  description: Timestamp of the error.
                  example: '2025-03-21T20:01:37Z'
    FolderFacet:
      type: object
      description: Folder metadata facet for a driveItem.
      properties:
        childCount:
          type: integer
          description: Number of children in the folder.
          example: 120
    SharedFacet:
      type: object
      description: Indicates the item has been shared with others.
      properties:
        owner:
          $ref: '#/components/schemas/IdentitySet'
        scope:
          type: string
          description: Scope of sharing.
          example: users
    DriveItem:
      type: object
      description: Represents a file, folder, or other item stored in a drive.
      properties:
        id:
          type: string
          description: The unique identifier of the item within the drive.
          example: 01NKDM7HMOJTVYMDOSXFDK2QJDXCDI3WUK
        name:
          type: string
          description: The name of the item (filename and extension).
          example: quarterly-report.docx
        description:
          type: string
          description: A user-visible description of the item.
          example: Q4 2025 financial report
        size:
          type: integer
          format: int64
          description: Size of the item in bytes.
          example: 157286400
        webUrl:
          type: string
          format: uri
          description: URL that displays the resource in the browser.
          example: https://contoso-my.sharepoint.com/personal/user/Documents/report.docx
        webDavUrl:
          type: string
          format: uri
          description: WebDAV compatible URL for the item.
          example: https://contoso-my.sharepoint.com/personal/user/Documents/report.docx
        createdDateTime:
          type: string
          format: date-time
          description: Date and time of item creation.
          example: '2025-03-21T20:01:37Z'
        lastModifiedDateTime:
          type: string
          format: date-time
          description: Date and time the item was last modified.
          example: '2025-06-15T14:30:00Z'
        eTag:
          type: string
          description: ETag for the entire item (metadata + content).
          example: '"{86EB4C8E-D20D-46B9-AD41-23B8868DDA8A},1"'
        cTag:
          type: string
          description: ETag for the content of the item.
          example: '"{86EB4C8E-D20D-46B9-AD41-23B8868DDA8A},0"'
        createdBy:
          $ref: '#/components/schemas/IdentitySet'
        lastModifiedBy:
          $ref: '#/components/schemas/IdentitySet'
        parentReference:
          $ref: '#/components/schemas/ItemReference'
        file:
          $ref: '#/components/schemas/FileFacet'
        folder:
          $ref: '#/components/schemas/FolderFacet'
        shared:
          $ref: '#/components/schemas/SharedFacet'
    ItemReference:
      type: object
      description: Reference to a drive item's parent.
      properties:
        driveId:
          type: string
          description: Identifier of the drive containing the item.
          example: b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd
        id:
          type: string
          description: Identifier of the item in the drive.
          example: 01NKDM7HMOJTVYMDOSXFDK2QJDXCDI3WUK
        path:
          type: string
          description: Path from the root to the item.
          example: /drive/root:/Documents
    FileFacet:
      type: object
      description: File metadata facet for a driveItem.
      properties:
        mimeType:
          type: string
          description: MIME type of the file.
          example: application/vnd.openxmlformats-officedocument.wordprocessingml.document
        hashes:
          type: object
          properties:
            sha1Hash:
              type: string
              description: SHA1 hash of the file content.
              example: aabbccdd1122334455
            quickXorHash:
              type: string
              description: QuickXor hash of the file content.
              example: aabbccdd1122334455
    IdentitySet:
      type: object
      description: Keyed collection of identity resources.
      properties:
        user:
          type: object
          properties:
            id:
              type: string
              description: Unique identifier for the user.
              example: efee1b77-fb3b-4f65-99d6-274c11914d12
            displayName:
              type: string
              description: Display name of the user.
              example: Jane Smith
    UploadSession:
      type: object
      description: Information about a resumable upload session.
      properties:
        uploadUrl:
          type: string
          format: uri
          description: URL to use for uploading file chunks.
          example: https://sn3302.up.1drv.com/up/abc123
        expirationDateTime:
          type: string
          format: date-time
          description: When the upload session expires.
          example: '2025-03-22T20:01:37Z'
        nextExpectedRanges:
          type: array
          items:
            type: string
          description: Byte ranges the server expects next.
          example:
          - 0-
    CreateUploadSessionRequest:
      type: object
      description: Request body for creating a resumable upload session.
      properties:
        item:
          type: object
          properties:
            '@microsoft.graph.conflictBehavior':
              type: string
              description: Conflict resolution behavior.
              example: rename
            name:
              type: string
              description: Name of the file being uploaded.
              example: large-document.docx
  responses:
    NotFound:
      description: The requested resource was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Authentication required or token expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  parameters:
    itemId:
      name: item-id
      in: path
      required: true
      description: The unique identifier of the drive item.
      schema:
        type: string
      example: 01NKDM7HMOJTVYMDOSXFDK2QJDXCDI3WUK
  securitySchemes:
    oauth2:
      type: oauth2
      description: OAuth 2.0 authorization code flow with Microsoft Identity Platform.
      flows:
        authorizationCode:
          authorizationUrl: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
          tokenUrl: https://login.microsoftonline.com/common/oauth2/v2.0/token
          scopes:
            Files.Read: Read user files
            Files.ReadWrite: Read and write user files
            Files.Read.All: Read all files the user can access
            Files.ReadWrite.All: Read and write all files the user can access