commercetools · API Governance Rules

commercetools API Rules

Spectral linting rules defining API design standards and conventions for commercetools.

9 Rules error 4 warn 4 info 1
View Rules File View on GitHub

Rule Categories

commercetools

Rules

error
commercetools-info-contact
API info must include a contact block.
$.info
error
commercetools-server-https
Server URLs must use HTTPS.
$.servers[*].url
warn
commercetools-server-host
Public server URL should point to *.commercetools.com.
$.servers[*].url
info
commercetools-regional-server
Production server URLs should be regional (use {region}).
$.servers[*].url
error
commercetools-oauth-security
APIs must declare OAuth 2.0 security.
$.components.securitySchemes[*]
error
commercetools-operation-id
Every operation must declare a unique operationId.
$.paths[*][get,post,put,patch,delete]
warn
commercetools-operation-tags
Operations must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
commercetools-project-key-path
Project-scoped paths must include a {projectKey} parameter.
$.paths[?(@property.indexOf('{projectKey}') > -1)]
warn
commercetools-error-responses
Mutating operations should declare 400 and 409 error responses.
$.paths[*][post,put,patch,delete].responses

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

# Spectral linting rules for commercetools Composable Commerce APIs.
# Tuned to commercetools.com conventions: regional api.{region}.commercetools.com
# servers, OAuth 2.0 client-credentials authentication, project-key path
# scoping, and strongly typed JSON resources.
rules:
  commercetools-info-contact:
    description: API info must include a contact block.
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

  commercetools-server-https:
    description: Server URLs must use HTTPS.
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  commercetools-server-host:
    description: Public server URL should point to *.commercetools.com.
    severity: warn
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "commercetools.com"

  commercetools-regional-server:
    description: Production server URLs should be regional (use {region}).
    severity: info
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "{region}"

  commercetools-oauth-security:
    description: APIs must declare OAuth 2.0 security.
    severity: error
    given: "$.components.securitySchemes[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            type:
              enum: ["oauth2", "http"]

  commercetools-operation-id:
    description: Every operation must declare a unique operationId.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  commercetools-operation-tags:
    description: Operations must declare at least one tag.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 1

  commercetools-project-key-path:
    description: Project-scoped paths must include a {projectKey} parameter.
    severity: warn
    given: "$.paths[?(@property.indexOf('{projectKey}') > -1)]"
    then:
      function: truthy

  commercetools-error-responses:
    description: Mutating operations should declare 400 and 409 error responses.
    severity: warn
    given: "$.paths[*][post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ["400"]
            - required: ["401"]
            - required: ["404"]
            - required: ["409"]

Work with this as data

Every ruleset here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for spectral rules

4 MCP tools reach this
  • find_rulesBrowse and filter every ruleset in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This ruleset
curl "https://apis.io/api/v1/rules/commercetools-rules"
All spectral rules
curl "https://apis.io/api/v1/rules?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.