Cognite · API Governance Rules

Cognite API Rules

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

9 Rules error 1 warn 5 info 3
View Rules File View on GitHub

Rule Categories

cognite

Rules

info
cognite-list-endpoints-use-post
Cognite list endpoints use POST with a filter body, not GET with query params
$.paths[*]
warn
cognite-external-id-in-create-body
Cognite resource create requests should support externalId
$.components.schemas[*ExternalAsset,*ExternalEvent,*Post*].properties
warn
cognite-timestamp-fields-are-epoch-ms
Timestamp fields (createdTime, lastUpdatedTime, startTime, endTime) must be int64 epoch milliseconds
$.components.schemas[*].properties[createdTime,lastUpdatedTime,startTime,endTime]
info
cognite-pagination-cursor-field
Cognite list responses use nextCursor for pagination
$.components.schemas[*Response*,*List*].properties
warn
cognite-internal-ids-are-int64
Internal IDs (id, parentId, assetId, rootId) must be int64
$.components.schemas[*].properties.id
info
cognite-metadata-string-values
Metadata fields in Cognite resources are string key -> string value maps
$.components.schemas[*].properties.metadata
warn
cognite-external-id-max-length
externalId fields must have maxLength of 255
$.components.schemas[*].properties.externalId
error
cognite-operation-ids-required
All operations must have an operationId for SDK generation
$.paths[*][get,post,put,patch,delete]
warn
cognite-operations-have-tags
All operations should be tagged for API navigation
$.paths[*][get,post,put,patch,delete]

Spectral Ruleset

Raw ↑
extends: spectral:oas
formats:
  - oas3

rules:
  # Cognite uses POST for list operations with filter bodies
  cognite-list-endpoints-use-post:
    description: "Cognite list endpoints use POST with a filter body, not GET with query params"
    message: "List/filter endpoints should use POST method per Cognite API conventions"
    severity: info
    given: "$.paths[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  # All resource types must have externalId support
  cognite-external-id-in-create-body:
    description: "Cognite resource create requests should support externalId"
    message: "Create request body should include externalId property"
    severity: warn
    given: "$.components.schemas[*ExternalAsset,*ExternalEvent,*Post*].properties"
    then:
      field: externalId
      function: truthy

  # Timestamps use epoch milliseconds (int64)
  cognite-timestamp-fields-are-epoch-ms:
    description: "Timestamp fields (createdTime, lastUpdatedTime, startTime, endTime) must be int64 epoch milliseconds"
    message: "Timestamp field '{{property}}' should be integer type with int64 format"
    severity: warn
    given: "$.components.schemas[*].properties[createdTime,lastUpdatedTime,startTime,endTime]"
    then:
      - field: type
        function: enumeration
        functionOptions:
          values:
            - integer
      - field: format
        function: enumeration
        functionOptions:
          values:
            - int64

  # Pagination uses nextCursor pattern
  cognite-pagination-cursor-field:
    description: "Cognite list responses use nextCursor for pagination"
    message: "Paginated list response should include nextCursor field"
    severity: info
    given: "$.components.schemas[*Response*,*List*].properties"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  # Internal IDs should be int64
  cognite-internal-ids-are-int64:
    description: "Internal IDs (id, parentId, assetId, rootId) must be int64"
    message: "Internal ID field should be integer with int64 format"
    severity: warn
    given: "$.components.schemas[*].properties.id"
    then:
      - field: type
        function: enumeration
        functionOptions:
          values:
            - integer
      - field: format
        function: enumeration
        functionOptions:
          values:
            - int64

  # Metadata maps should be string->string only
  cognite-metadata-string-values:
    description: "Metadata fields in Cognite resources are string key -> string value maps"
    message: "Metadata field should have additionalProperties of type string"
    severity: info
    given: "$.components.schemas[*].properties.metadata"
    then:
      field: additionalProperties
      function: truthy

  # ExternalId max length constraint
  cognite-external-id-max-length:
    description: "externalId fields must have maxLength of 255"
    message: "externalId should have maxLength: 255"
    severity: warn
    given: "$.components.schemas[*].properties.externalId"
    then:
      field: maxLength
      function: enumeration
      functionOptions:
        values:
          - 255

  # Operations should have operationId
  cognite-operation-ids-required:
    description: "All operations must have an operationId for SDK generation"
    message: "Operation must have an operationId"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  # Tags should be present on all operations
  cognite-operations-have-tags:
    description: "All operations should be tagged for API navigation"
    message: "Operation should have at least one tag"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

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/cognite-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.