> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kosli.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an evaluation

> **Beta** — the Server-side evaluation feature is in beta. Requests from organizations without it enabled receive `403 Forbidden`.



## OpenAPI

````yaml https://app.kosli.com/api/v2/openapi.json post /evaluations/{org}
openapi: 3.1.0
info:
  title: Kosli API
  summary: The API for communicating with Kosli
  description: >

    # Authentication 


    When making requests against Kosli API, you can authenticate your requests
    using a bearer token. 

    Set the bearer token in the request Authorization header to a valid API
    key. 

    API Keys can be personal or for service accounts. Check the [service
    accounts
    documentation](https://docs.kosli.com/getting_started/service-accounts/) for
    details. 


    ## Curl example


    ```shell

    curl -H "Authorization: Bearer <<your-api-key>>"
    https://app.kosli.com/api/v2/environments/<<your-org-name>>

    ```
  version: '2.0'
servers:
  - url: https://app.kosli.com/api/v2
    description: EU
  - url: https://app.us.kosli.com/api/v2
    description: US
security:
  - HTTPBearer: []
paths:
  /evaluations/{org}:
    post:
      tags:
        - Evaluations
      summary: Create an evaluation
      description: >-
        **Beta** — the Server-side evaluation feature is in beta. Requests from
        organizations without it enabled receive `403 Forbidden`.
      operationId: create_evaluation
      parameters:
        - name: org
          in: path
          required: true
          schema:
            type: string
            title: Org
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EvaluationPostInput'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EvaluationResponse'
        '400':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/fastapi_app__errors__ValidationErrorResponse___locals___ValidationErrorResponseModel__13
          description: Bad Request
        '403':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/fastapi_app__errors__ForbiddenResponse___locals___ForbiddenResponseModel__16
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/fastapi_app__errors__NotFoundResponse___locals___NotFoundResponseModel__53
          description: Not Found
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceUnavailableResponseModel'
          description: Service Unavailable
      security:
        - HTTPBearer: []
        - HTTPBasic: []
components:
  schemas:
    EvaluationPostInput:
      properties:
        context:
          $ref: '#/components/schemas/EvaluationContextInput'
        policy:
          $ref: '#/components/schemas/InlinePolicyInput'
        params:
          additionalProperties: true
          type: object
          title: Params
          description: Values the policy reads as `data.params`, not enforced against it
      additionalProperties: false
      type: object
      required:
        - context
        - policy
      title: EvaluationPostInput
    EvaluationResponse:
      properties:
        id:
          type: string
          title: Id
          description: Server-minted id of the evaluation
        status:
          $ref: '#/components/schemas/EvaluationStatus'
          description: >-
            Whether the evaluation has run, and if so whether it recorded a
            result or an error
        requested_at:
          type: number
          title: Requested At
          description: When the evaluation was asked for
        recorded_at:
          type: number
          title: Recorded At
          description: >-
            The instant on the recorded-time axis that every trail in the
            context resolves at
        result:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Result
          description: The policy's output, present only when `completed`
        error:
          anyOf:
            - $ref: '#/components/schemas/EvaluationErrorResponse'
            - type: 'null'
          description: Why the evaluation failed, present only when `failed`
      type: object
      required:
        - id
        - status
        - requested_at
        - recorded_at
      title: EvaluationResponse
    fastapi_app__errors__ValidationErrorResponse___locals___ValidationErrorResponseModel__13:
      properties:
        message:
          type: string
          title: Message
          description: Error message
        errors:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Errors
          description: Validation errors by field
      type: object
      required:
        - message
      title: ValidationErrorResponseModel
      examples:
        - errors:
            email: Field must be a valid email address
            name: Field cannot be empty
          message: Input payload validation failed
    fastapi_app__errors__ForbiddenResponse___locals___ForbiddenResponseModel__16:
      properties:
        message:
          type: string
          title: Message
          description: Error message
        errors:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Errors
          description: Validation errors by field
      type: object
      required:
        - message
      title: ForbiddenResponseModel
      examples:
        - message: You don't have permission to access this resource
    fastapi_app__errors__NotFoundResponse___locals___NotFoundResponseModel__53:
      properties:
        message:
          type: string
          title: Message
          description: Error message
        errors:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Errors
          description: Validation errors by field
      type: object
      required:
        - message
      title: NotFoundResponseModel
      description: Trail not found
      examples:
        - message: Trail not found
    ServiceUnavailableResponseModel:
      properties:
        message:
          type: string
          title: Message
          description: Error message
        errors:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Errors
          description: Validation errors by field
      type: object
      required:
        - message
      title: ServiceUnavailableResponseModel
      description: Service Unavailable
      examples:
        - message: Database temporarily unavailable; retry the request.
    EvaluationContextInput:
      properties:
        trails:
          items:
            $ref: '#/components/schemas/TrailReferenceInput'
          type: array
          maxItems: 100
          minItems: 1
          title: Trails
          description: The trails to evaluate, all resolved at one instant
      additionalProperties: false
      type: object
      required:
        - trails
      title: EvaluationContextInput
    InlinePolicyInput:
      properties:
        files:
          additionalProperties:
            type: string
          type: object
          maxProperties: 100
          minProperties: 1
          title: Files
          description: Rego bundle as relative path to source; a single file is one entry
      additionalProperties: false
      type: object
      required:
        - files
      title: InlinePolicyInput
    EvaluationStatus:
      type: string
      enum:
        - pending
        - completed
        - failed
      title: EvaluationStatus
    EvaluationErrorResponse:
      properties:
        kind:
          type: string
          title: Kind
          description: >-
            Classification of the failure, distinguishing a broken policy from a
            fault on our side
        message:
          type: string
          title: Message
          description: Human-readable detail of the failure
          default: ''
      type: object
      required:
        - kind
      title: EvaluationErrorResponse
    TrailReferenceInput:
      properties:
        flow:
          type: string
          pattern: ^[a-zA-Z0-9][a-zA-Z0-9\.\-_~]*$
          title: Flow
          description: Name of the flow the trail belongs to
        trail:
          type: string
          pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_.~]*$
          title: Trail
          description: Name of the trail to evaluate
      additionalProperties: false
      type: object
      required:
        - flow
        - trail
      title: TrailReferenceInput
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````