openapi: 3.0.3 info: title: Microsoft Graph Word Body 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: Body description: Operations on the document body content paths: /documents/{document-id}/body: get: operationId: getBody summary: Microsoft Word Get Body description: Get the body object of the document containing the main content. tags: - Body parameters: - $ref: '#/components/parameters/documentId' responses: '200': description: Successfully retrieved document body. content: application/json: schema: $ref: '#/components/schemas/Body' '404': $ref: '#/components/responses/NotFound' x-microcks-operation: delay: 0 dispatcher: FALLBACK /documents/{document-id}/body/insertText: post: operationId: insertText summary: Microsoft Word Insert Text description: Insert text at the specified location in the document body. tags: - Body parameters: - $ref: '#/components/parameters/documentId' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/InsertTextRequest' responses: '200': description: Successfully inserted text. content: application/json: schema: $ref: '#/components/schemas/Range' '400': $ref: '#/components/responses/BadRequest' x-microcks-operation: delay: 0 dispatcher: FALLBACK /documents/{document-id}/body/insertHtml: post: operationId: insertHtml summary: Microsoft Word Insert HTML description: Insert HTML content at the specified location in the document body. tags: - Body parameters: - $ref: '#/components/parameters/documentId' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/InsertHtmlRequest' responses: '200': description: Successfully inserted HTML. content: application/json: schema: $ref: '#/components/schemas/Range' '400': $ref: '#/components/responses/BadRequest' x-microcks-operation: delay: 0 dispatcher: FALLBACK /documents/{document-id}/body/search: post: operationId: searchDocument summary: Microsoft Word Search Document description: Search the document body for text matching the specified criteria. tags: - Body parameters: - $ref: '#/components/parameters/documentId' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SearchRequest' responses: '200': description: Successfully completed search. content: application/json: schema: $ref: '#/components/schemas/RangeCollection' '400': $ref: '#/components/responses/BadRequest' 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: InvalidArgument message: type: string description: Human-readable error message. example: The argument is invalid or missing. Range: type: object description: Represents a contiguous area in a document. properties: text: type: string description: Text content of the range. example: inserted text content style: type: string description: Style applied to the range. example: Normal isEmpty: type: boolean description: Whether the range is empty. example: false InsertTextRequest: type: object description: Request to insert text into the document. required: - text - location properties: text: type: string description: The text to insert. example: Hello, World! location: type: string description: Location to insert text (Start, End, Before, After, Replace). example: End RangeCollection: type: object description: Collection of ranges. properties: value: type: array items: $ref: '#/components/schemas/Range' Body: type: object description: Represents the body of a document or section. properties: text: type: string description: Plain text content of the body. example: This is the document body text. type: type: string description: Type of the body (MainDoc, Section, Header, Footer, TableCell). example: MainDoc style: type: string description: Style name applied to the body. example: Normal SearchRequest: type: object description: Request to search document content. required: - searchText properties: searchText: type: string description: Text to search for in the document. example: quarterly report ignorePunct: type: boolean description: Whether to ignore punctuation. example: true ignoreSpace: type: boolean description: Whether to ignore whitespace. example: true matchCase: type: boolean description: Whether to perform case-sensitive search. example: false matchWholeWord: type: boolean description: Whether to match whole words only. example: false matchWildcards: type: boolean description: Whether to use wildcard matching. example: false InsertHtmlRequest: type: object description: Request to insert HTML content into the document. required: - html - location properties: html: type: string description: The HTML content to insert. example:
Body paragraph
location: type: string description: Location to insert HTML (Start, End, Before, After, Replace). example: End responses: NotFound: description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' BadRequest: description: Invalid request parameters. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' parameters: documentId: name: document-id in: path required: true description: The unique identifier of the Word document. schema: type: string example: doc-a1b2c3d4 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