> ## 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.

# Shut down the server

> Trip the exit event, which the app's `on_idle_exit` acts on.

The daemon's hook sends SIGTERM to its own process, so uvicorn runs
its graceful shutdown (close connections, run the lifespan's finally
block). An app run without a hook keeps serving. The server serves
every account, so an account may not stop it.

> [accordion] Errors
>
> | Status | Meaning |
> | - | - |
> | `401` | The token is missing or wrong |
> | `429` | Past a rate limit, or a new session past max\_sessions |
>
> 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/daemon/shutdown
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
    parent: Workspace operations
  - name: Snapshots
  - name: Templates
  - name: Saved VFS
    x-group: VFS
    parent: Saved configurations
  - name: Saved CLIs
    x-group: CLIs
    parent: Saved configurations
  - name: Saved runtimes
    x-group: Runtimes
    parent: Saved configurations
  - name: Saved machines
    x-group: Machines
    parent: Saved configurations
  - name: Saved configurations
  - name: Policies
  - name: Asks
    parent: Workspace operations
  - name: Lines
    parent: Workspace operations
  - name: Jobs
    parent: Workspace operations
  - name: Processes
    parent: Workspace operations
  - name: Machines
    parent: Workspace operations
  - name: Service
  - name: Daemon
  - name: Auth
paths:
  /v1/daemon/shutdown:
    post:
      tags:
        - Daemon
      summary: Shut down the server
      description: |-
        Trip the exit event, which the app's `on_idle_exit` acts on.

        The daemon's hook sends SIGTERM to its own process, so uvicorn runs
        its graceful shutdown (close connections, run the lifespan's finally
        block). An app run without a hook keeps serving. The server serves
        every account, so an account may not stop it.
      operationId: shutdown_v1_daemon_shutdown_post
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ShutdownResponse'
components:
  schemas:
    ShutdownResponse:
      properties:
        status:
          type: string
          title: Status
        pid:
          title: Pid
          type: integer
      type: object
      required:
        - status
        - pid
      title: ShutdownResponse
  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.