Organisation-wide API governance: a style guide, automated OpenAPI linting with Spectral in CI, lightweight risk-based reviews, shared building blocks for errors, paging and versioning, an API catalogue, and measuring adoption without becoming a bottleneck.
I'd build governance as a paved road, not a gate:
A small central guild with champions in each team owns it, and I measure lint pass rates and review lead time. The trade-off: consistency versus team autonomy and speed.
"The goal of API governance is that a consumer who has used one of our APIs can use the next without surprises: the same error shape, the same paging, the same versioning and auth. The failure mode is a central review board that every team waits on for two weeks, so teams route around it. So I design it as a paved road: make the right thing the easy thing, automate what can be automated, and save human review for the APIs where mistakes are expensive.
Concretely, I'd start with a short style guide, maybe 30 rules, adapted from the Microsoft REST API Guidelines or Zalando's, written as MUST, SHOULD and MAY. Then I'd turn as many MUSTs as possible into a shared Spectral ruleset published as a package: camelCase properties,
application/problem+jsonon 4xx and 5xx, cursor parameters on collections,operationIdpresent, no verbs in paths. Every pipeline lints the generated OpenAPI document and runs oasdiff for breaking changes. Next, the paved road: adotnet newtemplate and NuGet packages that configure ProblemDetails with our error codes, Asp.Versioning, cursor pagination helpers and OpenTelemetry, so a new service is compliant before anyone writes a line. For example, at [company] we [had 20 teams and five different error formats]; after [the shared package and lint rules], [lint compliance went from X% to Y%] in [two quarters] without a single mandated review for internal APIs.Human review is risk-based. Public, partner and cross-domain APIs get a design review on the spec, done by a rotating group of champions from the teams, with a service level of a few days. Internal single-consumer APIs are self-service if they pass lint. Everything is registered in an API catalogue, Azure API Center or the APIM developer portal, with an owner and lifecycle state. And the guide itself evolves through lightweight RFCs, so teams shape it rather than resent it. I measure it: lint pass rate, catalogue coverage, review lead time and consumer satisfaction. If review lead time grows, governance is becoming a bottleneck and I fix that before anything else."
| Block | What it is | Owner |
|---|---|---|
| Style guide | ~30 MUST/SHOULD/MAY rules, examples, rationale | API guild |
| Spectral ruleset | Automated checks for most MUST rules, versioned package | API guild |
| Breaking-change gate | oasdiff in each pipeline | Each team (template provided) |
| Paved road | dotnet new template, NuGet packages (errors, paging, versioning, telemetry) |
Platform team |
| Design review | Spec review for high-risk APIs, SLA 3 working days | Rotating champions |
| API catalogue | Azure API Center / APIM: owner, lifecycle, specs, consumers | Each team registers; guild audits |
| RFC process | Proposals to change the guide | Anyone |
| API type | Review | Gate |
|---|---|---|
| Public / partner | Full design review on spec + security review | Before first consumer integrates |
| Cross-domain internal | Lightweight review by a champion from another team | Before production |
| Single-consumer internal | None if lint and oasdiff pass | Automated |
| Standard | Decision |
|---|---|
| Errors | RFC 9457 ProblemDetails with code and traceId |
| Pagination | Cursor (after, limit), max 100, no default totals |
| Versioning | URL major version, Deprecation and Sunset headers, 12 months' notice |
| Naming | camelCase JSON, plural nouns, kebab-case paths |
| Data types | Money as string + ISO 4217, date-time with offset, extensible enums |
| Reliability | Idempotency-Key on non-idempotent POSTs, ETags for updates, 429 + Retry-After |
Across [20] teams and [~120] APIs, the shared Spectral ruleset and paved-road packages took lint compliance from [35]% to [90]% in [two quarters]. Design reviews were limited to [15] public and partner APIs with a median lead time of [two days], and the mobile team reported dropping [four] custom error parsers.
Checks staff-level ability to drive consistency across many teams through automation, defaults and lightweight process rather than central control.
Green flags
Red flags
style guide (why + rules)
│
┌────────────┼───────────────┐
▼ ▼ ▼
paved road Spectral rules review guidance
(templates, (automated in (high-risk APIs
packages) every PR) only)
│ │ │
└────────────┼───────────────┘
▼
API catalogue (owner, lifecycle, spec, consumers)
│
▼
metrics ──► RFCs to change the guide
The loop at the bottom matters: metrics and team feedback change the rules, so governance improves instead of ossifying.
Spectral lints OpenAPI documents with JSONPath-based rules and custom functions. Organise it as:
@org/spectral-api-rules) extending spectral:oas.error for MUSTs (fails CI), warn for SHOULDs.Because .NET 10 can generate the OpenAPI document at build time, linting runs on what the code actually does, not on a hand-maintained YAML.
Teams follow the path of least resistance. If the template already returns ProblemDetails with codes, paginates with cursors and emits OpenTelemetry, compliance is the default. Packages to provide:
| Package | Provides |
|---|---|
Org.Api.Errors |
AddProblemDetails config, code catalogue types, exception handler |
Org.Api.Paging |
Cursor encoding, Page<T>, limit validation |
Org.Api.Versioning |
Asp.Versioning defaults, deprecation header filter |
Org.Api.Telemetry |
OpenTelemetry setup, client id and version tags |
An API catalogue answers "what APIs exist, who owns them, who uses them, and what state are they in?" Azure API Center is designed for this inventory across gateways and environments, and integrates with Spectral-based analysis; APIM gives a developer portal for APIs it fronts; Backstage is an option for organisations already using it. Lifecycle states: design, preview, GA, deprecated, retired.
Central review boards don't scale to 20 teams. A small guild (2-3 people part-time) owns the guide and tooling; each team nominates a champion who reviews other teams' high-risk APIs on rotation. That spreads knowledge and keeps reviews fast.
| Metric | Signal |
|---|---|
| Lint pass rate (error-level) per API | Adoption of MUST rules |
| Catalogue coverage | Shadow APIs |
| Review lead time | Bottleneck risk |
| Breaking changes caught in CI vs reported by consumers | Effectiveness |
| Consumer survey / support tickets about inconsistency | Outcome |
limit max 100) and run them on one of your specs.extends from another repo.dotnet new template that includes ProblemDetails and versioning defaults.A shared Spectral ruleset that turns guideline MUSTs into CI failures, and the pipeline step every team inherits.
# org-api-rules/.spectral.yaml (published as a versioned package)
extends: ["spectral:oas"]
rules:
org-camel-case-properties:
description: JSON properties MUST be camelCase (guideline 4.1).
severity: error
given: "$..properties[*]~"
then:
function: casing
functionOptions: { type: camel }
org-problem-json-for-errors:
description: 4xx and 5xx responses MUST use application/problem+json (guideline 7.2).
severity: error
given: "$.paths[*][*].responses[?(@property.match(/^[45]/))].content"
then:
field: "application/problem+json"
function: truthy
org-no-verbs-in-paths:
description: Paths SHOULD be nouns, not verbs (guideline 3.3).
severity: warn
given: "$.paths[*]~"
then:
function: pattern
functionOptions: { notMatch: "/(get|create|update|delete)[A-Z]" }
org-collection-limit-max:
description: Collection 'limit' parameters MUST have maximum <= 100 (guideline 8.1).
severity: error
given: "$.paths[*].get.parameters[?(@.name == 'limit')].schema"
then:
field: maximum
function: schema
functionOptions: { schema: { type: number, maximum: 100 } }
# azure-pipelines/api-governance.yml (template every API pipeline extends)
steps:
- script: dotnet build src/$(ApiProject) -c Release # build-time OpenAPI generation
displayName: Build and generate OpenAPI
- script: npx @stoplight/spectral-cli lint artifacts/openapi/*.json --ruleset node_modules/@org/api-rules/.spectral.yaml --fail-severity=error
displayName: Lint against API guidelines
- script: oasdiff breaking $(PublishedSpec) artifacts/openapi/$(ApiProject).json --fail-on ERR
displayName: Block breaking changes
// Org.Api.Defaults - the paved road: one call gives a compliant service.
namespace Org.Api;
public static class ApiDefaults
{
public static WebApplicationBuilder AddOrgApiDefaults(this WebApplicationBuilder builder)
{
builder.Services.AddProblemDetails(o => o.CustomizeProblemDetails = ctx =>
ctx.ProblemDetails.Extensions["traceId"] = System.Diagnostics.Activity.Current?.Id);
builder.Services.AddOpenApi();
builder.Services.AddApiVersioning(o => o.ReportApiVersions = true).AddApiExplorer();
builder.Services.AddRateLimiter(_ => { }); // team policies configured per endpoint
return builder;
}
}
Governance succeeds when teams would choose it voluntarily. The levers, in order of effectiveness, are: defaults (templates and packages), automation (lint and diff in CI), visibility (catalogue and dashboards), and only then human review. I spend most of the effort on the first two, and I keep the review step small and fast so it's seen as help from peers, not permission from a committee.
Culture decides whether any of this lands. I get buy-in before rules: involve team leads in choosing the first 30 rules, publish the rationale, run short workshops and office hours, and celebrate teams that adopt early. Engineering leadership sponsors it by putting the metrics in quarterly reviews, not by mandating approvals. Security is part of the same system: the ruleset requires a security scheme and scopes on every operation, flags personal data in query strings, and high-risk APIs get a security review alongside the design review, with gateway policies (APIM JWT validation, rate limits) as the runtime backstop.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Central review board | Few teams, high regulation, public APIs | Bottleneck, slow lead time | Many teams shipping weekly |
| Federated guild + champions | 10-50 teams | Champion time (a few hours a week) | Very small organisations |
| Automation-only (lint + diff) | Internal APIs, mature teams | Rules must be precise | Public APIs needing design judgement |
| Gateway-enforced policy (APIM) | Cross-cutting runtime concerns (auth, rate limits) | Gateway coupling | Design-time concerns like naming |
The staff-level signal is treating governance as a product with users (the teams), success metrics and a feedback loop, and being willing to delete rules that don't earn their keep.
I make the committed build-time spec the contract and gate pull requests on it:
oasdiff breaking compares the PR's spec with main and the last released spec, and fails on removed paths or properties, new required request fields, narrowed enums or changed types.AddOpenApi("v1"), AddOpenApi("v2")), so breaking changes go into a new version while v1 stays frozen.The trade-off: CI becomes stricter and occasionally needs a deliberate override, but breaking changes become explicit decisions instead of production incidents.
I start from partner use cases and the domain, modelling resources around stable business concepts rather than tables. I adopt a published baseline (the Azure or Microsoft Graph REST API guidelines, which replaced Microsoft's original general guidelines; Google AIP or Zalando are good alternatives) and write a short house style: naming, JSON conventions, dates with offsets, money as decimal plus currency, opaque ids, one error shape (RFC 9457 ProblemDetails with error codes) and one paging shape (cursor plus nextLink).
Then I design for evolution: additive changes only, tolerant readers, a written deprecation policy with Sunset headers, and rare major versions. Security is OAuth 2.0 client credentials with scopes, rate limits and idempotency keys. Partners experience the API through OpenAPI, examples, a sandbox, SDKs and a changelog. The trade-off is upfront design and governance effort versus years of breaking partner integrations.
Understand the cost first: who the clients are, how many, what their contracts say and what migrating them would take. The rule I would not bend is never break existing clients.
Accept header and move when ready, with a migration guide and changelog.Forcing an immediate change would cost more than the inconsistency.
How to tell it (STAR)
**S:** We had [20] teams publishing APIs with five different error formats, inconsistent paging and a review board that took three weeks, so teams ignored it. **T:** I was asked to make our APIs consistent without slowing teams down. **A:** I rewrote the guidelines as 30 rules with reasons, turned most into a shared Spectral ruleset in every pipeline, built packages and a template so new services were compliant by default, replaced the board with rotating champion reviews for partner APIs only, and put every API in a catalogue with an owner. **R:** Lint compliance went from [35]% to [90]% in [two quarters], review lead time dropped to [two days], and the mobile team retired [four] error parsers.
Last updated 23 Nov 2026.