📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

You're asked to set API governance for 20 teams who each publish HTTP APIs. How would you design it: a style guide, automated linting with something like Spectral, the review process, shared standards for errors, pagination and versioning, and how do you keep it from becoming a bottleneck that teams route around?

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.

Staff / Architect Architecture Expert api-governance api-guidelines architecture azure-api-management spectral web-api

🎯 Key points

  • Written API style guide based on established guidelines (Microsoft REST API Guidelines, Zalando), with MUST/SHOULD/MAY rules
  • Automate most rules as a shared Spectral ruleset run in every pipeline on the OpenAPI document
  • Paved road: shared NuGet packages and templates for ProblemDetails, pagination, versioning, telemetry
  • Risk-based review: full design review only for public/partner or cross-domain APIs; self-service for the rest
  • Breaking change gate with oasdiff on every PR
  • API catalogue (APIM, Azure API Center or Backstage) for discovery, ownership and lifecycle
  • Federated model: small central guild plus champions in each team; guideline changes via RFCs
  • Measure adoption (lint pass rate, catalogue coverage, consumer satisfaction, review lead time)

⏱ 30-second answer

I'd build governance as a paved road, not a gate:

  • A short style guide with MUST/SHOULD rules, based on established guidelines (Microsoft REST API Guidelines, Zalando) and adapted to us.
  • Automation first: a shared Spectral ruleset linting every OpenAPI document in CI, plus an oasdiff breaking-change gate.
  • Shared building blocks: NuGet packages and templates that implement ProblemDetails, cursor pagination, versioning and telemetry, so the compliant path is the easiest.
  • Risk-based reviews: full design reviews only for public, partner or cross-domain APIs; everything else is self-service if lint passes.
  • An API catalogue (Azure API Center or APIM) for ownership and lifecycle.

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.

🗣 Full answer (senior)

How I would answer this in an interview

"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+json on 4xx and 5xx, cursor parameters on collections, operationId present, no verbs in paths. Every pipeline lints the generated OpenAPI document and runs oasdiff for breaking changes. Next, the paved road: a dotnet new template 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."


Governance building blocks

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

Risk-based review

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

Shared standards to agree first

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

Production example

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.

🔍 What the interviewer is checking

Checks staff-level ability to drive consistency across many teams through automation, defaults and lightweight process rather than central control.

Green flags

  • Paved road and automation before review boards
  • Concrete tooling: Spectral, oasdiff, build-time OpenAPI, API catalogue
  • Risk-based reviews with federated ownership
  • Plans for buy-in and culture: involving teams, rationale, education, leadership sponsorship
  • Includes security rules (auth schemes, scopes, no personal data in URLs) in the automated checks
  • Measures adoption and bottlenecks; guide evolves via RFCs

Red flags

  • Mandatory central approval for every API
  • A long document with no enforcement
  • No thought about team autonomy, culture or lead time

📚 Learn in depth

1. Governance as a system

          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.

2. Writing the style guide

  • Start from an established guide (Microsoft REST API Guidelines on GitHub, Zalando RESTful API Guidelines, Google AIP) rather than a blank page.
  • Use RFC 2119 language: MUST, SHOULD, MAY.
  • Each rule has a rationale and an example; rules without a reason get ignored.
  • Keep it short. A 200-page guide is read by nobody; 30 rules that are mostly automated are followed.

3. Spectral rulesets

Spectral lints OpenAPI documents with JSONPath-based rules and custom functions. Organise it as:

  • A base ruleset package (@org/spectral-api-rules) extending spectral:oas.
  • Rules tagged with severity: error for MUSTs (fails CI), warn for SHOULDs.
  • Versioned releases so teams upgrade deliberately; new error-level rules start as warnings for a quarter.

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.

4. The paved road beats the policy

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

5. Catalogue and lifecycle

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.

6. Federated ownership

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.

7. Metrics

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

Try it yourself

  1. Write three Spectral rules (camelCase properties, problem+json for 4xx, limit max 100) and run them on one of your specs.
  2. Package them as a ruleset and use extends from another repo.
  3. Create a dotnet new template that includes ProblemDetails and versioning defaults.
  4. Register two APIs in Azure API Center (or a spreadsheet as a start) with owner and lifecycle.
  5. Draft a one-page RFC template for changing a guideline.

💻 Code

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;
    }
}

⚠ Common mistakes

  • Mistake: A central review board approving every API. Why it is wrong: It becomes a bottleneck and teams route around it. Instead: Automate most rules; review only high-risk APIs, using federated champions.
  • Mistake: A long style guide with no automation. Why it is wrong: Nobody reads 200 pages, and compliance depends on reviewers' memory. Instead: ~30 rules, most enforced by Spectral in CI.
  • Mistake: Rules without rationale. Why it is wrong: Teams treat them as bureaucracy and argue every case. Instead: Each rule explains why and shows an example.
  • Mistake: Turning new rules on as errors immediately. Why it is wrong: Every pipeline goes red at once and teams disable linting. Instead: Introduce as warnings for a quarter, then promote.
  • Mistake: Governance without a paved road. Why it is wrong: Teams must build compliance themselves, so they don't. Instead: Templates and packages that are compliant by default.
  • Mistake: No catalogue. Why it is wrong: Shadow APIs and unknown owners make deprecation and security reviews impossible. Instead: Register every API with owner and lifecycle in API Center or APIM.
  • Mistake: Not measuring the governance itself. Why it is wrong: You can't tell if it helps or just slows teams. Instead: Track lint pass rate, review lead time and consumer outcomes.

🏛 Senior insight: trade-offs

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.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions linting specs and breaking-change detection in CI Why: Checks the CI implementation of OpenAPI linting and diffing.
    How to answer

    I make the committed build-time spec the contract and gate pull requests on it:

    1. Drift check: rebuild and fail if the generated spec differs from the committed one.
    2. Breaking-change check: 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.
    3. Lint: Spectral rules for house style (operationIds, ProblemDetails errors, naming).
    4. Versioning: one document per major version (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.

  2. When: Candidate mentions basing the guide on published REST guidelines Why: Checks depth on public API design guidelines and their content.
    How to answer

    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.

  3. When: Candidate describes shared standards as mandatory Why: Checks influence without authority and pragmatic exceptions.
    How to answer

    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.

    • Exception with an expiry: existing endpoints keep their format; new endpoints and the next major version use the standard ProblemDetails (RFC 9457). Record it in the catalogue with an owner and review date.
    • Opt-in path: clients can ask for the standard format via the version or Accept header and move when ready, with a migration guide and changelog.
    • Make it cheap: the shared error package, and a gateway transformation as a bridge if needed.
    • Measure: share of endpoints and traffic on the standard, exceptions past expiry.

    Forcing an immediate change would cost more than the inconsistency.

🛠 Real-world problems: how you handle them

Five error formats across 20 teams
Situation
An organisation with [20] product teams and [~120] internal and partner APIs on Azure. A mobile team and [six] partners consumed APIs from many teams. There was a wiki page of API guidelines that nobody followed.
Signals
The mobile app had [five] different error parsers; partner onboarding took [weeks] per API; an audit found APIs with offset paging and no limits, and [about a third] of APIs had no known owner.
Investigation
Generated OpenAPI documents for every API we could find and ran a draft Spectral ruleset across them: [35]% passed. Interviewed team leads: the guidelines were seen as unenforced and the old review board took [three weeks], so teams skipped it.
Resolution
Rewrote the guide as 30 MUST/SHOULD rules with rationale; published a Spectral ruleset and pipeline template; built paved-road packages for errors, paging, versioning and telemetry; replaced the review board with champion reviews for public and partner APIs only; registered every API in Azure API Center with an owner.
Prevention
Quarterly ruleset releases with warnings before errors; dashboard of lint pass rate, catalogue coverage and review lead time reviewed by engineering leadership; RFC process for guideline changes.

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.

More in API Design

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me