intermediate·10 min read·Updated

API Governance Best Practices: Design Standards, Policies and Risks

Hold every API to the same rules, and when one cannot meet them, record why and until when. Check specifications against design standards, write policies, and accept risks with an end date.

This is lesson 9.26, part 2, of Shift-Left API in Depth. Part 1 set lifecycle states and project rules. This part covers design standards, policies and the risk register. All three are part of API governance, which comes with Professional, the 15-day trial and Enterprise.

Which rules should every API follow?

API governance best practices come down to this: hold every API to the same rules, and when one cannot meet them, say so, with a reason and an end date. Shift-Left API has three kinds of check:

  • Design standards read the specification itself.
  • Policies are rules about facts of each API, such as whether it requires sign-in.
  • The risk register shows each API's worst risk.

For each problem, you either fix the cause or a person records why not, and for how long. The product never accepts, waives or lowers anything by itself.

How do you check API design standards?

  1. Open Design standards. A project uses the Standard ruleset (documentation, naming and design) until you choose another.
  2. Click Check the specification now. The check reads the stored specification and changes nothing.
  3. Read the verdict, then each broken rule, worst first, with how many places it affects and where.

The rulesets have rules for REST, SOAP and GraphQL, and a project is checked only against the rules for its kind. Rules that did not run are never counted as met.

A shipped ruleset cannot be edited, but you can click Start your own from it. Your rules are YAML or JSON, written the way Spectral rules are and read by the product's own engine. You can turn a rule off, change how serious it is or add your own. Try it on this project shows the result without saving. To fix a finding, change the specification where it is written and import it again. Once a project has rules, the check also runs every night. By default, errors from design rules count as a risk in the release verdict.

How do you write a policy and allow an exception?

On Policies, add a policy with a name, a severity (low, medium or high), a short reason, the APIs it covers and what must be true. For example, every DELETE operation must require sign-in according to the specification. A sentence at the bottom reads the whole policy back, and no code is needed.

Each condition is a fact the product knows, and shows its source. Some come from the specification, some are typed by a person, some are counted from tests, security checks and mocks, and one is a guess from field names about whether an API returns personal data. A fact nobody stated counts as not met, except with "is not".

Policies are checked every night, or when you click Check now. Each violation shows what was required and what was found. When one cannot be fixed yet, allow it with a reason of at least ten characters and an end date within a year.

How does the risk register work?

On Risks, each row is one API with the worst of three kinds of risk: its security risk, a waiting change that could break users, and gaps in what has been checked, such as missing tests. One gap is rated low, two medium, and three or more high. The worst risk wins; there is no averaging.

To accept a risk, give a reason and an end date. A critical risk needs a date within 90 days. If the date passes, or the risk grows beyond what you accepted, it comes back. Accepting also needs permission to see security findings.

While an accepted risk is in force and covers the worst open security finding, the release verdict counts that finding as a risk instead of a block. It never excuses a security check that failed or could not run, and it does not affect a waiting change or missing tests.

What else does governance show?

Documentation and duplicates reports how fully each API is documented and where the same operation appears more than once. A duplicate is an observation, not a fault. Each API also has its own Governance tab with its state, owner, documentation, risk and broken design rules. Governance decisions are recorded in the audit log.

What habits help?

  • Give every API a state, starting with Active for live ones.
  • Name owners by email, so each name reaches one person.
  • Introduce project rules one at a time and tell people first.
  • Start with narrow policies, such as "deletes need sign-in".
  • Give every exception and acceptance an end date.

Try it yourself

With a trial: on Design standards, click Check the specification now. Write one policy and click Check now. On Risks, read the first row, and accept a risk only with a reason and a date.

Recap

  • Design standards check the specification, and the verdict is only about the rules.
  • Your own ruleset can switch rules off or change their severity.
  • Each API governance policy checks facts, and every exception ends.
  • Risk acceptances end too, so your API governance standards stay decisions that people make.

Next: lesson 9.27 on API usage monitoring. Also read how to standardize API testing across enterprise teams.

Hands-on lab

Try it: With a trial, open Design standards and check your project's specification. Write one policy and click Check now. On Risks, read the first row, and accept a risk only with a reason and a date.

Enter your email to open the lab steps. One unlock opens every lab in the learning center.

No spam. Protected by reCAPTCHA — Google Privacy & Terms.

Frequently asked questions

What are API design standards?+

They are rules about the specification itself, such as naming, documentation, versioning, error responses and paging. Shift-Left API checks a project against a ruleset and grades each broken rule as an error, warning, suggestion or hint. You can start your own ruleset, written in YAML or JSON the way Spectral rules are.

How should you handle an exception to an API governance policy?+

Record it with a reason and an end date. In Shift-Left API, an exception or an accepted risk keeps your name, your reason and a date no more than a year away. When the date passes and the problem remains, it is open again.

Does meeting the design rules mean an API is secure?+

No. A Rules met result only says that the rules in the ruleset were met. It does not say that the API is well designed or secure.

Read more on the blog