> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autype.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update document from Extended Markdown

> Replace the latest document content from Extended Markdown while preserving omitted metadata. This is the preferred persistent edit endpoint for AI agents. Internally Autype converts the markdown back to validated JSON and stores a normal document snapshot.



## OpenAPI

````yaml /api-reference/openapi.json patch /api/v1/dev/documents/{documentId}/markdown
openapi: 3.0.0
info:
  title: Autype Developer API
  description: >-
    Autype Developer API for programmatic document generation.


    ## Authentication

    Use an API key in `X-API-Key`. Autype's trusted MCP service may instead use
    a short-lived, Developer-API-audience OAuth token obtained through
    server-side token exchange. Raw MCP resource tokens, login JWTs, and
    third-party tokens are not accepted.


    ## Rate Limiting

    API requests are rate-limited to 100 requests per minute per API key.


    ## Automation Credits

    Developer API rendering and bulk operations consume automation credits from
    your organization. AI documents, assistant tasks, translations, and AI
    images use separate plan allowances.
  version: '1.0'
  contact: {}
servers:
  - url: https://api.autype.com
    description: Production
security: []
tags:
  - name: Temporary Images
    description: Upload and manage temporary images for document rendering
  - name: Render
    description: Render documents to PDF, DOCX, ODT, or page images
  - name: Bulk Render
    description: Bulk document generation with variable substitution
  - name: Documents
    description: Document variable inspection
  - name: Projects
    description: List organization projects
paths:
  /api/v1/dev/documents/{documentId}/markdown:
    patch:
      tags:
        - developer-api
      summary: Update document from Extended Markdown
      description: >-
        Replace the latest document content from Extended Markdown while
        preserving omitted metadata. This is the preferred persistent edit
        endpoint for AI agents. Internally Autype converts the markdown back to
        validated JSON and stores a normal document snapshot.
      operationId: DocumentsController_updateDocumentMarkdown_v1
      parameters:
        - name: documentId
          required: true
          in: path
          description: Document ID
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeveloperApiUpdateMarkdownDocumentDto'
      responses:
        '200':
          description: Updated document represented as Extended Markdown
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MarkdownDocumentResponseDto'
        '400':
          description: Invalid markdown or document schema
        '401':
          description: Invalid or missing API key
        '403':
          description: Document belongs to a private project or another organization
        '404':
          description: Document not found
      security:
        - mcp-oauth: []
        - api-key: []
components:
  schemas:
    DeveloperApiUpdateMarkdownDocumentDto:
      type: object
      properties:
        content:
          type: string
          description: >-
            Replacement Extended Markdown content. Omit only when updating
            metadata such as variables/defaults/stylePresetId.
          example: |-
            # Updated Report

            New content.
        document:
          description: Document settings to replace/merge with current settings.
          allOf:
            - $ref: '#/components/schemas/DeveloperApiMarkdownDocumentSettingsDto'
        stylePresetId:
          type: string
          nullable: true
          description: >-
            Set, replace, or clear the referenced workspace or built-in system
            style preset.
        variables:
          type: object
          description: Replacement variables object
        abbreviations:
          type: object
          description: Replacement abbreviation map
        defaults:
          type: object
          description: Defaults to merge with the current inline defaults
        citations:
          description: Replacement citations array in CSL-JSON format
          type: array
          items:
            type: string
        style:
          type: object
          description: Replacement style metadata
    MarkdownDocumentResponseDto:
      type: object
      properties:
        id:
          type: string
          description: Document ID
        title:
          type: string
          description: Document title
        projectId:
          type: string
          description: Project ID the document belongs to
        stylePresetId:
          type: string
          nullable: true
          description: Referenced workspace or built-in system style preset, if any
        content:
          type: string
          description: Extended Markdown representation of the latest snapshot
        document:
          type: object
          description: Document settings
        variables:
          type: object
          description: Variables for template substitution
        abbreviations:
          type: object
          description: Abbreviation map
        defaults:
          type: object
          description: Inline defaults
        citations:
          description: Citations array
          type: array
          items:
            type: string
        style:
          type: object
          description: Style metadata
        createdAt:
          format: date-time
          type: string
        updatedAt:
          format: date-time
          type: string
        revision:
          type: number
          description: Current content revision
      required:
        - id
        - title
        - projectId
        - content
        - document
        - createdAt
        - updatedAt
    DeveloperApiMarkdownDocumentSettingsDto:
      type: object
      properties:
        type:
          type: string
          description: Output format
          enum:
            - pdf
            - docx
            - odt
          example: pdf
        size:
          type: string
          description: Page size
          enum:
            - A4
            - A3
            - A5
            - Letter
            - Legal
          example: A4
        orientation:
          type: string
          description: Page orientation
          enum:
            - portrait
            - landscape
          example: portrait
        title:
          type: string
          description: Document title metadata
        author:
          type: string
          description: Document author metadata
        filename:
          type: string
          description: Output filename without extension
        marginTop:
          type: number
          description: Top margin in cm
        marginRight:
          type: number
          description: Right margin in cm
        marginBottom:
          type: number
          description: Bottom margin in cm
        marginLeft:
          type: number
          description: Left margin in cm
      required:
        - type
  securitySchemes:
    mcp-oauth:
      scheme: bearer
      bearerFormat: Autype Developer API OAuth token
      type: http
      description: >-
        Short-lived, Developer-API-audience token obtained by the trusted MCP
        service through token exchange (mcp_at_...). Raw MCP resource tokens are
        rejected.
    api-key:
      type: apiKey
      in: header
      name: X-API-Key
      description: API Key (starts with ak_...)

````