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

> Query components with filtering, sorting and pagination



## OpenAPI

````yaml https://api.draftt.io/swagger post /component/query
openapi: 3.1.0
info:
  title: Draftt API
  version: 0.2.1
servers:
  - url: https://api.draftt.io/v1
security:
  - BearerAuth: []
paths:
  /component/query:
    post:
      tags:
        - Component
      summary: Query components with filtering, sorting and pagination
      description: Query components with filtering, sorting and pagination
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ComponentQuery'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComponentResponse'
        '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:
    ComponentQuery:
      type: object
      examples:
        - pageSize: 20
          filter:
            technology:
              $eq: k8s
            region:
              $eq: us-east-1
          sort:
            createdAt: desc
          pageToken: >-
            eyJ1bmlxdWVGaWVsZE5hbWUiOiJpZCIsInNvcnQiOnsidXJnZW5jeSI6eyJvcmRlciI6MCwiZGlyZWN0aW9uIjoiZGVzYyJ9LCJpZCI6eyJvcmRlciI6MSwiZGlyZWN0aW9uIjoiYXNjIn19LCJzb3J0VmFsdWVzIjp7InVyZ2VuY3kiOjUuNDM0NzgyNjA4Njk1NjUyLCJpZCI6IjUwMDg1In19
        - filter:
            type:
              $eq: rds-postgres
            version:
              $like: 14.*
          sort:
            technology: asc
      properties:
        filter:
          $ref: '#/components/schemas/ComponentFilter'
        select:
          type: array
          description: >-
            If empty - will return all fields, if passed will only return
            selected fields
          items:
            type: string
            enum:
              - id
              - integrationId
              - uniqueIdentifier
              - region
              - vendor
              - technology
              - type
              - version
              - hasAvailableDraftts
              - createdAt
              - updatedAt
              - tags
              - customTags
              - details
        sort:
          type: object
          description: >-
            Optional sorting options, if not passed will sort by creation date
            in ascending order, sorting by a non-unique value will sub-sort by a
            creation date in ascending order
          properties:
            id:
              type: string
              enum:
                - asc
                - desc
            integrationId:
              type: string
              enum:
                - asc
                - desc
            uniqueIdentifier:
              type: string
              enum:
                - asc
                - desc
            region:
              type: string
              enum:
                - asc
                - desc
            vendor:
              type: string
              enum:
                - asc
                - desc
            technology:
              type: string
              enum:
                - asc
                - desc
            type:
              type: string
              enum:
                - asc
                - desc
            version:
              type: string
              enum:
                - asc
                - desc
            hasAvailableDraftts:
              type: string
              enum:
                - asc
                - desc
            createdAt:
              type: string
              enum:
                - asc
                - desc
            updatedAt:
              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
    ComponentResponse:
      type: object
      required:
        - items
      example:
        nextPageToken: >-
          eyJ1bmlxdWVGaWVsZE5hbWUiOiJpZCIsInNvcnQiOnsidXJnZW5jeSI6eyJvcmRlciI6MCwiZGlyZWN0aW9uIjoiZGVzYyJ9LCJpZCI6eyJvcmRlciI6MSwiZGlyZWN0aW9uIjoiYXNjIn19LCJzb3J0VmFsdWVzIjp7InVyZ2VuY3kiOjUuNDM0NzgyNjA4Njk1NjUyLCJpZCI6IjUwMDg1In19
        items:
          - id: '456654'
            integrationId: '6'
            uniqueIdentifier: arn:aws:rds:us-east-1:1234567:db:rds-dev-1
            region: us-east-1
            vendor: aws
            technology: rds
            type: rds-postgres
            version: '14.10'
            hasAvailableDraftts: true
            createdAt: '2024-05-06T11:25:50.750Z'
            updatedAt: '2024-09-09T14:36:11.531Z'
            tags:
              Environment: dev-us-east-1
              Terraform: 'true'
            customTags:
              CostCenter: engineering
              Owner: platform-team
            details:
              database:
                lastActiveConnectionTime: '2024-09-09T14:36:11.531Z'
          - ...
      properties:
        items:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: int64
                description: Component ID
              integrationId:
                type: string
                format: int64
              uniqueIdentifier:
                type: string
              region:
                type: string
              vendor:
                type: string
              technology:
                type: string
              type:
                type: string
              version:
                type: string
              hasAvailableDraftts:
                type: boolean
              createdAt:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              updatedAt:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              tags:
                type: object
                additionalProperties: true
              customTags:
                type: object
                additionalProperties: true
              details:
                type: object
                description: >-
                  Additional details about the component grouped by a technology
                  or technology group, each component contains only the details
                  relevant to it
                properties:
                  serverless-function:
                    type: object
                    description: Serverless function response metadata.
                    properties:
                      invocationCount:
                        type: number
                        description: >-
                          Number of invocations when available for
                          serverless-function components.
                      lastInvocationTime:
                        type: string
                        format: date-time
                        description: >-
                          Timestamp of the last invocation when available for
                          serverless-function components.
                    additionalProperties: false
                  container-image:
                    type: object
                    description: Container image response metadata.
                    properties:
                      lastPulledAt:
                        type: string
                        format: date-time
                        description: >-
                          Latest image pull timestamp when available for
                          container-image components.
                    additionalProperties: false
                  database:
                    type: object
                    description: Database response metadata.
                    properties:
                      lastActiveConnectionTime:
                        type: string
                        format: date-time
                        description: >-
                          Timestamp of the last active database connection when
                          available for database components.
                    additionalProperties: false
                additionalProperties: false
        nextPageToken:
          oneOf:
            - type: string
              description: Token for fetching the next page of results
            - type: 'null'
    ComponentFilter:
      type: object
      properties:
        $and:
          type: array
          items:
            $ref: '#/components/schemas/ComponentFilter'
        $or:
          type: array
          items:
            $ref: '#/components/schemas/ComponentFilter'
        id:
          $ref: '#/components/schemas/NumberOperatorBlock'
        integrationId:
          $ref: '#/components/schemas/NumberOperatorBlock'
        uniqueIdentifier:
          $ref: '#/components/schemas/StringOperatorBlock'
        region:
          $ref: '#/components/schemas/StringOperatorBlock'
        vendor:
          $ref: '#/components/schemas/StringOperatorBlock'
        technology:
          $ref: '#/components/schemas/StringOperatorBlock'
        type:
          $ref: '#/components/schemas/StringOperatorBlock'
        version:
          $ref: '#/components/schemas/StringOperatorBlock'
        hasAvailableDraftts:
          $ref: '#/components/schemas/BooleanOperatorBlock'
        createdAt:
          $ref: '#/components/schemas/StringOperatorBlock'
        updatedAt:
          $ref: '#/components/schemas/StringOperatorBlock'
        tags$.*:
          $ref: '#/components/schemas/StringOperatorBlock'
        customTags$.*:
          $ref: '#/components/schemas/StringOperatorBlock'
      additionalProperties:
        oneOf:
          - $ref: '#/components/schemas/StringOperatorBlock'
          - not:
              type: object
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - error
    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
    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
    BooleanOperatorBlock:
      type: object
      properties:
        $eq:
          type: boolean
          description: Equals operator
        $ne:
          type: boolean
          description: Not equals 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

````