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

# Validate BRK

> Validates a BRK to ensure it is properly structured

This endpoint validates a BRK to ensure it is properly structured and can be executed. It checks the BRK's schema, prompt templates, dependencies, and configuration parameters. It does not execute the BRK, but only verifies that it is valid. You must have at least editor permissions for the BRK to validate it.

## Request

<ParamField body="brxId" type="string" required>
  The ID of the BRK to validate
</ParamField>

### Example Request

```json theme={null}
{
  "brxId": "brk-12345678-90ab-cdef-1234-567890abcdef"
}
```

## Response

<ResponseField name="validateBrxResponse" type="object">
  <Expandable title="properties">
    <ResponseField name="httpResponse" type="object">
      <Expandable title="properties">
        <ResponseField name="isError" type="boolean">
          Indicates whether the request resulted in an error
        </ResponseField>

        <ResponseField name="statusMsg" type="string">
          A message describing the status of the request
        </ResponseField>

        <ResponseField name="isValid" type="boolean">
          Indicates whether the BRK is valid
        </ResponseField>

        <ResponseField name="validationResults" type="object">
          Detailed validation results for each component of the BRK

          <Expandable title="properties">
            <ResponseField name="schema" type="object">
              Validation results for the BRK schema

              <Expandable title="properties">
                <ResponseField name="isValid" type="boolean">
                  Indicates whether the schema is valid
                </ResponseField>

                <ResponseField name="errors" type="array">
                  Array of schema validation errors
                </ResponseField>
              </Expandable>
            </ResponseField>

            <ResponseField name="prompt" type="object">
              Validation results for the BRK prompt templates

              <Expandable title="properties">
                <ResponseField name="isValid" type="boolean">
                  Indicates whether the prompt templates are valid
                </ResponseField>

                <ResponseField name="errors" type="array">
                  Array of prompt template validation errors
                </ResponseField>
              </Expandable>
            </ResponseField>

            <ResponseField name="dependencies" type="object">
              Validation results for the BRK dependencies

              <Expandable title="properties">
                <ResponseField name="isValid" type="boolean">
                  Indicates whether the dependencies are valid
                </ResponseField>

                <ResponseField name="errors" type="array">
                  Array of dependency validation errors
                </ResponseField>
              </Expandable>
            </ResponseField>

            <ResponseField name="configuration" type="object">
              Validation results for the BRK configuration parameters

              <Expandable title="properties">
                <ResponseField name="isValid" type="boolean">
                  Indicates whether the configuration parameters are valid
                </ResponseField>

                <ResponseField name="errors" type="array">
                  Array of configuration parameter validation errors
                </ResponseField>
              </Expandable>
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

### Example Response (Valid BRK)

```json theme={null}
{
  "validateBrxResponse": {
    "httpResponse": {
      "isError": false,
      "statusMsg": "BRK validated successfully",
      "isValid": true,
      "validationResults": {
        "schema": {
          "isValid": true,
          "errors": []
        },
        "prompt": {
          "isValid": true,
          "errors": []
        },
        "dependencies": {
          "isValid": true,
          "errors": []
        },
        "configuration": {
          "isValid": true,
          "errors": []
        }
      }
    }
  }
}
```

### Example Response (Invalid BRK)

```json theme={null}
{
  "validateBrxResponse": {
    "httpResponse": {
      "isError": false,
      "statusMsg": "BRK validation failed",
      "isValid": false,
      "validationResults": {
        "schema": {
          "isValid": true,
          "errors": []
        },
        "prompt": {
          "isValid": false,
          "errors": [
            "Prompt template contains undefined variable: {{undefined_variable}}"
          ]
        },
        "dependencies": {
          "isValid": false,
          "errors": [
            "Dependency 'main_brx_entry_schema' references a non-existent BRK: brk-abcdef12-3456-7890-abcd-ef1234567890"
          ]
        },
        "configuration": {
          "isValid": true,
          "errors": []
        }
      }
    }
  }
}
```

## Error Codes

<ResponseField name="400" type="object">
  Bad Request - The request was malformed or missing required parameters
</ResponseField>

<ResponseField name="401" type="object">
  Unauthorized - Authentication credentials are missing or invalid
</ResponseField>

<ResponseField name="403" type="object">
  Forbidden - The authenticated user does not have permission to validate the requested BRK
</ResponseField>

<ResponseField name="404" type="object">
  Not Found - The requested BRK does not exist
</ResponseField>

<ResponseField name="500" type="object">
  Internal Server Error - An unexpected error occurred on the server
</ResponseField>

## Notes

* This endpoint is useful for checking if a BRK is valid before attempting to execute it.
* The validation checks include:
  * Schema validation: Ensures that the BRK's schema is properly structured and all required fields are present.
  * Prompt template validation: Ensures that all variables used in prompt templates are defined in the schema.
  * Dependency validation: Ensures that all referenced BRKs exist and are accessible.
  * Configuration validation: Ensures that all configuration parameters are valid.
* The response includes detailed validation results for each component of the BRK, including any errors that were found.
* A BRK is considered valid only if all components are valid (i.e., `isValid` is `true` for all components).
