DocumentationAPI Contract

API Contract

The cPod backend exposes a REST API documented as an OpenAPI 3.1 specification. The spec is the authoritative source of truth for every endpoint, request/response shape, and error code in the platform.

SDK vs direct API. Use the typed SDKs (@cpod/sdk, cpod-sdk, etc.) rather than calling the REST API directly. The spec exists to define the contract between SDK and backend — not as a primary integration point for application developers.


Specification file

The spec lives at docs/api-contract/openapi.yaml in the repository. It follows OpenAPI 3.1 and uses JSON Schema Draft 2020-12 for all schema definitions.


View interactively

npx @redocly/cli preview-docs docs/api-contract/openapi.yaml
# Opens http://localhost:8080

Endpoint groups

GroupBase pathDescription
Authentication/v1/oauth/*Token issuance, introspection, app registration
People/v1/peoplePerson CRUD
Groups/v1/groupsGroup CRUD + membership
Technology/v1/technologyAssets + entitlements
Licenses/v1/licensesLicenses + assignments
Assets/v1/assetsPhysical + cloud resources
Risk/v1/riskVulnerabilities, controls, risk items
Relationships/v1/relationshipsEntity graph edges
Data Sources/v1/data-sourcesConnector CRUD + sync
Storage: Files/v1/storage/files/*Blob upload/download
Storage: DB/v1/storage/db/*Document store
Storage: KV/v1/storage/kv/*Key-value store
Skills/v1/skillsList + run
Workflows/v1/workflowsCRUD + trigger
Jobs/v1/jobsSubmit + track
Masking/v1/masking/*PII masking
Telemetry/v1/telemetry/*Audit, traces, events
Feature Flags/v1/flags/*Flag evaluation
Secrets/v1/secrets/*Secret resolution
Management/v1/organizations, /v1/users, /v1/credentials, /v1/podsAdmin ops

Contract validation (CI)

Every PR that touches docs/api-contract/, emulator/src/routes/, or sdks/ triggers the API Contract Validation workflow (.github/workflows/api-contract.yml), which runs three jobs:

1. Spectral lint

Stoplight Spectral lints the spec against the ruleset in .spectral.yaml. The ruleset extends spectral:oas and adds cPod-specific rules:

RuleSeverityDescription
operation-operationIderrorEvery operation must have a unique operationId
operation-descriptionwarnEvery operation should include a description
operation-tagswarnEvery operation should belong to a tag
operation-success-responseerrorEvery operation must define at least one 2xx response
oas3-schemaerrorSchema objects must be valid OAS 3.1
cpod-id-patternwarnEntity id properties must declare a regex pattern
cpod-no-inline-schemaswarnInline schemas with >3 properties should be extracted to components/schemas
cpod-pagination-shapewarnList-endpoint responses should include items and total

2. Path completeness check

scripts/check-api-contract.mjs reads the spec and asserts:

  • At least 40 paths are defined (warns if the spec looks truncated)
  • At least 10 component schemas are defined
  • OpenAPI version is 3.1.x
  • info.contact is present
  • Every path starts with /v1/

3. SDK alignment check

scripts/validate-api-contract.ts compares the set of SDK service names (people, groups, technology, licenses, assets, risk, relationships, dataSources) against the tags declared in the spec. The build fails if any SDK service has no corresponding tag in the OpenAPI document (or vice-versa, with a warning).


Keeping the contract in sync

When you add a new endpoint, follow this order:

  1. Emulator route — add the handler in emulator/src/routes/
  2. OpenAPI spec — add the path + schema to docs/api-contract/openapi.yaml
  3. SDK methods — implement the client method in all four SDKs
  4. Tests — add at minimum a smoke test per SDK
  5. Docs — update the relevant domain page under docs/pages/docs/domains/

CI will catch any step you miss that touches the spec.

⚠️

Never hand-edit the spec for an endpoint that does not yet exist in the emulator. The spec and the emulator must stay in lock-step — they are tested together in CI.


Entity ID prefixes

All cPod entity IDs use a three-letter kebab prefix so they are self-describing in logs:

EntityPrefixExample
Personper-per-01J...
Groupgrp-grp-01J...
TechnologyAssettast-tast-01J...
AccessEntitlementent-ent-01J...
SoftwareLicenselic-lic-01J...
LicenseAssignmentlasgn-lasgn-01J...
PhysicalAssetpast-past-01J...
CloudResourcecres-cres-01J...
Vulnerabilityvuln-vuln-01J...
ComplianceControlctrl-ctrl-01J...
RiskItemrisk-risk-01J...
Relationshiprel-rel-01J...
DataSourceds-ds-01J...

The cpod-id-pattern Spectral rule warns when an id property is missing a pattern constraint — this keeps the spec honest about ID shapes.