|
| 1 | +# Content Quality Scoring API Reference |
| 2 | + |
| 3 | +**Version:** 1.0.0 |
| 4 | +**Base URL:** `/api/v1/quality` |
| 5 | +**Added:** 2026-03-16 |
| 6 | + |
| 7 | +All endpoints require Sanctum authentication. Permission `content.view` is required |
| 8 | +for read operations; `settings.manage` is required for config updates. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## Endpoints |
| 13 | + |
| 14 | +### 1. GET /api/v1/quality/scores |
| 15 | + |
| 16 | +List quality scores for a space, optionally filtered by content item. |
| 17 | + |
| 18 | +**Query parameters:** |
| 19 | + |
| 20 | +| Parameter | Type | Required | Description | |
| 21 | +|-----------|------|----------|-------------| |
| 22 | +| `space_id` | string (ULID) | ✅ | Space to filter by | |
| 23 | +| `content_id` | string (ULID) | ❌ | Filter to specific content item | |
| 24 | +| `per_page` | integer (1–100) | ❌ | Scores per page (default: 20) | |
| 25 | + |
| 26 | +**Response:** |
| 27 | +```json |
| 28 | +{ |
| 29 | + "data": [ |
| 30 | + { |
| 31 | + "id": "01J...", |
| 32 | + "space_id": "01J...", |
| 33 | + "content_id": "01J...", |
| 34 | + "content_version_id": "01J...", |
| 35 | + "overall_score": 82.5, |
| 36 | + "dimensions": { |
| 37 | + "readability": 88.0, |
| 38 | + "seo": 79.0, |
| 39 | + "brand": 85.0, |
| 40 | + "factual": 91.0, |
| 41 | + "engagement": 70.0 |
| 42 | + }, |
| 43 | + "scoring_model": "content-quality-v1", |
| 44 | + "scoring_duration_ms": 1240, |
| 45 | + "scored_at": "2026-03-16T10:00:00Z", |
| 46 | + "items": [] |
| 47 | + } |
| 48 | + ], |
| 49 | + "links": {...}, |
| 50 | + "meta": {...} |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +### 2. GET /api/v1/quality/scores/{score} |
| 57 | + |
| 58 | +Get a single quality score with its dimension items. |
| 59 | + |
| 60 | +**Response:** Single `ContentQualityScoreResource` with `items` array. |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +### 3. POST /api/v1/quality/score |
| 65 | + |
| 66 | +Trigger an async quality scoring job for a content item. |
| 67 | + |
| 68 | +**Request body:** |
| 69 | +```json |
| 70 | +{ "content_id": "01J..." } |
| 71 | +``` |
| 72 | + |
| 73 | +**Response (202):** |
| 74 | +```json |
| 75 | +{ "message": "Quality scoring job queued.", "content_id": "01J..." } |
| 76 | +``` |
| 77 | + |
| 78 | +--- |
| 79 | + |
| 80 | +### 4. GET /api/v1/quality/trends |
| 81 | + |
| 82 | +Aggregate daily trend data, leaderboard, and dimension distributions for a space. |
| 83 | + |
| 84 | +**Query parameters:** |
| 85 | + |
| 86 | +| Parameter | Type | Required | Description | |
| 87 | +|-----------|------|----------|-------------| |
| 88 | +| `space_id` | string (ULID) | ✅ | Space to query | |
| 89 | +| `from` | date (YYYY-MM-DD) | ❌ | Start date (default: 30 days ago) | |
| 90 | +| `to` | date (YYYY-MM-DD) | ❌ | End date (default: today) | |
| 91 | + |
| 92 | +**Response:** |
| 93 | +```json |
| 94 | +{ |
| 95 | + "data": { |
| 96 | + "trends": { |
| 97 | + "2026-03-15": { |
| 98 | + "overall": 81.3, |
| 99 | + "readability": 85.2, |
| 100 | + "seo": 78.4, |
| 101 | + "brand": 82.0, |
| 102 | + "factual": 90.1, |
| 103 | + "engagement": 71.5, |
| 104 | + "total": 12 |
| 105 | + } |
| 106 | + }, |
| 107 | + "leaderboard": [ |
| 108 | + { |
| 109 | + "score_id": "01J...", |
| 110 | + "content_id": "01J...", |
| 111 | + "title": "10 Ways to Write Better Content", |
| 112 | + "overall_score": 94.5, |
| 113 | + "scored_at": "2026-03-16T09:00:00Z" |
| 114 | + } |
| 115 | + ], |
| 116 | + "distribution": { |
| 117 | + "overall": { "0-10": 0, "10-20": 1, "20-30": 2, ..., "90-100": 8 } |
| 118 | + }, |
| 119 | + "period": { "from": "2026-02-14", "to": "2026-03-16" } |
| 120 | + } |
| 121 | +} |
| 122 | +``` |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +### 5. GET /api/v1/quality/config |
| 127 | + |
| 128 | +Get quality configuration for a space. Creates a default config if none exists. |
| 129 | + |
| 130 | +**Query parameters:** `space_id` (required) |
| 131 | + |
| 132 | +**Response:** |
| 133 | +```json |
| 134 | +{ |
| 135 | + "data": { |
| 136 | + "id": "01J...", |
| 137 | + "space_id": "01J...", |
| 138 | + "dimension_weights": { |
| 139 | + "readability": 0.25, |
| 140 | + "seo": 0.25, |
| 141 | + "brand_consistency": 0.20, |
| 142 | + "factual_accuracy": 0.15, |
| 143 | + "engagement_prediction": 0.15 |
| 144 | + }, |
| 145 | + "thresholds": { "poor": 40, "fair": 60, "good": 75, "excellent": 90 }, |
| 146 | + "enabled_dimensions": ["readability", "seo", "brand_consistency", "factual_accuracy", "engagement_prediction"], |
| 147 | + "auto_score_on_publish": true, |
| 148 | + "pipeline_gate_enabled": false, |
| 149 | + "pipeline_gate_min_score": 70.0, |
| 150 | + "created_at": "2026-03-16T08:00:00Z", |
| 151 | + "updated_at": "2026-03-16T08:00:00Z" |
| 152 | + } |
| 153 | +} |
| 154 | +``` |
| 155 | + |
| 156 | +--- |
| 157 | + |
| 158 | +### 6. PUT /api/v1/quality/config |
| 159 | + |
| 160 | +Update quality configuration for a space. Requires `settings.manage` permission. |
| 161 | + |
| 162 | +**Request body:** |
| 163 | +```json |
| 164 | +{ |
| 165 | + "space_id": "01J...", |
| 166 | + "pipeline_gate_enabled": true, |
| 167 | + "pipeline_gate_min_score": 75, |
| 168 | + "auto_score_on_publish": true, |
| 169 | + "enabled_dimensions": ["readability", "seo"], |
| 170 | + "dimension_weights": { "readability": 0.5, "seo": 0.5 } |
| 171 | +} |
| 172 | +``` |
| 173 | + |
| 174 | +**Response:** Updated `ContentQualityConfigResource`. |
| 175 | + |
| 176 | +--- |
| 177 | + |
| 178 | +## Webhook Event |
| 179 | + |
| 180 | +### `quality.scored` |
| 181 | + |
| 182 | +Fired when a content item is successfully scored. |
| 183 | + |
| 184 | +**Payload:** |
| 185 | +```json |
| 186 | +{ |
| 187 | + "id": "01J...", |
| 188 | + "event": "quality.scored", |
| 189 | + "timestamp": "2026-03-16T10:00:00Z", |
| 190 | + "data": { |
| 191 | + "score_id": "01J...", |
| 192 | + "content_id": "01J...", |
| 193 | + "space_id": "01J...", |
| 194 | + "overall_score": 82.5, |
| 195 | + "readability_score": 88.0, |
| 196 | + "seo_score": 79.0, |
| 197 | + "brand_score": 85.0, |
| 198 | + "factual_score": 91.0, |
| 199 | + "engagement_score": 70.0, |
| 200 | + "scored_at": "2026-03-16T10:00:00Z" |
| 201 | + } |
| 202 | +} |
| 203 | +``` |
| 204 | + |
| 205 | +--- |
| 206 | + |
| 207 | +## Pipeline Stage: `quality_gate` |
| 208 | + |
| 209 | +Add a `quality_gate` stage to any pipeline to enforce quality thresholds before publishing. |
| 210 | + |
| 211 | +**Pipeline definition example:** |
| 212 | +```json |
| 213 | +{ |
| 214 | + "stages": [ |
| 215 | + { "name": "ai_generate", "type": "ai_generate" }, |
| 216 | + { |
| 217 | + "name": "quality_check", |
| 218 | + "type": "quality_gate", |
| 219 | + "min_score": 75 |
| 220 | + }, |
| 221 | + { "name": "publish", "type": "auto_publish" } |
| 222 | + ] |
| 223 | +} |
| 224 | +``` |
| 225 | + |
| 226 | +If `min_score` is omitted, the stage uses the space's `pipeline_gate_min_score` config (default: 70). |
| 227 | + |
| 228 | +If the score is below the threshold, the pipeline is paused with status `paused_for_review`. |
| 229 | + |
| 230 | +--- |
| 231 | + |
| 232 | +## Scoring Dimensions |
| 233 | + |
| 234 | +| Dimension | Key | Description | |
| 235 | +|-----------|-----|-------------| |
| 236 | +| Readability | `readability` | Flesch-Kincaid score, sentence length, word complexity | |
| 237 | +| SEO | `seo` | Keyword density, meta tags, heading structure | |
| 238 | +| Brand Consistency | `brand_consistency` | Tone, voice, and brand guideline adherence (LLM-based) | |
| 239 | +| Factual Accuracy | `factual_accuracy` | Fact-check claims against knowledge base (LLM-based) | |
| 240 | +| Engagement Prediction | `engagement_prediction` | Predicted engagement based on content patterns (LLM-based) | |
| 241 | + |
| 242 | +## Score Interpretation |
| 243 | + |
| 244 | +| Range | Label | Meaning | |
| 245 | +|-------|-------|---------| |
| 246 | +| 90–100 | Excellent | Ready to publish, high-quality | |
| 247 | +| 75–89 | Good | Publish-ready, minor improvements possible | |
| 248 | +| 60–74 | Fair | Consider improvements before publishing | |
| 249 | +| 40–59 | Poor | Significant improvements needed | |
| 250 | +| 0–39 | Critical | Major revision required | |
0 commit comments