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

# Call VFS function

Call a VFS function by name using the selected session and its permissions. Request arguments and the JSON response depend on the function. A name no mount declares answers `400` with `errno` `ENOTSUP`. A name Mirage defines itself, such as `copy`, answers `400` without an `errno`.

> [accordion] Errors
>
> | Status | Meaning |
> | - | - |
> | `400` | The request is malformed: the body is not JSON (`invalid_json`) or not a JSON object, a field is missing (`missing_field`), unknown (`unknown_field`) or has a wrong value (`invalid_value`), or the request is otherwise invalid (`invalid_request`). `param` names the field at fault. |
> | `401` | The token is missing or wrong (`unauthorized`). |
> | `403` | The call is refused. A policy refused it (`policy_refused`, with `decision`), a mount mode or permission refused it (`forbidden`), the backend is out of space or quota (`storage_full`), or the request came for a host or from a browser origin that is not allowed (`host_not_allowed`, `origin_not_allowed`). |
> | `404` | The workspace, session, job, file or route does not exist, or the caller may not see it (`not_found`). |
> | `409` | The request conflicts with the current state. The id or name is taken (`already_exists`), the workspace is busy on another server or starting or stopping (`workspace_busy`), the workspace is stopped (`workspace_stopped`), a file changed since it was read (`stale_write`), or the state allows no such change (`conflict`). |
> | `429` | Past a rate limit (`rate_limited`), or a new session past max\_sessions (`session_limit`). |
> | `413` | The request body, a multipart part, or stdin exceeds its size limit (`too_large`). |
> | `500` | The server failed internally (`internal`). The message is `internal server error` and the cause goes to the server log. A file call that fails with an I/O error (`EIO`, `EPIPE`, `EBADF`) carries its `errno` and the POSIX message instead. Check for side effects before retrying. |
>
> See [error examples and recovery steps](https://docs.mirage.strukto.ai/api/errors.md). The [complete OpenAPI contract](https://github.com/strukto-ai/mirage/blob/main/docs/openapi.yaml) includes every response schema.


## OpenAPI

````yaml /openapi.yaml post /v1/workspaces/{workspace_id}/vfs/{name}
openapi: 3.2.0
info:
  title: Mirage API
  version: '0.1'
servers:
  - url: http://127.0.0.1:8765
    description: A local server on its default port
security:
  - bearerAuth: []
tags:
  - name: Workspace operations
    x-group: Workspaces
  - name: Workspaces
    x-group: Lifecycle
    parent: Workspace operations
  - name: Sessions
  - name: Shell
    parent: Workspace operations
  - name: VFS
    parent: Workspace operations
  - name: Tools
  - name: Documents
    x-group: Agent Instructions
    parent: Workspace operations
  - name: Snapshots
  - name: Templates
    parent: Configuration
  - name: Saved VFS
    x-group: VFS
    parent: Configuration
  - name: Saved CLIs
    x-group: CLI
    parent: Configuration
  - name: Saved machines
    x-group: Machine
    parent: Configuration
  - name: Configuration
  - name: Policies
    parent: Configuration
  - name: Asks
    parent: Workspace operations
    x-group: Approval requests
  - name: Lines
    parent: Workspace operations
    x-group: Commands
  - name: Jobs
    parent: Workspace operations
  - name: Processes
    parent: Workspace operations
  - name: Machines
    parent: Workspace operations
  - name: Server
  - name: Service
    parent: Server
  - name: Daemon
    parent: Server
  - name: Auth
paths:
  /v1/workspaces/{workspace_id}/vfs/{name}:
    post:
      tags:
        - VFS
      summary: Call VFS function
      operationId: custom_function_v1_workspaces__workspace_id__vfs__name__post
      parameters:
        - $ref: '#/components/parameters/workspaceId'
        - name: name
          in: path
          required: true
          schema:
            type: string
          description: The function's name, as a mount declares it.
        - $ref: '#/components/parameters/sessionId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                path:
                  type: string
                  description: The path the function acts on.
                kwargs:
                  type: object
                  description: The function's keyword arguments.
              required:
                - path
              additionalProperties: false
            example:
              path: /hello.txt
              kwargs: {}
      responses:
        '200':
          description: '`value` is what the function returns.'
          content:
            application/json:
              schema:
                type: object
                title: Result
                properties:
                  value:
                    description: What the function returns.
                required:
                  - value
                additionalProperties: false
              example:
                value: null
components:
  parameters:
    workspaceId:
      name: workspace_id
      in: path
      required: true
      description: Workspace ID.
      schema:
        type: string
      example: demo
    sessionId:
      name: session_id
      in: query
      required: false
      description: Session ID to use. If omitted, the default session is used.
      schema:
        type: string
      example: analysis
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        The server's token (MIRAGE_AUTH_TOKEN) or a JWT. A daemon in the default
        local mode with no token accepts requests without one.

````

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