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

# Document events

> A live feed of a version or an alias of a document, as server-sent events. It sends the version whole first, then, as an alias moves, each new version as a patch from the one before.

Events, each with its version as the event ID where it has one:

- `version`: `{version, commit_id, sha256, document}`, the version whole. The first event, and again when there's no patch to send, such as when an alias moves back.
- `patch`: `{version, commit_id, sha256, patch}`, the alias moved on, as an RFC 6902 patch from the version before.
- `deleted`: the alias or the document is gone. The last event.
- `expired`: the preview credential expired; ask for another. The last event.



## OpenAPI

````yaml /api/openapi.json get /v1/documents/{document_id}/events
openapi: 3.1.0
info:
  title: Rendermate API
  version: v1
servers:
  - url: https://api.rendermate.com
security:
  - api_key: []
tags:
  - name: Account
  - name: Workspaces
  - name: Projects
  - name: Documents
  - name: Links
  - name: Exports
  - name: Assets
  - name: Generations
  - name: Persons
  - name: Help
paths:
  /v1/documents/{document_id}/events:
    get:
      tags:
        - Documents
      summary: Document events
      description: >-
        A live feed of a version or an alias of a document, as server-sent
        events. It sends the version whole first, then, as an alias moves, each
        new version as a patch from the one before.


        Events, each with its version as the event ID where it has one:


        - `version`: `{version, commit_id, sha256, document}`, the version
        whole. The first event, and again when there's no patch to send, such as
        when an alias moves back.

        - `patch`: `{version, commit_id, sha256, patch}`, the alias moved on, as
        an RFC 6902 patch from the version before.

        - `deleted`: the alias or the document is gone. The last event.

        - `expired`: the preview credential expired; ask for another. The last
        event.
      operationId: document_events
      parameters:
        - description: The document.
          in: path
          name: document_id
          required: true
          schema:
            type: string
        - description: >-
            A version to follow, which never changes. With an API key; a preview
            credential names its own.
          in: query
          name: version
          required: false
          schema:
            minimum: 0
            type: integer
        - description: >-
            An alias to follow as it moves; `latest` when neither is given. With
            an API key.
          in: query
          name: alias
          required: false
          schema:
            type: string
      responses:
        '200':
          content:
            text/event-stream:
              example: >+
                event: version

                id: 12

                data:
                {"version":12,"commit_id":"0193f2a4-c1d8-7b2e-9f3a-6c5d4e8b7a10","sha256":"9f2c4e1a7b3d5f8e0c6a2b4d8f1e3c5a7b9d0f2e4c6a8b1d3f5e7c9a0b2d4f6e","document":{}}

              schema:
                type: string
          description: The stream.
        '400':
          content:
            application/json:
              examples:
                invalid_request:
                  summary: invalid_request
                  value:
                    error:
                      code: invalid_request
                      doc_url: https://rendermate.com/docs/errors#invalid_request
                      message: give version or alias, not both
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: '- `invalid_request`: give version or alias, not both'
        '401':
          content:
            application/json:
              examples:
                unauthorized:
                  summary: unauthorized
                  value:
                    error:
                      code: unauthorized
                      doc_url: https://rendermate.com/docs/errors#unauthorized
                      message: 'provide a valid API key: Authorization: Bearer sk_…'
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            - `unauthorized`: provide a valid API key: Authorization: Bearer
            sk_…
        '403':
          content:
            application/json:
              examples:
                key_without_workspace:
                  summary: key_without_workspace
                  value:
                    error:
                      code: key_without_workspace
                      doc_url: https://rendermate.com/docs/errors#key_without_workspace
                      message: >-
                        this API key has no workspace: create a key in the
                        dashboard, under api keys in the workspace it should act
                        in
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            - `key_without_workspace`: this API key has no workspace: create a
            key in the dashboard, under api keys in the workspace it should act
            in
        '404':
          content:
            application/json:
              examples:
                alias.not_found:
                  summary: alias.not_found
                  value:
                    error:
                      code: alias.not_found
                      doc_url: https://rendermate.com/docs/errors#alias.not_found
                      message: the document has no alias approved
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
                version.not_found:
                  summary: version.not_found
                  value:
                    error:
                      code: version.not_found
                      doc_url: https://rendermate.com/docs/errors#version.not_found
                      message: 'no version 14: the newest is 12'
                      newest_version: 12
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: |-
            - `version.not_found`: no version 14: the newest is 12
            - `alias.not_found`: the document has no alias approved
        '500':
          content:
            application/json:
              examples:
                internal:
                  summary: internal
                  value:
                    error:
                      code: internal
                      doc_url: https://rendermate.com/docs/errors#internal
                      message: internal error
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: '- `internal`: internal error'
        '503':
          content:
            application/json:
              examples:
                preview.unavailable:
                  summary: preview.unavailable
                  value:
                    error:
                      code: preview.unavailable
                      doc_url: https://rendermate.com/docs/errors#unavailable
                      message: previews aren't available on this api yet
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: '- `preview.unavailable`: previews aren''t available on this api yet'
      security:
        - api_key: []
        - preview_token: []
components:
  schemas:
    Error:
      properties:
        error:
          properties:
            code:
              description: Stable, such as `asset.name_taken` or `not_available`.
              type: string
            doc_url:
              description: The code's entry on the Errors page.
              type: string
            message:
              description: What went wrong and what to do next.
              type: string
            request_id:
              description: >-
                The request's ID, also in its `x-request-id` header. Quote it
                when you contact support.
              type: string
          required:
            - code
            - message
            - doc_url
            - request_id
          type: object
      required:
        - error
      type: object
  securitySchemes:
    api_key:
      description: >-
        An API key from the dashboard, such as `sk_live_…`. It acts in its
        workspace.
      scheme: bearer
      type: http
    preview_token:
      description: >-
        A preview credential from create_preview, for a browser's `EventSource`,
        which can't send headers.
      in: query
      name: token
      type: apiKey

````

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