Obsidian Active File API

The Active File API from Obsidian — 1 operation(s) for active file.

Operations 5

DELETE /active/ Deletes the currently-active file in Obsidian #
GET /active/ Return the content of the active file open in Obsidian #
PATCH /active/ Partially update content in the currently open note #
POST /active/ Append content to the active file open in Obsidian #
PUT /active/ Update the content of the active file open in Obsidian #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/obsidian-active-file-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

obsidian-active-file-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  description: You can use this interface for trying out your Local REST API in Obsidian.
  title: Local REST API for Obsidian Active File API
  version: '1.0'
servers:
- description: HTTPS (Secure Mode)
  url: https://{host}:{port}
  variables:
    host:
      default: 127.0.0.1
      description: Binding host
    port:
      default: '27124'
      description: HTTPS port
- description: HTTP (Insecure Mode)
  url: http://{host}:{port}
  variables:
    host:
      default: 127.0.0.1
      description: Binding host
    port:
      default: '27123'
      description: HTTP port
security:
- apiKeyAuth: []
tags:
- name: Active File
paths:
  /active/:
    delete:
      parameters: []
      responses:
        '204':
          description: Success
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: File does not exist.
        '405':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Your path references a directory instead of a file; this request method is valid only for updating files.

            '
      summary: Deletes the currently-active file in Obsidian
      tags:
      - Active File
      operationId: deleteActive
      x-operation-id-source: derived
    get:
      description: 'Returns the content of the currently active file in Obsidian.


        # Targeting a Sub-part of your Document


        You can operate on a specific section of a note instead of the whole file by providing `Target-Type` and `Target` headers:


        - Set `Target-Type` to `heading`, `block`, or `frontmatter`.

        - Set `Target` to the name of the heading, block reference, or frontmatter field. If the target contains non-ASCII characters (e.g. accented letters), percent-encode the value (e.g. `H%C3%A9llo` for `Héllo`).

        - For nested headings, use the `Target-Delimiter` header (default `::`) to separate levels.


        You can also embed the target type and target directly in the URL path after the note identifier instead of using headers. The segment immediately following the note identifier is the target type, and the remaining segments form the target:


        - `.../heading/My%20Section` is equivalent to supplying `Target-Type: heading` and `Target: My%20Section`.

        - For nested headings, add additional path segments: `.../heading/My%20Section/Subsection` is equivalent to `Target: My%20Section::Subsection`.

        - `.../frontmatter/fieldName` targets the `fieldName` frontmatter field.

        - `.../block/abc123` targets the block with reference ID `abc123`.


        When URL-embedded values are present they take priority over the corresponding headers.


        # Retrieving Document Metadata


        ## Metadata


        If you specify the header `Accept: application/vnd.olrapi.note+json`, will return a JSON representation of your note including parsed tag and frontmatter data as well as filesystem metadata.


        ## Document Map


        If you specify the header `Accept: application/vnd.olrapi.document-map+json`, will return a JSON object outlining what PATCH targets exist. See "responses" below for details.'
      parameters:
      - description: 'Type of sub-document section to target. When specified, the operation

          applies only to the matching section rather than the whole file. Must

          be used together with the `Target` header.


          - `heading`: a markdown heading section.

          - `block`: a block reference.

          - `frontmatter`: a frontmatter field.

          '
        in: header
        name: Target-Type
        required: false
        schema:
          enum:
          - heading
          - block
          - frontmatter
          type: string
      - description: 'The section to target; required when `Target-Type` is specified.

          This value can be URL-Encoded and *must* be URL-Encoded if it

          includes non-ASCII characters.

          '
        in: header
        name: Target
        required: false
        schema:
          type: string
      - description: Delimiter used when specifying nested heading targets (e.g. "Heading 1::Subheading"). Defaults to "::".
        in: header
        name: Target-Delimiter
        required: false
        schema:
          default: '::'
          type: string
      responses:
        '200':
          content:
            application/json:
              description: Returned when `Target-Type` is `frontmatter`; the JSON value of the specified frontmatter field.
              schema: {}
            application/vnd.olrapi.document-map+json:
              schema:
                properties:
                  blocks:
                    example:
                    - ^blockref1
                    - ^anotherBlockRef
                    items:
                      type: string
                    type: array
                  frontmatterFields:
                    example:
                    - title
                    - tags
                    - dateCreated
                    items:
                      type: string
                    type: array
                  headings:
                    example:
                    - Heading 1
                    - Heading 1::Subhead of Heading 1
                    - Heading 2
                    items:
                      type: string
                    type: array
                type: object
            application/vnd.olrapi.note+json:
              schema:
                $ref: '#/components/schemas/NoteJson'
            text/markdown:
              schema:
                example: '# This is my document


                  something else here

                  '
                type: string
          description: Success
        '404':
          description: File or target section does not exist
      summary: Return the content of the active file open in Obsidian
      tags:
      - Active File
      operationId: getActive
      x-operation-id-source: derived
    patch:
      description: Inserts content into the currently-open note relative to a heading, block reference, or frontmatter field within that document.
      parameters:
      - description: Patch operation to perform
        in: header
        name: Operation
        required: true
        schema:
          enum:
          - append
          - prepend
          - replace
          type: string
      - description: If the specified Target does not exist, create it?
        in: header
        name: Create-Target-If-Missing
        required: false
        schema:
          default: 'false'
          enum:
          - 'true'
          - 'false'
          type: string
      - description: If patch data already exists in Target, apply patch anyway?
        in: header
        name: Apply-If-Content-Preexists
        required: false
        schema:
          default: 'false'
          enum:
          - 'true'
          - 'false'
          type: string
      - description: Trim whitespace from Target content before applying the operation?
        in: header
        name: Trim-Target-Whitespace
        required: false
        schema:
          default: 'false'
          enum:
          - 'true'
          - 'false'
          type: string
      - description: 'Type of sub-document section to target. When specified, the operation

          applies only to the matching section rather than the whole file. Must

          be used together with the `Target` header.


          - `heading`: a markdown heading section.

          - `block`: a block reference.

          - `frontmatter`: a frontmatter field.

          '
        in: header
        name: Target-Type
        required: true
        schema:
          enum:
          - heading
          - block
          - frontmatter
          type: string
      - description: 'The section to target; required when `Target-Type` is specified.

          This value can be URL-Encoded and *must* be URL-Encoded if it

          includes non-ASCII characters.

          '
        in: header
        name: Target
        required: true
        schema:
          type: string
      - description: Delimiter used when specifying nested heading targets (e.g. "Heading 1::Subheading"). Defaults to "::".
        in: header
        name: Target-Delimiter
        required: false
        schema:
          default: '::'
          type: string
      requestBody:
        content:
          application/json:
            schema:
              example: '[''one'', ''two'']'
              type: string
          text/markdown:
            schema:
              example: '# This is my document


                something else here

                '
              type: string
        description: Content you would like to insert.
        required: true
      responses:
        '200':
          description: Success
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Bad Request; see response message for details.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Does not exist
        '405':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Your path references a directory instead of a file; this request method is valid only for updating files.

            '
      summary: Partially update content in the currently open note
      tags:
      - Active File
      operationId: patchActive
      x-operation-id-source: derived
    post:
      description: 'Appends content to the end of the currently-open note.


        # Targeting a Sub-part of your Document


        You can operate on a specific section of a note instead of the whole file by providing `Target-Type` and `Target` headers:


        - Set `Target-Type` to `heading`, `block`, or `frontmatter`.

        - Set `Target` to the name of the heading, block reference, or frontmatter field. If the target contains non-ASCII characters (e.g. accented letters), percent-encode the value (e.g. `H%C3%A9llo` for `Héllo`).

        - For nested headings, use the `Target-Delimiter` header (default `::`) to separate levels.


        You can also embed the target type and target directly in the URL path after the note identifier instead of using headers. The segment immediately following the note identifier is the target type, and the remaining segments form the target:


        - `.../heading/My%20Section` is equivalent to supplying `Target-Type: heading` and `Target: My%20Section`.

        - For nested headings, add additional path segments: `.../heading/My%20Section/Subsection` is equivalent to `Target: My%20Section::Subsection`.

        - `.../frontmatter/fieldName` targets the `fieldName` frontmatter field.

        - `.../block/abc123` targets the block with reference ID `abc123`.


        When URL-embedded values are present they take priority over the corresponding headers.


        When a target is specified the content is appended within that section and the full updated file content is returned with a `200` status. Without a target, the content is appended to the end of the file and a `204` status is returned.


        If you need `prepend` or `replace` operations, use `PATCH` instead.'
      parameters:
      - description: If the specified Target does not exist, create it?
        in: header
        name: Create-Target-If-Missing
        required: false
        schema:
          default: 'false'
          enum:
          - 'true'
          - 'false'
          type: string
      - description: If patch data already exists in Target, apply patch anyway?
        in: header
        name: Apply-If-Content-Preexists
        required: false
        schema:
          default: 'false'
          enum:
          - 'true'
          - 'false'
          type: string
      - description: Trim whitespace from Target content before applying the operation?
        in: header
        name: Trim-Target-Whitespace
        required: false
        schema:
          default: 'false'
          enum:
          - 'true'
          - 'false'
          type: string
      - description: 'Type of sub-document section to target. When specified, the operation

          applies only to the matching section rather than the whole file. Must

          be used together with the `Target` header.


          - `heading`: a markdown heading section.

          - `block`: a block reference.

          - `frontmatter`: a frontmatter field.

          '
        in: header
        name: Target-Type
        required: false
        schema:
          enum:
          - heading
          - block
          - frontmatter
          type: string
      - description: 'The section to target; required when `Target-Type` is specified.

          This value can be URL-Encoded and *must* be URL-Encoded if it

          includes non-ASCII characters.

          '
        in: header
        name: Target
        required: false
        schema:
          type: string
      - description: Delimiter used when specifying nested heading targets (e.g. "Heading 1::Subheading"). Defaults to "::".
        in: header
        name: Target-Delimiter
        required: false
        schema:
          default: '::'
          type: string
      requestBody:
        content:
          text/markdown:
            schema:
              example: '# This is my document


                something else here

                '
              type: string
        description: Content you would like to append.
        required: true
      responses:
        '200':
          content:
            text/markdown:
              schema:
                type: string
          description: Success; targeted section updated. The full updated file content is returned.
        '204':
          description: Success; content appended to end of file.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Bad Request
        '405':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Your path references a directory instead of a file; this request method is valid only for updating files.

            '
      summary: Append content to the active file open in Obsidian
      tags:
      - Active File
      operationId: postActive
      x-operation-id-source: derived
    put:
      description: '# Targeting a Sub-part of your Document


        You can operate on a specific section of a note instead of the whole file by providing `Target-Type` and `Target` headers:


        - Set `Target-Type` to `heading`, `block`, or `frontmatter`.

        - Set `Target` to the name of the heading, block reference, or frontmatter field. If the target contains non-ASCII characters (e.g. accented letters), percent-encode the value (e.g. `H%C3%A9llo` for `Héllo`).

        - For nested headings, use the `Target-Delimiter` header (default `::`) to separate levels.


        You can also embed the target type and target directly in the URL path after the note identifier instead of using headers. The segment immediately following the note identifier is the target type, and the remaining segments form the target:


        - `.../heading/My%20Section` is equivalent to supplying `Target-Type: heading` and `Target: My%20Section`.

        - For nested headings, add additional path segments: `.../heading/My%20Section/Subsection` is equivalent to `Target: My%20Section::Subsection`.

        - `.../frontmatter/fieldName` targets the `fieldName` frontmatter field.

        - `.../block/abc123` targets the block with reference ID `abc123`.


        When URL-embedded values are present they take priority over the corresponding headers.


        When a target is specified the target section is replaced with the request body and the full updated file content is returned with a `200` status. If the target does not exist it will be created. Without a target, the entire file is replaced and a `204` status is returned.'
      parameters:
      - description: If patch data already exists in Target, apply patch anyway?
        in: header
        name: Apply-If-Content-Preexists
        required: false
        schema:
          default: 'false'
          enum:
          - 'true'
          - 'false'
          type: string
      - description: Trim whitespace from Target content before applying the operation?
        in: header
        name: Trim-Target-Whitespace
        required: false
        schema:
          default: 'false'
          enum:
          - 'true'
          - 'false'
          type: string
      - description: 'Type of sub-document section to target. When specified, the operation

          applies only to the matching section rather than the whole file. Must

          be used together with the `Target` header.


          - `heading`: a markdown heading section.

          - `block`: a block reference.

          - `frontmatter`: a frontmatter field.

          '
        in: header
        name: Target-Type
        required: false
        schema:
          enum:
          - heading
          - block
          - frontmatter
          type: string
      - description: 'The section to target; required when `Target-Type` is specified.

          This value can be URL-Encoded and *must* be URL-Encoded if it

          includes non-ASCII characters.

          '
        in: header
        name: Target
        required: false
        schema:
          type: string
      - description: Delimiter used when specifying nested heading targets (e.g. "Heading 1::Subheading"). Defaults to "::".
        in: header
        name: Target-Delimiter
        required: false
        schema:
          default: '::'
          type: string
      requestBody:
        content:
          '*/*':
            schema:
              type: string
          text/markdown:
            schema:
              example: '# This is my document


                something else here

                '
              type: string
        description: Content of the file you would like to upload.
        required: true
      responses:
        '200':
          content:
            text/markdown:
              schema:
                type: string
          description: Success; targeted section replaced. The full updated file content is returned.
        '204':
          description: Success; entire file replaced.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Incoming file could not be processed.  Make sure you have specified a reasonable file name, and make sure you have set a reasonable ''Content-Type'' header; if you are uploading a note, ''text/markdown'' is likely the right choice.

            '
        '405':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Your path references a directory instead of a file; this request method is valid only for updating files.

            '
      summary: Update the content of the active file open in Obsidian
      tags:
      - Active File
      operationId: putActive
      x-operation-id-source: derived
components:
  schemas:
    NoteJson:
      properties:
        content:
          type: string
        frontmatter:
          type: object
        path:
          type: string
        stat:
          properties:
            ctime:
              type: number
            mtime:
              type: number
            size:
              type: number
          required:
          - ctime
          - mtime
          - size
          type: object
        tags:
          items:
            type: string
          type: array
      required:
      - tags
      - frontmatter
      - stat
      - path
      - content
      type: object
    Error:
      properties:
        errorCode:
          description: 'A 5-digit error code uniquely identifying this particular type of error.

            '
          example: 40149
          type: number
        message:
          description: Message describing the error.
          example: A brief description of the error.
          type: string
      type: object
  securitySchemes:
    apiKeyAuth:
      description: 'Find your API Key in your Obsidian settings

        in the "Local REST API" section under "Plugins".

        '
      scheme: bearer
      type: http