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

# Create AI agent review item writeback PR

> Open a writeback pull request for a review item (semantic-layer or
project-context root cause)



## OpenAPI

````yaml https://raw.githubusercontent.com/lightdash/lightdash/refs/heads/main/packages/backend/src/generated/swagger.json post /api/v1/aiAgents/admin/review-items/{fingerprint}/writeback
openapi: 3.0.0
info:
  title: Lightdash API
  version: 0.3249.0
  description: >
    Open API documentation for all public Lightdash API endpoints. #
    Authentication Before you get started, you might need to create a Personal
    Access Token to authenticate via the API. You can create a token by
    following this guide: https://docs.lightdash.com/references/personal_tokens
  license:
    name: MIT
  contact:
    name: Lightdash Support
    email: support@lightdash.com
    url: https://docs.lightdash.com/help-and-contact/contact/contact_info/
servers:
  - url: /
security: []
tags:
  - name: My Account
    description: These routes allow users to manage their own user account.
  - name: Organizations
    description: >-
      Each user is a member of a single organization. These routes allow users
      to manage their organization. Most actions are only available to admin
      users.
  - name: Projects
    description: >-
      Projects belong to a single organization. These routes allow users to
      manage their projects, browse content, and execute queries. Users inside
      an organization might have access to a project from an organization-level
      role or they might be granted access to a project directly.
  - name: Spaces
    description: >-
      Spaces allow you to organize charts and dashboards within a project. They
      also allow granular access to content by allowing you to create private
      spaces, which are only accessible to the creator and admins.
  - name: Roles & Permissions
    description: >-
      These routes allow users to manage roles and permissions for their
      organization.
    externalDocs:
      url: https://docs.lightdash.com/references/roles
  - name: Query
    description: >-
      These routes allow users to execute and manage queries against their data
      warehouse. This includes metric queries, SQL queries, and retrieving query
      results.
paths:
  /api/v1/aiAgents/admin/review-items/{fingerprint}/writeback:
    post:
      summary: Create AI agent review item writeback PR
      description: |-
        Open a writeback pull request for a review item (semantic-layer or
        project-context root cause)
      operationId: createAiAgentReviewItemWriteback
      parameters:
        - in: path
          name: fingerprint
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiAiAgentReviewItemResponse'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorPayload'
      security: []
components:
  schemas:
    ApiAiAgentReviewItemResponse:
      $ref: '#/components/schemas/ApiSuccess_AiAgentReviewItemSummary_'
    ApiErrorPayload:
      properties:
        error:
          properties:
            data:
              $ref: '#/components/schemas/AnyType'
              description: Optional data containing details of the error
            message:
              type: string
              description: A friendly message summarising the error
            name:
              type: string
              description: Unique name for the type of error
            statusCode:
              type: number
              format: integer
              description: HTTP status code
          required:
            - name
            - statusCode
          type: object
        status:
          type: string
          enum:
            - error
          nullable: false
      required:
        - error
        - status
      type: object
      description: |-
        The Error object is returned from the api any time there is an error.
        The message contains
    ApiSuccess_AiAgentReviewItemSummary_:
      properties:
        results:
          $ref: '#/components/schemas/AiAgentReviewItemSummary'
        status:
          type: string
          enum:
            - ok
          nullable: false
      required:
        - results
        - status
      type: object
    AnyType:
      description: |-
        This AnyType is an alias for any
        The goal is to make it easier to identify any type in the codebase
        without having to eslint-disable all the time
        These are only used on legacy `any` types, don't use it for new types.
        This is added on a separate file to avoid circular dependencies.
    AiAgentReviewItemSummary:
      allOf:
        - $ref: '#/components/schemas/AiAgentReviewItem'
        - properties:
            latestFinding:
              properties:
                createdAt:
                  type: string
                  format: date-time
                projectContextEntry:
                  allOf:
                    - $ref: '#/components/schemas/AiAgentJudgeProjectContextEntry'
                  nullable: true
                recommendation:
                  allOf:
                    - $ref: '#/components/schemas/AiAgentRecommendation'
                  nullable: true
                evidenceExcerpts:
                  items:
                    $ref: '#/components/schemas/AiAgentEvidenceExcerpt'
                  type: array
                targetRefs:
                  items:
                    $ref: '#/components/schemas/AiAgentTargetRef'
                  type: array
                fixTargets:
                  items:
                    $ref: '#/components/schemas/AiAgentFixTarget'
                  type: array
                subcategories:
                  items:
                    type: string
                  type: array
                agentUuid:
                  type: string
                projectUuid:
                  type: string
                threadUuid:
                  type: string
                promptUuid:
                  type: string
                uuid:
                  type: string
              required:
                - createdAt
                - projectContextEntry
                - recommendation
                - evidenceExcerpts
                - targetRefs
                - fixTargets
                - subcategories
                - agentUuid
                - projectUuid
                - threadUuid
                - promptUuid
                - uuid
              type: object
              nullable: true
            remediation:
              allOf:
                - $ref: '#/components/schemas/AiAgentReviewRemediation'
              nullable: true
            writebackEligibility:
              $ref: '#/components/schemas/AiAgentReviewItemWritebackEligibility'
            writebackEligible:
              type: boolean
              description: |-
                Legacy boolean kept for current clients. New clients should use
                writebackEligibility for the blocking reason and provider.
          required:
            - latestFinding
            - remediation
            - writebackEligibility
            - writebackEligible
          type: object
    AiAgentReviewItem:
      properties:
        updatedAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        boardPosition:
          type: number
          format: double
          nullable: true
        prWritebackMessage:
          type: string
          nullable: true
        prWritebackStatus:
          allOf:
            - $ref: '#/components/schemas/AiAgentReviewItemWritebackStatus'
          nullable: true
        prState:
          allOf:
            - $ref: '#/components/schemas/AiAgentReviewItemPrState'
          nullable: true
        linkedPrUrl:
          type: string
          nullable: true
        linkedIssueUrl:
          type: string
          nullable: true
        statusUpdatedByUserUuid:
          type: string
          nullable: true
        statusUpdatedAt:
          type: string
          format: date-time
        findingCount:
          type: number
          format: double
        lastSeenAt:
          type: string
          format: date-time
        firstSeenAt:
          type: string
          format: date-time
        assignedToUserUuid:
          type: string
          nullable: true
        ownerType:
          $ref: '#/components/schemas/AiAgentReviewItemOwnerType'
        dismissedReason:
          allOf:
            - $ref: '#/components/schemas/AiAgentReviewItemDismissedReason'
          nullable: true
        status:
          $ref: '#/components/schemas/AiAgentReviewItemStatus'
        primaryRootCause:
          $ref: '#/components/schemas/AiAgentRootCause'
        description:
          type: string
        title:
          type: string
        agentUuid:
          type: string
          nullable: true
        projectUuid:
          type: string
          nullable: true
        organizationUuid:
          type: string
        fingerprint:
          type: string
        uuid:
          type: string
      required:
        - updatedAt
        - createdAt
        - boardPosition
        - prWritebackMessage
        - prWritebackStatus
        - prState
        - linkedPrUrl
        - linkedIssueUrl
        - statusUpdatedByUserUuid
        - statusUpdatedAt
        - findingCount
        - lastSeenAt
        - firstSeenAt
        - assignedToUserUuid
        - ownerType
        - dismissedReason
        - status
        - primaryRootCause
        - description
        - title
        - agentUuid
        - projectUuid
        - organizationUuid
        - fingerprint
        - uuid
      type: object
    AiAgentJudgeProjectContextEntry:
      properties:
        objects:
          items:
            type: string
          type: array
        terms:
          items:
            type: string
          type: array
        content:
          type: string
        kind:
          type: string
          enum:
            - definition
            - context
        id:
          type: string
          nullable: true
        op:
          type: string
          enum:
            - create
            - update
      required:
        - objects
        - terms
        - content
        - kind
        - id
        - op
      type: object
    AiAgentRecommendation:
      properties:
        targetRefs:
          items:
            $ref: '#/components/schemas/AiAgentTargetRef'
          type: array
        rationale:
          type: string
        title:
          type: string
        actionType:
          $ref: '#/components/schemas/AiAgentRecommendationAction'
      required:
        - targetRefs
        - rationale
        - title
        - actionType
      type: object
    AiAgentEvidenceExcerpt:
      properties:
        redacted:
          type: boolean
        text:
          type: string
        source:
          type: string
          enum:
            - user_prompt
            - assistant_answer
            - next_user_prompt
            - conversation_context
            - tool_call
            - tool_result
            - agent_config
      required:
        - redacted
        - text
        - source
      type: object
    AiAgentTargetRef:
      anyOf:
        - $ref: '#/components/schemas/AiAgentSemanticTargetRef'
        - properties:
            agentUuid:
              type: string
            type:
              type: string
              enum:
                - agent
              nullable: false
          required:
            - agentUuid
            - type
          type: object
        - properties:
            setting:
              $ref: '#/components/schemas/AiAgentConfigurationSetting'
            type:
              type: string
              enum:
                - agent_config
              nullable: false
          required:
            - setting
            - type
          type: object
        - properties:
            capabilityKey:
              type: string
            type:
              type: string
              enum:
                - product_capability
              nullable: false
          required:
            - capabilityKey
            - type
          type: object
        - properties:
            key:
              type: string
            type:
              type: string
              enum:
                - runtime
              nullable: false
          required:
            - key
            - type
          type: object
    AiAgentFixTarget:
      type: string
      enum:
        - semantic_yaml_patch
        - project_context_rule
        - agent_configuration_change
        - dbt_modeling_ticket
        - semantic_layer_ticket
        - product_capability_ticket
        - runtime_reliability_ticket
        - feedback_needed
        - no_action
    AiAgentReviewRemediation:
      properties:
        updatedAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        resolvedAt:
          type: string
          format: date-time
          nullable: true
        resolvedByUserUuid:
          type: string
          nullable: true
        createdByUserUuid:
          type: string
          nullable: true
        retryPrompt:
          type: string
          nullable: true
        errorMessage:
          type: string
          nullable: true
        status:
          $ref: '#/components/schemas/AiAgentReviewRemediationStatus'
        previewThreadUuid:
          type: string
          nullable: true
        previewAgentUuid:
          type: string
          nullable: true
        previewProjectUuid:
          type: string
          nullable: true
        linkedPrUrl:
          type: string
          nullable: true
        pullRequestUuid:
          type: string
          nullable: true
        workThreadUuid:
          type: string
          nullable: true
        sourceAgentUuid:
          type: string
        sourceProjectUuid:
          type: string
        sourceThreadUuid:
          type: string
        sourcePromptUuid:
          type: string
        sourceFindingUuid:
          type: string
        organizationUuid:
          type: string
        fingerprint:
          type: string
        uuid:
          type: string
      required:
        - updatedAt
        - createdAt
        - resolvedAt
        - resolvedByUserUuid
        - createdByUserUuid
        - retryPrompt
        - errorMessage
        - status
        - previewThreadUuid
        - previewAgentUuid
        - previewProjectUuid
        - linkedPrUrl
        - pullRequestUuid
        - workThreadUuid
        - sourceAgentUuid
        - sourceProjectUuid
        - sourceThreadUuid
        - sourcePromptUuid
        - sourceFindingUuid
        - organizationUuid
        - fingerprint
        - uuid
      type: object
    AiAgentReviewItemWritebackEligibility:
      anyOf:
        - properties:
            reason:
              type: number
              enum:
                - null
              nullable: true
            strategy:
              $ref: '#/components/schemas/AiAgentReviewItemWritebackStrategy'
            provider:
              $ref: '#/components/schemas/PullRequestProvider'
            eligible:
              type: boolean
              enum:
                - true
              nullable: false
          required:
            - reason
            - strategy
            - provider
            - eligible
          type: object
        - properties:
            reason:
              $ref: '#/components/schemas/AiAgentReviewItemWritebackBlockedReason'
            strategy:
              allOf:
                - $ref: '#/components/schemas/AiAgentReviewItemWritebackStrategy'
              nullable: true
            provider:
              allOf:
                - $ref: '#/components/schemas/PullRequestProvider'
              nullable: true
            eligible:
              type: boolean
              enum:
                - false
              nullable: false
          required:
            - reason
            - strategy
            - provider
            - eligible
          type: object
    AiAgentReviewItemWritebackStatus:
      type: string
      enum:
        - queued
        - running
        - completed
        - failed
    AiAgentReviewItemPrState:
      type: string
      enum:
        - open
        - merged
        - closed
    AiAgentReviewItemOwnerType:
      type: string
      enum:
        - semantic_layer_owner
        - agent_admin
        - product
        - support
        - unknown
    AiAgentReviewItemDismissedReason:
      type: string
      enum:
        - not_actionable
        - expected_behavior
        - duplicate
        - low_confidence
        - other
    AiAgentReviewItemStatus:
      type: string
      enum:
        - triage
        - open
        - in_progress
        - resolved
        - dismissed
        - duplicate
    AiAgentRootCause:
      type: string
      enum:
        - semantic_layer
        - project_context
        - agent_configuration
        - product_capability
        - runtime_reliability
        - feedback_quality
        - not_a_failure
        - ambiguous
    AiAgentRecommendationAction:
      type: string
      enum:
        - update_semantic_yaml
        - update_agent_instructions
        - add_knowledge_document
        - enable_data_access
        - enable_sql_mode
        - enable_self_improvement
        - configure_mcp_server
        - adjust_explore_tags
        - update_access
        - route_to_product_work
        - request_more_evidence
        - no_action
    AiAgentSemanticTargetRef:
      anyOf:
        - properties:
            modelName:
              type: string
            type:
              type: string
              enum:
                - model
              nullable: false
          required:
            - modelName
            - type
          type: object
        - properties:
            exploreName:
              type: string
            modelName:
              type: string
            type:
              type: string
              enum:
                - explore
              nullable: false
          required:
            - exploreName
            - modelName
            - type
          type: object
        - properties:
            exploreName:
              type: string
            joinName:
              type: string
            modelName:
              type: string
            type:
              type: string
              enum:
                - join
              nullable: false
          required:
            - joinName
            - modelName
            - type
          type: object
        - properties:
            dimensionName:
              type: string
            modelName:
              type: string
            type:
              type: string
              enum:
                - dimension
              nullable: false
          required:
            - dimensionName
            - modelName
            - type
          type: object
        - properties:
            dimensionName:
              type: string
            metricName:
              type: string
            modelName:
              type: string
            type:
              type: string
              enum:
                - metric
              nullable: false
          required:
            - metricName
            - modelName
            - type
          type: object
        - properties:
            dimensionName:
              type: string
            parentDimensionName:
              type: string
            modelName:
              type: string
            type:
              type: string
              enum:
                - additional_dimension
              nullable: false
          required:
            - dimensionName
            - parentDimensionName
            - modelName
            - type
          type: object
        - properties:
            fieldName:
              type: string
            exploreName:
              type: string
            modelName:
              type: string
            type:
              type: string
              enum:
                - required_filter
              nullable: false
          required:
            - fieldName
            - exploreName
            - modelName
            - type
          type: object
        - properties:
            targetName:
              type: string
            targetType:
              type: string
              enum:
                - model
                - dimension
                - metric
            modelName:
              type: string
            type:
              type: string
              enum:
                - ai_hint
              nullable: false
          required:
            - targetName
            - targetType
            - modelName
            - type
          type: object
    AiAgentConfigurationSetting:
      type: string
      enum:
        - instructions
        - knowledge_documents
        - data_access
        - self_improvement
        - sql_mode
        - mcp_servers
        - explore_tags
        - space_access
        - user_or_group_access
        - unknown
    AiAgentReviewRemediationStatus:
      type: string
      enum:
        - queued
        - running
        - pr_open
        - preview_ready
        - resolved
        - failed
    AiAgentReviewItemWritebackStrategy:
      type: string
      enum:
        - semantic_layer
        - project_context
    PullRequestProvider:
      enum:
        - github
        - gitlab
      type: string
    AiAgentReviewItemWritebackBlockedReason:
      type: string
      enum:
        - reviews_disabled
        - unsupported_root_cause
        - missing_project
        - missing_project_context_entry
        - project_context_disabled
        - unsupported_source_control
        - git_app_not_installed
        - missing_writeback_config
        - pull_request_open
        - source_thread_writeback_exists
        - terminal_state
        - writeback_in_progress

````