> ## 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 (draftts) across the organization using DrafttQL with advanced filtering, field selection, and cursor-based pagination.



## OpenAPI

````yaml https://api.draftt.io/swagger post /draftt/query
openapi: 3.1.0
info:
  title: Draftt API
  version: 0.2.1
servers:
  - url: https://api.draftt.io/v1
security:
  - BearerAuth: []
paths:
  /draftt/query:
    post:
      tags:
        - Draftt
      summary: Query upgrade plans with filtering, sorting and pagination
      description: >-
        Query upgrade plans (draftts) across the organization using DrafttQL
        with advanced filtering, field selection, and cursor-based pagination.
      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: k8s
            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: k8s
            status: active
            currentVersion: '1.28'
            desiredVersion: '1.30'
            createdAt: '2025-01-10T08:00:00.000Z'
            updatedAt: '2025-04-01T12:00:00.000Z'
            completedAt: null
          - ...
      properties:
        items:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                description: Draftt ID
              componentId:
                type: string
                format: int64
              technology:
                type: string
              status:
                type: string
                enum:
                  - active
                  - pending
                  - completed
              currentVersion:
                type: string
              desiredVersion:
                type: string
              createdAt:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              updatedAt:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              completedAt:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
        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'
    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, wildrards are defind as `*`, for example - `{$like:
            'abc*'}` - starts with abc
        $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
      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
  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

````