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

# List the saved queries

> Return your company's saved queries as JSON: the osquery SQL each one runs, how often (`intervalSeconds`), on which platforms and devices (`target`). Use this to find a `queryId` before reading what the devices answered with `getStoredQueryResults`.

A query whose `intervalSeconds` is 0 never runs on its own and stores no results. `isPrimoManaged` flags a query Primo created for one of its own features; its results read like any other.

Key: ReadScope: Company


## OpenAPI

````yaml https://api.getprimo.com/openapi.json get /queries
openapi: 3.1.1
info:
  title: Public API - BETA
  description: Read docs on https://docs.getprimo.com/
  version: '1.0'
  contact: {}
servers:
  - url: https://api.getprimo.com
security:
  - apikey: []
tags: []
paths:
  /queries:
    get:
      tags:
        - Queries
      summary: List the saved queries
      description: >-
        Return your company's saved queries as JSON: the osquery SQL each one
        runs, how often (`intervalSeconds`), on which platforms and devices
        (`target`). Use this to find a `queryId` before reading what the devices
        answered with `getStoredQueryResults`.


        A query whose `intervalSeconds` is 0 never runs on its own and stores no
        results. `isPrimoManaged` flags a query Primo created for one of its own
        features; its results read like any other.
      operationId: getQueries
      parameters: []
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetQueries_Output'
components:
  schemas:
    GetQueries_Output:
      type: object
      properties:
        data:
          type: array
          items:
            type: object
            properties:
              id:
                description: >-
                  Identifier of the saved query, used as `queryId` to read its
                  stored results.
                type: number
              name:
                type: string
              description:
                type: string
              sql:
                description: The osquery SQL the devices run.
                type: string
              platforms:
                description: Platforms the query runs on.
                type: array
                items:
                  type: string
                  enum:
                    - macos
                    - windows
                    - linux
              intervalSeconds:
                description: >-
                  How often each device runs the query, in seconds. 0: it never
                  runs on its own and stores no results.
                type: number
              target:
                description: >-
                  The devices the query runs on: `all`, the `deviceGroups`
                  named, or `labels` set in Fleet that match no device group.
                anyOf:
                  - type: object
                    properties:
                      type:
                        type: string
                        const: all
                    required:
                      - type
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: deviceGroups
                      deviceGroups:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                            name:
                              type: string
                          required:
                            - id
                            - name
                          additionalProperties: false
                    required:
                      - type
                      - deviceGroups
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: labels
                      labels:
                        type: array
                        items:
                          type: string
                    required:
                      - type
                      - labels
                    additionalProperties: false
              isPrimoManaged:
                description: True for a query Primo created for one of its own features.
                type: boolean
              createdAt:
                anyOf:
                  - type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                  - type: 'null'
              updatedAt:
                anyOf:
                  - type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                  - type: 'null'
            required:
              - id
              - name
              - description
              - sql
              - platforms
              - intervalSeconds
              - target
              - isPrimoManaged
              - createdAt
              - updatedAt
            additionalProperties: false
      required:
        - data
      additionalProperties: false
  securitySchemes:
    apikey:
      scheme: bearer
      bearerFormat: API key
      type: http
      description: >-
        Use your Primo API key in the Authorization header as `Bearer
        <API_KEY>`.

````

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