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

# Save Document

> Save something a run made

Save a page, screenshots, a markdown report or a file from this run as a document. It shows on the run card and opens in Avazal beside the chat, visible to the workspace. Pages render sandboxed with no network, so inline every script, style and image.

Any valid credential may call this.


## OpenAPI

````yaml /api-reference/openapi.json post /v1/documents.save
openapi: 3.1.0
info:
  title: Avazal API
  version: '1'
  description: >-
    Every operation is `POST /v1/<concept>.<verb>` with a JSON body, so agents
    and scripts call Avazal the same way. Slack, email, Linear, GitHub and
    calendars are sources behind Avazal's concepts: a task is a task whether it
    lives in a Slack List or Linear.


    Authenticate with an API key from Settings → API keys, sent as `x-api-key:
    avz_…` or `Authorization: Bearer avz_…`. A key acts as the member who
    created it, in one organization, and only with the scopes it was given.


    The MCP server at `/mcp` exposes the same operations as tools.


    Tagged JSON errors that include a `message` also include a machine-readable
    `code` matching `_tag`. Branch on `code`, not the human-readable message.


    Guides, scopes and MCP setup are at https://docs.avazal.com.
servers:
  - url: https://api.avazal.com
    description: Avazal
security:
  - apiKey: []
  - bearer: []
tags:
  - name: me
    x-group: Profile
  - name: accounts
    x-group: Accounts
  - name: settings
    x-group: Settings
  - name: search
    x-group: Search
  - name: inbox
    x-group: Inbox
  - name: conversations
    x-group: Conversations
  - name: messages
    x-group: Messages
  - name: reactions
    x-group: Reactions
  - name: emoji
    x-group: Emoji
  - name: files
    x-group: Files
  - name: people
    x-group: People
  - name: lists
    x-group: Lists
  - name: tasks
    x-group: Tasks
  - name: comments
    x-group: Comments
  - name: links
    x-group: Links
  - name: shares
    x-group: Shares
  - name: documents
    x-group: Documents
  - name: events
    x-group: Events
  - name: notifications
    x-group: Notifications
  - name: triggers
    x-group: Triggers
  - name: runs
    x-group: Runs
  - name: asks
    x-group: Asks
paths:
  /v1/documents.save:
    post:
      tags:
        - documents
      summary: Save something a run made
      description: >-
        Save a page, screenshots, a markdown report or a file from this run as a
        document. It shows on the run card and opens in Avazal beside the chat,
        visible to the workspace. Pages render sandboxed with no network, so
        inline every script, style and image.


        Any valid credential may call this.
      operationId: documents.save
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - kind
                - title
                - files
              properties:
                kind:
                  $ref: '#/components/schemas/ArtifactKind'
                title:
                  $ref: '#/components/schemas/NonEmptyTrimmedString'
                  description: a string at most 120 character(s) long
                  title: maxLength(120)
                  maxLength: 120
                files:
                  type: array
                  items:
                    type: object
                    required:
                      - name
                      - mimeType
                      - data
                    properties:
                      name:
                        $ref: '#/components/schemas/NonEmptyTrimmedString'
                        description: a string at most 200 character(s) long
                        title: maxLength(200)
                        maxLength: 200
                      mimeType:
                        type: string
                        description: a string at most 120 character(s) long
                        pattern: ^[a-z]+\/[a-z0-9.+-]+$
                        title: maxLength(120)
                        maxLength: 120
                      data:
                        type: string
                        description: The file's bytes, base64 encoded.
                        title: maxLength(6666668)
                        minLength: 1
                        maxLength: 6666668
                        pattern: ^[A-Za-z0-9+/]+={0,2}$
                    additionalProperties: false
                  description: an array of at most 12 item(s)
                  title: maxItems(12)
                  minItems: 1
                  maxItems: 12
              additionalProperties: false
        required: true
      responses:
        '200':
          description: >-
            A document, folder, Slack canvas or something a run saved. A read
            adds its markdown, your canvas draft and publish state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicDocument'
        '400':
          description: The request did not match the expected schema
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/HttpApiDecodeError'
                  - $ref: '#/components/schemas/InvalidId'
        '401':
          description: KeyRequired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyRequired'
        '403':
          description: AccessPending
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/AccessPending'
                  - $ref: '#/components/schemas/ScopeRequired'
                  - $ref: '#/components/schemas/OutsideRun'
                  - $ref: '#/components/schemas/ToolNotGranted'
        '409':
          description: AskFirst
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AskFirst'
        '422':
          description: Unsupported
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unsupported'
        '500':
          description: Unexpected server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerError'
        '503':
          description: Service unavailable
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/ServerError'
                  - type: object
                    required:
                      - error
                    properties:
                      error:
                        type: string
                    additionalProperties: false
      security:
        - apiKey: []
        - bearer: []
components:
  schemas:
    ArtifactKind:
      type: string
      enum:
        - page
        - images
        - report
        - file
      description: >-
        page: one self-contained text/html file, shown sandboxed with inline
        scripts and styles only. images: one to twelve PNG, JPEG, GIF or WebP
        screenshots. report: one text/markdown file. file: any one file, offered
        as a download.
    NonEmptyTrimmedString:
      type: string
      title: nonEmptyString
      pattern: ^\S[\s\S]*\S$|^\S$|^$
      minLength: 1
    PublicDocument:
      type: object
      required:
        - id
        - url
        - source
        - title
        - kind
        - parentId
        - revisionId
        - version
        - updatedAt
        - conversation
      properties:
        id:
          type: string
          description: The object's id. Every operation that takes it accepts it.
        url:
          anyOf:
            - type: string
            - type: 'null'
          description: A link that opens the object where it lives.
        source:
          $ref: '#/components/schemas/Source'
        title:
          type: string
        kind:
          $ref: '#/components/schemas/DocumentKind'
        parentId:
          anyOf:
            - $ref: '#/components/schemas/DocumentId'
            - type: 'null'
        revisionId:
          anyOf:
            - $ref: '#/components/schemas/DocumentRevisionId'
            - type: 'null'
        version:
          anyOf:
            - $ref: '#/components/schemas/Int'
            - type: 'null'
        updatedAt:
          anyOf:
            - type: string
            - type: 'null'
        conversation:
          anyOf:
            - $ref: '#/components/schemas/ConversationId'
            - type: 'null'
          description: The channel or DM a Slack canvas belongs to.
        run:
          allOf:
            - $ref: '#/components/schemas/AgentRunId'
          description: The run that saved it with documents_save.
        files:
          type: array
          items:
            type: object
            required:
              - name
              - mimeType
              - size
            properties:
              name:
                $ref: '#/components/schemas/NonEmptyTrimmedString'
                description: a string at most 200 character(s) long
                title: maxLength(200)
                maxLength: 200
              mimeType:
                type: string
                description: a string at most 120 character(s) long
                pattern: ^[a-z]+\/[a-z0-9.+-]+$
                title: maxLength(120)
                maxLength: 120
              size:
                $ref: '#/components/schemas/NonNegativeInt'
              width:
                $ref: '#/components/schemas/Int'
              height:
                $ref: '#/components/schemas/Int'
            additionalProperties: false
          description: The files a run saved, in order.
        markdown:
          type: string
          description: a string at most 1000000 character(s) long
          title: maxLength(1000000)
          maxLength: 1000000
        draft:
          anyOf:
            - type: object
              required:
                - revisionId
                - baseRevisionId
                - generation
                - markdown
              properties:
                revisionId:
                  $ref: '#/components/schemas/DocumentRevisionId'
                baseRevisionId:
                  $ref: '#/components/schemas/DocumentRevisionId'
                generation:
                  $ref: '#/components/schemas/Int'
                markdown:
                  type: string
                  description: a string at most 1000000 character(s) long
                  title: maxLength(1000000)
                  maxLength: 1000000
              additionalProperties: false
            - type: 'null'
        publish:
          anyOf:
            - $ref: '#/components/schemas/PublishState'
            - type: 'null'
        context:
          type: object
          required:
            - folders
            - workItems
          properties:
            folders:
              type: array
              items:
                $ref: '#/components/schemas/FileNode'
              description: The folders it sits in, outermost first.
            workItems:
              type: array
              items:
                type: object
                required:
                  - id
                  - workspaceId
                  - conversationId
                  - listId
                  - rowId
                  - title
                properties:
                  id:
                    type: string
                    description: >-
                      A Slack List item that Avazal tracks, its work.id. From
                      tasks_get.
                  workspaceId:
                    $ref: '#/components/schemas/ChatWorkspaceId'
                  conversationId:
                    $ref: '#/components/schemas/ConversationId'
                  listId:
                    $ref: '#/components/schemas/SlackFileId'
                  rowId:
                    $ref: '#/components/schemas/SlackListItemId'
                  title:
                    type: string
                additionalProperties: false
              description: Slack List items it is attached to. Read one with tasks_get.
          additionalProperties: false
      additionalProperties: false
      description: >-
        A document, folder, Slack canvas or something a run saved. A read adds
        its markdown, your canvas draft and publish state.
    HttpApiDecodeError:
      type: object
      required:
        - issues
        - message
        - _tag
        - code
      properties:
        issues:
          type: array
          items:
            $ref: '#/components/schemas/Issue'
        message:
          type: string
        _tag:
          type: string
          enum:
            - HttpApiDecodeError
        code:
          type: string
          enum:
            - HttpApiDecodeError
      additionalProperties: false
      description: The request did not match the expected schema
    InvalidId:
      type: object
      required:
        - id
        - message
        - _tag
        - code
      properties:
        id:
          type: string
          description: The id that was passed and could not be read.
        message:
          type: string
        _tag:
          type: string
          enum:
            - InvalidId
        code:
          type: string
          enum:
            - InvalidId
      additionalProperties: false
    KeyRequired:
      type: object
      required:
        - message
        - _tag
        - code
      properties:
        message:
          type: string
        _tag:
          type: string
          enum:
            - KeyRequired
        code:
          type: string
          enum:
            - KeyRequired
      additionalProperties: false
    AccessPending:
      type: object
      required:
        - _tag
      properties:
        message:
          type: string
        _tag:
          type: string
          enum:
            - AccessPending
        code:
          type: string
          enum:
            - AccessPending
      additionalProperties: false
    ScopeRequired:
      type: object
      required:
        - scope
        - message
        - _tag
        - code
      properties:
        scope:
          $ref: '#/components/schemas/AgentScope'
        message:
          type: string
        _tag:
          type: string
          enum:
            - ScopeRequired
        code:
          type: string
          enum:
            - ScopeRequired
      additionalProperties: false
    OutsideRun:
      type: object
      required:
        - message
        - _tag
        - code
      properties:
        message:
          type: string
        _tag:
          type: string
          enum:
            - OutsideRun
        code:
          type: string
          enum:
            - OutsideRun
      additionalProperties: false
    ToolNotGranted:
      type: object
      required:
        - tool
        - message
        - _tag
        - code
      properties:
        tool:
          type: string
        message:
          type: string
        _tag:
          type: string
          enum:
            - ToolNotGranted
        code:
          type: string
          enum:
            - ToolNotGranted
      additionalProperties: false
    AskFirst:
      type: object
      required:
        - action
        - message
        - _tag
        - code
      properties:
        action:
          type: object
          required:
            - tool
            - input
          properties:
            tool:
              $ref: '#/components/schemas/OperationName'
            input:
              type: object
              required: []
              properties: {}
              additionalProperties:
                $id: /schemas/unknown
                title: unknown
          additionalProperties: false
        message:
          type: string
        _tag:
          type: string
          enum:
            - AskFirst
        code:
          type: string
          enum:
            - AskFirst
      additionalProperties: false
    Unsupported:
      type: object
      required:
        - message
        - _tag
        - code
      properties:
        message:
          type: string
        _tag:
          type: string
          enum:
            - Unsupported
        code:
          type: string
          enum:
            - Unsupported
      additionalProperties: false
    ServerError:
      type: object
      required:
        - traceId
        - _tag
      properties:
        message:
          type: string
        traceId:
          type: string
          description: The request trace ID, also sent in the x-trace-id header.
        _tag:
          type: string
          enum:
            - ServerError
        code:
          type: string
          enum:
            - ServerError
      additionalProperties: false
    Source:
      type: string
      enum:
        - avazal
        - slack
        - gmail
        - google-calendar
        - google-drive
        - linear
        - github
        - contacts
      description: Where the object lives. Avazal is the source of its own objects.
    DocumentKind:
      type: string
      enum:
        - file
        - folder
        - page
        - images
        - report
      description: >-
        file is a markdown document or a file a run saved, folder holds
        documents, and page, images and report are what a run saved with
        documents_save.
    DocumentId:
      type: string
      title: '`doc_${string}`'
      description: Document or folder
      pattern: ^doc_[\s\S]*?$
    DocumentRevisionId:
      type: string
      title: '`drev_${string}`'
      description: Document revision
      pattern: ^drev_[\s\S]*?$
    Int:
      type: integer
      title: int
    ConversationId:
      type: string
      title: '`chcv_${string}`'
      description: Slack channel or DM
      pattern: ^chcv_[\s\S]*?$
    AgentRunId:
      type: string
      title: '`arun_${string}`'
      description: Agent run
      pattern: ^arun_[\s\S]*?$
    NonNegativeInt:
      type: integer
      title: int
      minimum: 0
    PublishState:
      type: object
      required:
        - unpublished
        - generation
        - canWrite
        - operation
      properties:
        unpublished:
          type: boolean
          description: Whether you have a draft that Slack does not have yet.
        generation:
          type: integer
          description: The draft's generation, 0 when there is no draft.
          title: int
        canWrite:
          type: boolean
        operation:
          anyOf:
            - type: object
              required:
                - id
                - documentId
                - state
                - nextStep
                - revisionId
                - updatedAt
              properties:
                id:
                  $ref: '#/components/schemas/DocumentOperationId'
                documentId:
                  $ref: '#/components/schemas/DocumentId'
                state:
                  type: string
                  enum:
                    - queued
                    - applying
                    - unknown
                    - conflict
                    - verified
                    - failed
                nextStep:
                  $ref: '#/components/schemas/Int'
                revisionId:
                  $ref: '#/components/schemas/DocumentRevisionId'
                replacedRevisionId:
                  anyOf:
                    - $ref: '#/components/schemas/DocumentRevisionId'
                    - type: 'null'
                updatedAt:
                  type: string
              additionalProperties: false
            - type: 'null'
          description: >-
            The publish asked about with operationId, or the one
            documents_publish just made. state is queued or applying while it
            runs, verified once Slack has it, conflict when the canvas changed
            in Slack first, failed or unknown otherwise.
      additionalProperties: false
      description: Where a Slack canvas's draft stands against Slack.
    FileNode:
      type: object
      required:
        - id
        - parentId
        - name
        - kind
        - revisionId
        - version
        - updatedAt
      properties:
        id:
          $ref: '#/components/schemas/DocumentId'
        parentId:
          anyOf:
            - $ref: '#/components/schemas/DocumentId'
            - type: 'null'
        name:
          type: string
        kind:
          type: string
          enum:
            - file
            - folder
        revisionId:
          anyOf:
            - $ref: '#/components/schemas/DocumentRevisionId'
            - type: 'null'
        version:
          $ref: '#/components/schemas/Int'
        updatedAt:
          type: string
        source:
          type: object
          required:
            - provider
            - conversationId
            - channel
          properties:
            provider:
              type: string
            conversationId:
              anyOf:
                - $ref: '#/components/schemas/ConversationId'
                - type: 'null'
            channel:
              anyOf:
                - type: object
                  required:
                    - name
                    - kind
                  properties:
                    name:
                      type: string
                    kind:
                      type: string
                      enum:
                        - channel
                        - private
                        - dm
                        - group
                        - self
                  additionalProperties: false
                - type: 'null'
          additionalProperties: false
      additionalProperties: false
      description: A document or folder in the file tree.
    ChatWorkspaceId:
      type: string
      title: '`chws_${string}`'
      description: Connected Slack workspace
      pattern: ^chws_[\s\S]*?$
    SlackFileId:
      type: string
      description: >-
        A Slack file id, such as F0123ABCD, for a file, List or canvas. From
        files_list, lists_list or documents_list.
      title: minLength(1)
      minLength: 1
    SlackListItemId:
      type: string
      description: A row in a Slack List. From tasks_list.
      title: minLength(1)
      minLength: 1
    Issue:
      type: object
      required:
        - _tag
        - path
        - message
      properties:
        _tag:
          type: string
          enum:
            - Pointer
            - Unexpected
            - Missing
            - Composite
            - Refinement
            - Transformation
            - Type
            - Forbidden
          description: The tag identifying the type of parse issue
        path:
          type: array
          items:
            $ref: '#/components/schemas/PropertyKey'
          description: The path to the property where the issue occurred
        message:
          type: string
          description: A descriptive message explaining the issue
      additionalProperties: false
      description: >-
        Represents an error encountered while parsing a value to match the
        schema
    AgentScope:
      type: string
      enum:
        - messages:read
        - messages:write
        - messages:send
        - tasks:read
        - tasks:write
        - documents:read
        - documents:write
        - events:read
        - events:write
        - people:read
        - people:write
        - automations:read
        - automations:write
        - settings:read
        - settings:write
        - search:read
      description: A concept and the action an agent may take on it.
    OperationName:
      type: string
      description: An Avazal tool name, e.g. messages_send.
      pattern: ^[a-z]+_[a-z_]+$
    DocumentOperationId:
      type: string
      title: '`dop_${string}`'
      description: Document edit
      pattern: ^dop_[\s\S]*?$
    PropertyKey:
      anyOf:
        - type: string
        - type: number
        - type: object
          required:
            - _tag
            - key
          properties:
            _tag:
              type: string
              enum:
                - symbol
            key:
              type: string
          additionalProperties: false
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: An Avazal API key (avz_…) created in Settings → API keys.
    bearer:
      type: http
      scheme: bearer
      description: 'The same API key sent as `Authorization: Bearer avz_…`.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.