API Reference

The Code Baseline API enables programmatic access to all platform features. Build custom integrations, automate workflows, and embed code health data into your tools.

Base URL: https://api.codebaseline.tech/v1

Authentication

All API requests require authentication using an API key. Include your key in the Authorization header:

Request Header
Authorization: Bearer YOUR_API_KEY
GET /health

Get the overall health score for your organization or a specific repository.

Query Parameters
Parameter Type Description
repo string Repository slug (optional, returns org-wide if omitted)
branch string Branch name (default: main)
Response 200 OK
{ "score": 94.2, "trend": "+2.4%", "metrics": { "complexity": 88, "duplication": 96, "test_coverage": 92, "security": 100 }, "updated_at": "2024-12-25T10:30:00Z" }
GET /repos

List all monitored repositories in your organization.

Response 200 OK
{ "repos": [ { "id": "repo_abc123", "name": "core-api", "health_score": 94, "last_scan": "2024-12-25T08:00:00Z" }, { "id": "repo_def456", "name": "web-app", "health_score": 87, "last_scan": "2024-12-25T08:15:00Z" } ], "total": 247 }
POST /baselines

Create a new baseline snapshot for a repository.

Request Body
Parameter Type Description
repo required string Repository slug
branch string Branch name (default: main)
name string Optional baseline name
Response 201 Created
{ "id": "baseline_xyz789", "repo": "core-api", "branch": "main", "created_at": "2024-12-25T10:45:00Z", "metrics": { ... } }
POST /impact/analyze

Analyze the potential impact of changes in a branch before merging.

Request Body
Parameter Type Description
repo required string Repository slug
branch required string Feature branch to analyze
base string Base branch to compare against (default: main)
Response 200 OK
{ "risk_level": "medium", "score_delta": -1.2, "affected_files": 23, "downstream_deps": ["web-app", "mobile-api"], "recommendations": [ "Add tests for new authentication flow", "Consider breaking up large commit" ] }