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

# List Active Queries

> List active queries in the supplied database. The database query parameter is required and must not be empty or whitespace-only. Returns full query text and durations in seconds.



## OpenAPI

````yaml /machines-api/openapi.json get /v1/postgres/{postgres_cluster_id}/queries/active
openapi: 3.0.1
info:
  title: Machines API
  description: >-
    This site hosts documentation generated from the Fly.io Machines API OpenAPI
    specification. Visit our complete [Machines API
    docs](https://fly.io/docs/machines/api/) for how to get started, more
    information about each endpoint, parameter descriptions, and examples.
  contact: {}
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: '1.0'
servers:
  - url: https://api.machines.dev
security: []
tags:
  - name: Apps
    description: >-
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/apps-resource/) for details about
      using the Apps resource.
  - name: Machines
    description: >-
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/machines-resource/) for details
      about using the Machines resource.
  - name: TLS Certificates
    description: >
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/certificates-resource/) for details
      about using the TLS Certificates resource.
  - name: Volumes
    description: >-
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/volumes-resource/) for details
      about using the Volumes resource.
  - name: Postgres Clusters
    description: >-
      Create and manage Postgres clusters, including databases, users,
      extensions, backups, and app attachments.
externalDocs:
  url: https://fly.io/docs/machines/working-with-machines/
paths:
  /v1/postgres/{postgres_cluster_id}/queries/active:
    get:
      tags:
        - Postgres Clusters
      summary: List Active Queries
      description: >-
        List active queries in the supplied database. The database query
        parameter is required and must not be empty or whitespace-only. Returns
        full query text and durations in seconds.
      operationId: Postgres_queries_active
      parameters:
        - name: postgres_cluster_id
          in: path
          description: Managed Postgres Cluster ID
          required: true
          schema:
            type: string
        - name: database
          in: query
          description: Database to inspect (must not be empty or whitespace-only)
          required: true
          schema:
            minLength: 1
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/listPostgresActiveQueriesResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostgresErrorResponse'
        '404':
          description: Cluster not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostgresErrorResponse'
        '422':
          description: database must be a non-empty string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostgresErrorResponse'
        '500':
          description: Unable to load active queries
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostgresErrorResponse'
      security:
        - FlyBearerAuth: []
components:
  schemas:
    listPostgresActiveQueriesResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/PostgresActiveQuery'
    PostgresErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
    PostgresActiveQuery:
      type: object
      properties:
        application_name:
          type: string
          description: Application connected to the backend.
        client:
          type: string
          description: Client address.
        database:
          type: string
          description: Database name.
        duration_seconds:
          type: number
          description: Query duration in seconds.
        pid:
          type: integer
          description: Process ID of the backend running the query.
        query:
          type: string
          description: Full query text.
        state:
          type: string
          description: Current backend state.
        state_duration_seconds:
          type: number
          description: Time spent in the current state, in seconds.
        user:
          type: string
          description: User running the query.
        wait_event:
          type: string
          description: Event the backend is waiting for.
        wait_event_type:
          type: string
          description: Type of event the backend is waiting for.
  securitySchemes:
    FlyBearerAuth:
      type: apiKey
      description: >-
        A Fly API token with access to the requested organization or resource.
        Send it as `Authorization: Bearer <Fly API token>`.
      name: Authorization
      in: header

````