> ## Documentation Index
> Fetch the complete documentation index at: https://humanity-eaeda8f6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Evaluate a query against the authenticated user's credentials

> Evaluate a query against the authenticated user's credentials.
This endpoint allows declarative queries to check user claims.



## OpenAPI

````yaml api-reference/openapi.json post /queries/evaluate
openapi: 3.1.0
info:
  version: 0.1.0
  title: hp-public-dev-api-server
  description: NestJS CQRS + TDD base for Humanity Public Dev API
servers:
  - url: https://api.sandbox.humanity.org/v2
    description: Sandbox environment for development and testing
  - url: https://api.humanity.org/v2
    description: Production environment
security: []
tags: []
paths:
  /queries/evaluate:
    post:
      tags: []
      summary: Evaluate a query against the authenticated user's credentials
      description: |-
        Evaluate a query against the authenticated user's credentials.
        This endpoint allows declarative queries to check user claims.
      parameters: []
      requestBody:
        description: The query to evaluate
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryEvaluateRequest'
        required: true
      responses:
        '200':
          description: Query evaluation result
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/PredicateEvaluateResponse'
                  - $ref: '#/components/schemas/ProjectionEvaluateResponse'
                discriminator:
                  propertyName: type
                  mapping:
                    predicate: '#/components/schemas/PredicateEvaluateResponse'
                    projection: '#/components/schemas/ProjectionEvaluateResponse'
components:
  schemas:
    QueryEvaluateRequest:
      type: object
      properties:
        query:
          oneOf:
            - type: object
              properties:
                check:
                  type: object
                  properties:
                    claim:
                      type: string
                    operator:
                      oneOf:
                        - const: '=='
                        - const: '!='
                        - const: '>'
                        - const: '>='
                        - const: <
                        - const: <=
                        - const: in
                        - const: notIn
                        - const: contains
                        - const: isDefined
                        - const: startsWith
                        - const: matchRegex
                    value: {}
                  required:
                    - claim
                    - operator
              required:
                - check
            - $ref: '#/components/schemas/__type.o2'
            - type: object
              properties:
                projections:
                  type: array
                  items:
                    type: object
                    properties:
                      claim:
                        type: string
                      lens:
                        oneOf:
                          - const: pluck
                          - const: pick
                          - const: at
                    required:
                      - claim
                      - lens
              required:
                - projections
          description: The query to evaluate. Can be a simple check or compound policy.
      required:
        - query
      description: Request body for query evaluation.
    PredicateEvaluateResponse:
      type: object
      properties:
        type:
          const: predicate
        passed:
          type: boolean
          description: Whether the query passed.
        evaluatedAt:
          type: string
          description: Timestamp when the query was evaluated.
        evidence:
          type: object
          properties:
            claimsUsed:
              type: array
              items:
                type: object
                properties:
                  path:
                    type: string
                  value: {}
                  credentialId:
                    type: string
                  source:
                    type: string
                required:
                  - path
                  - value
            checkResults:
              type: array
              items:
                type: object
                properties:
                  claim:
                    type: string
                  operator:
                    type: string
                  expectedValue: {}
                  actualValue: {}
                  passed:
                    type: boolean
                required:
                  - claim
                  - operator
                  - expectedValue
                  - actualValue
                  - passed
          required:
            - claimsUsed
            - checkResults
          description: Evidence collected during evaluation.
        expiresAt:
          type: string
          description: Earliest credential expiry date (if any).
      required:
        - type
        - passed
        - evaluatedAt
        - evidence
      description: Response from predicate query evaluation.
    ProjectionEvaluateResponse:
      type: object
      properties:
        type:
          const: projection
        data:
          $ref: '#/components/schemas/Recordstringunknown'
          description: Extracted data from the projection query.
        evaluatedAt:
          type: string
          description: Timestamp when the query was evaluated.
        claimsUsed:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              value: {}
              credentialId:
                type: string
              source:
                type: string
            required:
              - path
              - value
          description: Claims used during evaluation.
        expiresAt:
          type: string
          description: Earliest credential expiry date (if any).
      required:
        - type
        - data
        - evaluatedAt
        - claimsUsed
      description: Response from projection query evaluation.
    __type.o2:
      type: object
      properties:
        policy:
          $ref: '#/components/schemas/PredicatePolicy'
      required:
        - policy
    Recordstringunknown:
      type: object
      properties: {}
      required: []
      description: Construct a type with a set of properties K of type T
      additionalProperties: {}
    PredicatePolicy:
      type: object
      properties:
        allOf:
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  check:
                    type: object
                    properties:
                      claim:
                        type: string
                      operator:
                        oneOf:
                          - const: '=='
                          - const: '!='
                          - const: '>'
                          - const: '>='
                          - const: <
                          - const: <=
                          - const: in
                          - const: notIn
                          - const: contains
                          - const: isDefined
                          - const: startsWith
                          - const: matchRegex
                      value: {}
                    required:
                      - claim
                      - operator
                required:
                  - check
              - $ref: '#/components/schemas/__type.o2'
        anyOf:
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  check:
                    type: object
                    properties:
                      claim:
                        type: string
                      operator:
                        oneOf:
                          - const: '=='
                          - const: '!='
                          - const: '>'
                          - const: '>='
                          - const: <
                          - const: <=
                          - const: in
                          - const: notIn
                          - const: contains
                          - const: isDefined
                          - const: startsWith
                          - const: matchRegex
                      value: {}
                    required:
                      - claim
                      - operator
                required:
                  - check
              - $ref: '#/components/schemas/__type.o2'
        not:
          oneOf:
            - type: object
              properties:
                check:
                  type: object
                  properties:
                    claim:
                      type: string
                    operator:
                      oneOf:
                        - const: '=='
                        - const: '!='
                        - const: '>'
                        - const: '>='
                        - const: <
                        - const: <=
                        - const: in
                        - const: notIn
                        - const: contains
                        - const: isDefined
                        - const: startsWith
                        - const: matchRegex
                    value: {}
                  required:
                    - claim
                    - operator
              required:
                - check
            - $ref: '#/components/schemas/__type.o2'
      required: []
      description: Forward declaration for recursive predicate policy schema.

````