Skip to main content

Code Health API

Octokraft continuously scores your codebase across 8 categories: security, runtime risks, test coverage, code smells, duplication, dead code, codebase consistency, and compliance. The Code Health API provides access to assessments, drift alerts, and the underlying analysis issues.

Get Health Dashboard

Returns the comprehensive health dashboard for a project, including the latest assessment, trend data, drift alerts, codebase dynamics, convention consistency, and test quality metrics.
curl "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/health" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."

List Assessments

Returns paginated assessment summaries for a project, ordered by creation date (newest first).
curl "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/health/assessments?limit=10&offset=0" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."

Get Assessment

Returns a full assessment by ID with all category scores and metrics.
curl "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/health/assessments/a1b2c3d4-5678-9abc-def0-111111111111" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."

Assessment Fields

FieldTypeDescription
overall_scorenumberWeighted average of all category scores (0-100)
overall_gradestringLetter grade: A, B, C, D, or F
*_scorenumberPer-category scores (0-100)
critical_countinfo_countintegerIssue counts by severity
total_lines_of_codeintegerTotal lines of code in the project
test_lines_of_codeintegerLines of test code
structural_coverage_pctnumberStructural test coverage percentage
trigger_typestringmanual, push, pr_merge, or scheduled
statusstringpending, running, completed, or failed

Trigger Assessment

Triggers a new health assessment. The assessment runs asynchronously.
curl -X POST "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/health/trigger" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."

List Drift Alerts

Returns drift alerts for a project. Drift alerts are generated when health scores change significantly between assessments.
curl "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/health/drift-alerts?limit=20&offset=0" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."

Drift Alert Fields

FieldTypeDescription
drift_typestringscore, coverage, convention, or churn
categorystringThe health category affected
previous_valuenumberValue from the previous assessment
current_valuenumberValue from the current assessment
changenumberDelta between assessments

Dismiss Drift Alert

Dismisses a drift alert so it no longer appears in active alerts.
curl -X POST "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/health/drift-alerts/d4e5f6a7-8901-2345-6789-444444444444/dismiss" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."

List Issues

Returns analysis issues for a project with optional filters. Issues are findings from static analyzers, AI analysis, graph rules, and convention checks.
curl "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/analysis/issues?severity=critical&category=security&limit=50&offset=0" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."

Query Parameters

ParameterTypeDescription
severitystringFilter by severity: critical, high, medium, low, info
severitiesstringComma-separated list of severities (OR filter)
categorystringFilter by category: security, runtime, testing, code_smell, dead_code, duplication, consistency, compliance
sourcestringFilter by source: static_analyzer, llm_agent, graph_rule, convention, architecture
is_dismissedbooleanFilter dismissed/active issues
context_typestringFilter by analysis context: pr_analysis, health_assessment, architecture_review, push
context_idstringFilter by specific analysis run context
sort_bystringSort by: severity, file_path, category, created_at
limitintegerItems per page50
offsetintegerNumber of items to skip0

Get Issue Statistics

Returns aggregate issue counts for a project, grouped by category, severity, and source.
curl "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/analysis/issues/stats" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."

Dismiss Issue

Dismisses an issue with an action and optional reason. Creates a dismiss rule to suppress future matches.
curl -X POST "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/analysis/issues/e5f6a7b8-9012-3456-7890-555555555555/dismiss" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..." \
  -H "Content-Type: application/json" \
  -d '{
    "action": "false_positive",
    "reason": "This key is loaded from env in production; the test fixture is fine."
  }'

Request Body

FieldTypeRequiredDescription
actionstringnodismiss, false_positive, or wont_fix. Defaults to dismiss.
reasonstringnoHuman-readable reason for dismissing

Restore Issue

Restores a previously dismissed issue back to active status.
curl -X POST "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/analysis/issues/e5f6a7b8-9012-3456-7890-555555555555/restore" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."

List Dismiss Rules

Returns all dismiss rules configured for a project. Dismiss rules automatically suppress matching issues.
curl "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/analysis/dismiss-rules" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."

Create Dismiss Rule

Creates a new dismiss rule that automatically suppresses matching issues.
curl -X POST "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/analysis/dismiss-rules" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..." \
  -H "Content-Type: application/json" \
  -d '{
    "rule_pattern": "no-unused-vars",
    "source_type": "static_analyzer",
    "scope": "file",
    "file_path": "src/generated/**",
    "action": "wont_fix",
    "reason": "Generated code has expected unused variables"
  }'

Request Body

FieldTypeRequiredDescription
rule_patternstringyesPattern to match against issue rule IDs or titles
source_typestringnoRestrict to a specific source: static_analyzer, llm_agent, graph_rule, convention, architecture
secondary_patternstringnoAdditional pattern for finer matching
scopestringnoglobal, project, or file. Defaults to global.
file_pathstringnoFile path or glob pattern (required when scope is file)
actionstringnodismiss, false_positive, or wont_fix. Defaults to dismiss.
reasonstringnoHuman-readable reason

Delete Dismiss Rule

Removes a dismiss rule. Previously suppressed issues will reappear as active.
curl -X DELETE "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/analysis/dismiss-rules/f6a7b8c9-0123-4567-8901-666666666666" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."
Returns 204 No Content on success.

List Health Categories

Returns metadata for all 8 health scoring categories.
curl "https://app.octokraft.com/api/v1/projects/b3d7f1a2-4e5c-6d8a-9b0c-1e2f3a4b5c6d/health/categories" \
  -H "Authorization: Bearer ok_live_a1b2c3d4e5f6..."