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

> Query certificates with filtering, sorting and pagination



## OpenAPI

````yaml https://api.draftt.io/swagger post /certificates/query
openapi: 3.1.0
info:
  title: Draftt API
  version: 0.2.1
servers:
  - url: https://api.draftt.io/v1
security:
  - BearerAuth: []
paths:
  /certificates/query:
    post:
      tags:
        - Certificate
      summary: Query certificates with filtering, sorting and pagination
      description: Query certificates with filtering, sorting and pagination
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CertificateQuery'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CertificateResponse'
        '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:
    CertificateQuery:
      type: object
      required:
        - orgId
      examples:
        - pageSize: 20
          filter:
            status:
              $eq: active
            expirationDate:
              $gte: '2024-12-22T13:47:25.036Z'
          sort:
            expirationDate: asc
          pageToken: >-
            eyJ1bmlxdWVGaWVsZE5hbWUiOiJpZCIsInNvcnQiOnsiZXhwaXJhdGlvbkRhdGUiOnsiZGlyZWN0aW9uIjoiYXNjIn19fQ==
        - filter:
            status:
              $eq: expiring
            domainName:
              $like: '*.example.com'
            expirationDate:
              $lte: '2025-03-01T00:00:00+00:00'
          sort:
            expirationDate: asc
      properties:
        filter:
          $ref: '#/components/schemas/CertificateFilter'
        select:
          type: array
          description: >-
            If empty - will return all fields, if passed will only return
            selected field
          items:
            type: string
            enum:
              - id
              - integrationId
              - uniqueIdentifier
              - type
              - status
              - issuer
              - keyAlgorithm
              - renewalEligibility
              - domainName
              - domains
              - inUseBy
              - created
              - issuedAt
              - validityStartDate
              - expirationDate
              - dueDate
              - details
              - createdAt
              - updatedAt
              - deletedAt
              - componentIds
        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
            type:
              type: string
              enum:
                - asc
                - desc
            status:
              type: string
              enum:
                - asc
                - desc
            issuer:
              type: string
              enum:
                - asc
                - desc
            keyAlgorithm:
              type: string
              enum:
                - asc
                - desc
            renewalEligibility:
              type: string
              enum:
                - asc
                - desc
            domainName:
              type: string
              enum:
                - asc
                - desc
            created:
              type: string
              enum:
                - asc
                - desc
            issuedAt:
              type: string
              enum:
                - asc
                - desc
            validityStartDate:
              type: string
              enum:
                - asc
                - desc
            expirationDate:
              type: string
              enum:
                - asc
                - desc
            dueDate:
              type: string
              enum:
                - asc
                - desc
            createdAt:
              type: string
              enum:
                - asc
                - desc
            updatedAt:
              type: string
              enum:
                - asc
                - desc
            deletedAt:
              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
    CertificateResponse:
      type: object
      required:
        - items
      example:
        nextPageToken: >-
          eyJ1bmlxdWVGaWVsZE5hbWUiOiJpZCIsInNvcnQiOnsiZXhwaXJhdGlvbkRhdGUiOnsiZGlyZWN0aW9uIjoiYXNjIn19fQ==
        items:
          - id: '12345'
            integrationId: '456'
            uniqueIdentifier: cert-prod-web-2024
            type: ssl
            status: active
            issuer: Let's Encrypt Authority X3
            keyAlgorithm: RSA
            renewalEligibility: eligible
            domainName: example.com
            domains:
              - example.com
              - www.example.com
              - api.example.com
            inUseBy:
              - web-server-1
              - load-balancer-2
            created: '2024-01-15T10:30:00.000Z'
            issuedAt: '2024-01-15T10:30:00.000Z'
            validityStartDate: '2024-01-15T10:30:00.000Z'
            expirationDate: '2024-04-15T10:30:00.000Z'
            dueDate: '2024-03-15T10:30:00.000Z'
            details:
              serialNumber: 03E7B2B58A6E8B9C4D2F1A0E5C7B8D6F
              signatureAlgorithm: SHA256withRSA
            createdAt: '2024-01-15T10:30:00.000Z'
            updatedAt: '2024-02-15T10:30:00.000Z'
            deletedAt: null
            componentIds:
              - 789
              - 1234
            displayType: SSL Certificate
      properties:
        items:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: int64
                description: Certificate ID
              integrationId:
                type: string
                format: int64
              uniqueIdentifier:
                type: string
              type:
                type: string
              displayType:
                type: string
              status:
                type: string
              issuer:
                type: string
              keyAlgorithm:
                type: string
              renewalEligibility:
                type: string
              domainName:
                type: string
              domains:
                type: array
                items:
                  type: string
              inUseBy:
                type: array
                items:
                  type: string
              created:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              issuedAt:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              validityStartDate:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              expirationDate:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              dueDate:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              details:
                type: object
                additionalProperties: true
              createdAt:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              updatedAt:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              deletedAt:
                oneOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              componentIds:
                type: array
                items:
                  type: number
        nextPageToken:
          oneOf:
            - type: string
              description: Token for fetching the next page of results
            - type: 'null'
    CertificateFilter:
      type: object
      properties:
        $and:
          type: array
          items:
            $ref: '#/components/schemas/CertificateFilter'
        $or:
          type: array
          items:
            $ref: '#/components/schemas/CertificateFilter'
        id:
          $ref: '#/components/schemas/NumberOperatorBlock'
        integrationId:
          $ref: '#/components/schemas/NumberOperatorBlock'
        uniqueIdentifier:
          $ref: '#/components/schemas/StringOperatorBlock'
        type:
          $ref: '#/components/schemas/StringOperatorBlock'
        status:
          $ref: '#/components/schemas/StringOperatorBlock'
        issuer:
          $ref: '#/components/schemas/StringOperatorBlock'
        keyAlgorithm:
          $ref: '#/components/schemas/StringOperatorBlock'
        renewalEligibility:
          $ref: '#/components/schemas/StringOperatorBlock'
        domainName:
          $ref: '#/components/schemas/StringOperatorBlock'
        created:
          $ref: '#/components/schemas/StringOperatorBlock'
        issuedAt:
          $ref: '#/components/schemas/StringOperatorBlock'
        validityStartDate:
          $ref: '#/components/schemas/StringOperatorBlock'
        expirationDate:
          $ref: '#/components/schemas/StringOperatorBlock'
        dueDate:
          $ref: '#/components/schemas/StringOperatorBlock'
        createdAt:
          $ref: '#/components/schemas/StringOperatorBlock'
        updatedAt:
          $ref: '#/components/schemas/StringOperatorBlock'
        deletedAt:
          $ref: '#/components/schemas/StringOperatorBlock'
    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
  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

````