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

# Query scoped Kubernetes resources

> Queries collected Kubernetes resources with DrafttQL filtering, selection, sorting, and pagination. Discover supported details$ fields with POST /k8sResource/detailsSchema first.



## OpenAPI

````yaml https://api.draftt.io/swagger post /k8sResource/query
openapi: 3.1.0
info:
  title: Draftt API
  version: 0.2.1
servers:
  - url: https://api.draftt.io/v1
security:
  - BearerAuth: []
paths:
  /k8sResource/query:
    post:
      tags:
        - K8s Resource
      summary: Query scoped Kubernetes resources
      description: >-
        Queries collected Kubernetes resources with DrafttQL filtering,
        selection, sorting, and pagination. Discover supported details$ fields
        with POST /k8sResource/detailsSchema first.
      operationId: queryK8sResources
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/K8sResourceQuery'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/K8sResourceResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    K8sResourceQuery:
      type: object
      properties:
        filter:
          type: object
          additionalProperties: true
          description: >-
            DrafttQL filter. A kind $eq/$in filter is required when a details$
            path is used.
        select:
          type: array
          items:
            type: string
            enum:
              - id
              - clusterComponentId
              - clusterComponentName
              - uniqueIdentifier
              - name
              - kind
              - namespace
              - apiVersion
              - apiGroup
              - collectionMode
              - knownCrd
              - labels
              - details
              - ownershipClass
              - managedBy
              - managedByName
              - managedByNamespace
              - helmChartName
              - helmChartVersion
              - createdAt
              - updatedAt
        sort:
          type: object
          additionalProperties:
            type: string
            enum:
              - asc
              - desc
        pageToken:
          type: string
        pageSize:
          type: integer
          minimum: 1
          maximum: 1000
          default: 100
      example:
        filter:
          kind:
            $eq: Deployment
          details$.spec$.replicas:
            $gte: 3
        select:
          - id
          - name
          - kind
          - namespace
          - details
        pageSize: 50
    K8sResourceResponse:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/K8sResource'
        nextPageToken:
          type: string
      required:
        - items
    K8sResource:
      type: object
      properties:
        id:
          type: string
          format: uuid
        clusterComponentId:
          type: string
          format: int64
        clusterComponentName:
          type: string
        uniqueIdentifier:
          type: string
        name:
          type: string
        kind:
          type: string
        namespace:
          type:
            - string
            - 'null'
        apiVersion:
          type: string
        apiGroup:
          type: string
        collectionMode:
          type: string
          enum:
            - full
            - metadata-only
        knownCrd:
          type:
            - boolean
            - 'null'
          description: >-
            `true` identifies a known CRD with its full spec available; `false`
            identifies an unknown CRD; `null` identifies a native Kubernetes API
            resource, whose full spec is always available.
        labels:
          type: object
          additionalProperties:
            type: string
        details:
          oneOf:
            - $ref: '#/components/schemas/K8sResourceDetails'
            - type: 'null'
        enrichment:
          type: object
          additionalProperties: true
          description: >-
            Analyzer enrichment promoted from the internal persisted details
            block.
        ownershipClass:
          type:
            - string
            - 'null'
          enum:
            - system-managed
            - user-managed
            - null
        managedBy:
          type:
            - string
            - 'null'
          enum:
            - Helm
            - ArgoCD
            - Flux
            - HelmAndArgoCD
            - HelmAndFlux
            - ArgoCDAndFlux
            - HelmAndArgoCDAndFlux
            - null
        managedByName:
          type:
            - string
            - 'null'
        managedByNamespace:
          type:
            - string
            - 'null'
        helmChartName:
          type:
            - string
            - 'null'
        helmChartVersion:
          type:
            - string
            - 'null'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - clusterComponentId
        - uniqueIdentifier
        - name
        - kind
        - apiVersion
        - apiGroup
        - collectionMode
        - labels
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - error
    K8sResourceDetails:
      type: object
      description: >-
        Collected manifest context. Internal persisted data is removed from API
        responses.
      additionalProperties: true
      properties:
        labels:
          type: object
          additionalProperties:
            type: string
        annotations:
          type: object
          additionalProperties:
            type: string
        annotationKeys:
          type: array
          items:
            type: string
        ownerRefs:
          type: array
          items:
            type: object
            additionalProperties: true
        management:
          $ref: '#/components/schemas/K8sResourceManagement'
        nodeInfo:
          type: object
          additionalProperties: true
        spec:
          type: object
          additionalProperties: true
    K8sResourceManagement:
      type: object
      additionalProperties: true
      properties:
        managedBy:
          type: string
          enum:
            - Helm
            - ArgoCD
            - Flux
            - HelmAndArgoCD
            - HelmAndFlux
            - ArgoCDAndFlux
            - HelmAndArgoCDAndFlux
        helm:
          type: object
          additionalProperties: true
        argocd:
          type: object
          additionalProperties: true
        flux:
          type: object
          additionalProperties: true
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    TooManyRequests:
      description: Too Many Requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````