> ## 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 upgrade plans with filtering, sorting and pagination

> Query upgrade plans across the organization using DrafttQL with advanced filtering, field selection, and cursor-based pagination.



## OpenAPI

````yaml https://api.draftt.io/swagger post /upgradePlan/query
openapi: 3.1.0
info:
  title: Draftt API
  version: 0.2.1
servers:
  - url: https://api.draftt.io/v1
security:
  - BearerAuth: []
paths:
  /upgradePlan/query:
    post:
      tags:
        - Upgrade Plan
      summary: Query upgrade plans with filtering, sorting and pagination
      description: >-
        Query upgrade plans across the organization using DrafttQL with advanced
        filtering, field selection, and cursor-based pagination.
      operationId: queryUpgradePlans
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DrafttQuery'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DrafttResponse'
        '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:
    DrafttQuery:
      type: object
      examples:
        - filter:
            status:
              $in:
                - active
                - completed
          sort:
            createdAt: desc
          pageSize: 20
        - filter:
            technology:
              $eq: eks
            status:
              $eq: active
          sort:
            updatedAt: desc
      properties:
        filter:
          $ref: '#/components/schemas/DrafttFilter'
        select:
          type: array
          description: >-
            If empty - will return all fields, if passed will only return
            selected fields
          items:
            type: string
            enum:
              - id
              - componentId
              - technology
              - status
              - currentVersion
              - desiredVersion
              - createdAt
              - updatedAt
              - completedAt
        sort:
          type: object
          description: >-
            Optional sorting options, if not passed will sort by creation date
            in ascending order
          properties:
            id:
              type: string
              enum:
                - asc
                - desc
            componentId:
              type: string
              enum:
                - asc
                - desc
            technology:
              type: string
              enum:
                - asc
                - desc
            status:
              type: string
              enum:
                - asc
                - desc
            currentVersion:
              type: string
              enum:
                - asc
                - desc
            desiredVersion:
              type: string
              enum:
                - asc
                - desc
            createdAt:
              type: string
              enum:
                - asc
                - desc
            updatedAt:
              type: string
              enum:
                - asc
                - desc
            completedAt:
              type: string
              enum:
                - asc
                - desc
          maxProperties: 2
        pageToken:
          type: string
          description: Base64 token for pagination
        pageSize:
          type: integer
          minimum: 1
          maximum: 1000
          default: 100
          description: Number of items to return per page
    DrafttResponse:
      type: object
      required:
        - items
      example:
        nextPageToken: >-
          eyJ1bmlxdWVGaWVsZE5hbWUiOiJpZCIsInNvcnQiOnsic3RhdHVzIjp7ImRpcmVjdGlvbiI6ImFzYyJ9fX0=
        items:
          - id: abc123
            componentId: '27448'
            technology: eks
            status: active
            currentVersion: '1.28'
            desiredVersion: '1.30'
            upgradePlan:
              controlPlane:
                changes:
                  - name: eks-control-plane
                    currentVersion: '1.28'
                    desiredVersion: '1.30'
                    status: pending
            createdAt: '2025-01-10T08:00:00.000Z'
            updatedAt: '2025-04-01T12:00:00.000Z'
            completedAt: null
          - ...
      properties:
        items:
          type: array
          items:
            anyOf:
              - $ref: '#/components/schemas/K8sUpgradePlanApiAttributes'
              - $ref: '#/components/schemas/DrafttApiAttributes'
        nextPageToken:
          oneOf:
            - type: string
              description: Token for fetching the next page of results
            - type: 'null'
    DrafttFilter:
      type: object
      properties:
        $and:
          type: array
          items:
            $ref: '#/components/schemas/DrafttFilter'
        $or:
          type: array
          items:
            $ref: '#/components/schemas/DrafttFilter'
        id:
          $ref: '#/components/schemas/StringOperatorBlock'
        componentId:
          $ref: '#/components/schemas/NumberOperatorBlock'
        technology:
          $ref: '#/components/schemas/StringOperatorBlock'
        status:
          $ref: '#/components/schemas/StringOperatorBlock'
        currentVersion:
          $ref: '#/components/schemas/StringOperatorBlock'
        desiredVersion:
          $ref: '#/components/schemas/StringOperatorBlock'
        createdAt:
          $ref: '#/components/schemas/StringOperatorBlock'
        updatedAt:
          $ref: '#/components/schemas/StringOperatorBlock'
        completedAt:
          $ref: '#/components/schemas/StringOperatorBlock'
    K8sUpgradePlanApiAttributes:
      allOf:
        - $ref: '#/components/schemas/DrafttApiAttributes'
        - type: object
          properties:
            technology:
              type: string
              enum:
                - eks
                - gke
                - aks
            upgradePlan:
              type: object
              properties:
                deployments:
                  $ref: '#/components/schemas/K8sUpgradePlanApiSection'
                controlPlane:
                  $ref: '#/components/schemas/K8sUpgradePlanApiSection'
                nodes:
                  $ref: '#/components/schemas/K8sUpgradePlanApiSection'
                k8sApi:
                  $ref: '#/components/schemas/K8sUpgradePlanApiSection'
    DrafttApiAttributes:
      type: object
      properties:
        id:
          type: string
          format: int64
        componentId:
          type: string
          format: int64
        name:
          type: string
        technology:
          type: string
          description: Upgrade-plan flavor discriminator.
        currentVersion:
          type: string
        desiredVersion:
          type: string
        status:
          type: string
          enum:
            - active
            - pending
            - completed
        upgradePlan:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DrafttApiSection'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        completedAt:
          type:
            - string
            - 'null'
          format: date-time
        deletedAt:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - componentId
        - name
        - technology
        - currentVersion
        - desiredVersion
        - status
        - upgradePlan
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - error
    StringOperatorBlock:
      type: object
      properties:
        $eq:
          type: string
          description: Equals operator
        $ne:
          type: string
          description: Not equals operator
        $gt:
          type: string
          description: Greater than operator
        $gte:
          type: string
          description: Greater than or equal operator
        $lt:
          type: string
          description: Less than operator
        $lte:
          type: string
          description: Less than or equal operator
        $like:
          type: string
          description: >-
            Like operator, case-sensitive, wildcards are defined as `*`, for
            example - `{$like: 'abc*'}` - starts with abc.
        $ilike:
          type: string
          description: Case-insensitive `$like` - same wildcard and whole-value rules
        $in:
          type: array
          items:
            type: string
          description: In operator
        $nin:
          type: array
          items:
            type: string
          description: Not in operator
        $exists:
          type: boolean
          description: Exists operator
      minProperties: 1
      maxProperties: 1
    NumberOperatorBlock:
      type: object
      description: >-
        Exactly one operator per field. Pass numbers, not numeric strings - a
        string value does not match rather than erroring.
      properties:
        $eq:
          type: number
          description: Equals operator
        $ne:
          type: number
          description: Not equals operator
        $gt:
          type: number
          description: Greater than operator
        $gte:
          type: number
          description: Greater than or equal operator
        $lt:
          type: number
          description: Less than operator
        $lte:
          type: number
          description: Less than or equal operator
        $in:
          type: array
          items:
            type: number
          description: In operator
        $nin:
          type: array
          items:
            type: number
          description: Not in operator
        $exists:
          type: boolean
          description: Exists operator
      minProperties: 1
      maxProperties: 1
    K8sUpgradePlanApiSection:
      type: object
      properties:
        changes:
          type: array
          items:
            $ref: '#/components/schemas/K8sUpgradePlanApiChange'
      required:
        - changes
    DrafttApiSection:
      type: object
      properties:
        changes:
          type: array
          items:
            $ref: '#/components/schemas/DrafttApiChange'
      required:
        - changes
    K8sUpgradePlanApiChange:
      allOf:
        - $ref: '#/components/schemas/DrafttApiChange'
        - type: object
          properties:
            k8sResourceId:
              type: string
              format: uuid
              description: >-
                Present on resource-backed changes. Legacy plans may omit it
                during the rollout window.
            imageName:
              type: string
            namespace:
              type: string
            workloadName:
              type: string
            maxCompatibleVersion:
              type: string
            replacementToolName:
              type: string
            requiredAction:
              type: string
            helmChart:
              type: string
            desiredHelmChartData:
              type: object
              additionalProperties: true
            workloadManagement:
              type: object
              additionalProperties: true
            nodeManagement:
              type: object
              additionalProperties: true
            crdManagement:
              type: object
              additionalProperties: true
            deprecatedResources:
              type: array
              items:
                $ref: '#/components/schemas/K8sUpgradePlanApiResource'
    DrafttApiChange:
      type: object
      properties:
        name:
          type: string
        currentVersion:
          type: string
        desiredVersion:
          type:
            - string
            - 'null'
        status:
          type: string
          enum:
            - warning
            - pending
            - completed
            - removed
            - info
            - acknowledged
        description:
          type: string
    K8sUpgradePlanApiResource:
      type: object
      properties:
        k8sResourceId:
          type: string
          format: uuid
        name:
          type: string
        version:
          type: string
        namespace:
          type:
            - string
            - 'null'
        lastApplied:
          type: boolean
        managedBy:
          type: string
        helmRelease:
          type: object
          additionalProperties: true
        requiredChanges:
          type: array
          items:
            type: object
            additionalProperties: true
        apiVersionState:
          type: object
          additionalProperties: true
      required:
        - name
        - version
  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

````