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

# Configure Custom Scoring

<Warning>
  Legacy Dataset, Evaluation, and Report endpoints are deprecated for new workflows. Use the [Tables API](/reference/tables-create) for new dataset import, evaluation, scoring, recalculation, and reporting workflows.
</Warning>

Configure the score card for an evaluation pipeline. Use this endpoint to choose the columns that contribute to the score and, optionally, provide custom Python or JavaScript scoring code.

## Behavior Notes

* Custom code receives a `data` variable containing evaluation rows and must return an object with at least a `score` key from 0 to 100.
* If no custom code is provided, PromptLayer uses default scoring over the selected columns.
* Updating a blueprint affects future runs; completed runs recalculate their score after the score card changes.

## Related

* [Create Evaluation Pipeline](/reference/create-reports)
* [Score Card](/features/evaluations/score-card)
* [Node & Column Types](/features/evaluations/column-types)


## OpenAPI

````yaml PATCH /reports/{report_id}/score-card
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /reports/{report_id}/score-card:
    patch:
      tags:
        - reports
      summary: Configure Custom Scoring
      operationId: updateReportScoreCard
      parameters:
        - name: report_id
          in: path
          required: true
          schema:
            type: integer
          description: ID of the evaluation pipeline to update.
      requestBody:
        required: true
        description: Score-card configuration payload.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateReportScoreCardRequest'
            examples:
              weighted:
                summary: Weighted scoring
                value:
                  column_names:
                    - Accuracy Check
                    - Style Check
                  code: >-
                    weights = {"Accuracy Check": 0.7, "Style Check": 0.3}

                    total_weight = weighted_sum = 0

                    for row in data:
                        for col_name, weight in weights.items():
                            if col_name in row and isinstance(row[col_name], bool):
                                total_weight += weight
                                if row[col_name]:
                                    weighted_sum += weight
                    score = (weighted_sum / total_weight * 100) if total_weight
                    > 0 else 0

                    return {"score": score}
                  code_language: PYTHON
              allMustPass:
                summary: All checks must pass
                value:
                  column_names:
                    - Accuracy Check
                    - Safety Check
                    - Format Check
                  code: >-
                    check_columns = ["Accuracy Check", "Safety Check", "Format
                    Check"]

                    passed_rows = 0

                    for row in data:
                        if all(row.get(col) == True for col in check_columns if col in row):
                            passed_rows += 1
                    score = (passed_rows / len(data) * 100) if data else 0

                    return {"score": score}
                  code_language: PYTHON
      responses:
        '200':
          description: Score card updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateReportScoreCardResponse'
              examples:
                updated:
                  summary: Score card updated
                  value:
                    success: true
                    report:
                      id: 456
                      name: My Evaluation Pipeline
                      score_configuration:
                        code: 'return {"score": 85.5}'
                        code_language: PYTHON
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    UpdateReportScoreCardRequest:
      type: object
      title: UpdateReportScoreCardRequest
      required:
        - column_names
      properties:
        column_names:
          type: array
          items:
            type: string
          description: Column names to include in the score calculation.
        code:
          type: string
          nullable: true
          description: >-
            Optional custom Python or JavaScript scoring code. The code receives
            data and must return an object with a score key.
        code_language:
          type: string
          enum:
            - PYTHON
            - JAVASCRIPT
          default: PYTHON
          description: Language used by the custom scoring code.
    UpdateReportScoreCardResponse:
      type: object
      title: UpdateReportScoreCardResponse
      required:
        - success
        - report
      properties:
        success:
          type: boolean
          enum:
            - true
        report:
          $ref: '#/components/schemas/EvaluationPipelineSummary'
    EvaluationPipelineSummary:
      type: object
      title: EvaluationPipelineSummary
      additionalProperties: true
      properties:
        id:
          type: integer
        name:
          type: string
        tags:
          type: array
          items:
            type: string
        score_configuration:
          anyOf:
            - $ref: '#/components/schemas/ScoreConfiguration'
            - type: 'null'
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          default: false
          description: Indicates that the request failed.
        message:
          type: string
          description: Human-readable error message.
        error:
          type: string
          description: Machine-readable or fallback error message.
      additionalProperties: true
      description: >-
        Standard error response. Some legacy endpoints may return either message
        or error.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ScoreConfiguration:
      type: object
      title: ScoreConfiguration
      description: >-
        Custom scoring configuration. The code receives a data variable
        containing row dictionaries and must return an object with at least a
        score key from 0 to 100.
      required:
        - code
      properties:
        code:
          type: string
          description: Python or JavaScript code used to calculate the score.
        code_language:
          type: string
          enum:
            - PYTHON
            - JAVASCRIPT
          default: PYTHON
          description: Language used by the scoring code.
      example:
        code: >-
          score = sum(1 for row in data if row.get("Accuracy Check") is True) /
          len(data) * 100 if data else 0

          return {"score": score}
        code_language: PYTHON
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  responses:
    UnauthorizedError:
      description: Unauthorized - missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFoundError:
      description: Not found - requested resource does not exist or is not accessible.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error - request parameters or body are invalid.
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/HTTPValidationError'
              - $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````