Skip to main content

Service Contracts

This document defines the contracts and standards for inter-service communication.

Standard Headersโ€‹

Required on ALL Requestsโ€‹

Authorization: Bearer <access_token>
X-Correlation-Id: <uuid>
Content-Type: application/json
Accept: application/json

After Authentication (Set by Backend)โ€‹

X-Tenant-Id: <tenant_id>        # From JWT claims
X-User-Id: <user_id> # From JWT claims
X-Request-Id: <uuid> # Generated per request

M2M (Service-to-Service)โ€‹

Authorization: Bearer <service_principal_token>
X-Service-Principal: <service_name>
X-Correlation-Id: <uuid>

ID Standardsโ€‹

ID TypeFormatExample
tenant_idUUID v4550e8400-e29b-41d4-a716-446655440000
user_idUUID v47c9e6679-7425-40de-944b-e07fc1f90ae7
customer_idInteger/UUID12345
contract_idcontract_ + UUIDcontract_a1b2c3d4-5678-90ab
license_keyQCOS-XXXX-XXXX-...QCOS-41FB-639F-C30B-14E3
bundle_idbundle_ + timestamp + UUIDbundle_20250104_abc123

Error Response Formatโ€‹

{
"error": {
"code": "RESOURCE_NOT_FOUND",
"message": "The requested resource was not found",
"details": {
"resource_type": "license",
"resource_id": "QCOS-XXXX-XXXX"
},
"correlation_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"timestamp": "2025-01-04T10:00:00Z"
}
}

Error Codesโ€‹

HTTPCodeDescription
400INVALID_REQUESTMalformed request
400VALIDATION_ERRORField validation failed
401UNAUTHORIZEDMissing/invalid token
401TOKEN_EXPIREDJWT expired
403FORBIDDENInsufficient permissions
403TENANT_MISMATCHCross-tenant access
404RESOURCE_NOT_FOUNDResource doesn't exist
409CONFLICTState conflict
429RATE_LIMITEDToo many requests
500INTERNAL_ERRORServer error
503SERVICE_UNAVAILABLEDependency down

Service Endpointsโ€‹

QSA (Identity Provider)โ€‹

EndpointMethodDescription
/.well-known/openid-configurationGETOIDC discovery
/.well-known/jwks.jsonGETJSON Web Key Set
/oauth2/authorizeGETAuthorization
/oauth2/tokenPOSTToken exchange
/oauth2/revokePOSTToken revocation
/api/v1/usersCRUDUser management
/api/v1/mfa/*POSTMFA operations

QuantumLockโ€‹

EndpointMethodDescription
/api/v1/licenses/generatePOSTGenerate license
/api/v1/licenses/validatePOSTValidate license
/api/v1/licenses/{key}GETGet license details
/api/v1/licenses/{key}/revokePOSTRevoke license
/api/v1/revocationsGETList revocations
/api/v1/quantum/crypto/signPOSTSign message
/api/v1/quantum/crypto/verifyPOSTVerify signature

Portal Backendโ€‹

EndpointMethodDescription
/api/customersCRUDCustomer management
/api/contractsCRUDContract management
/api/entitlementsCRUDEntitlements
/api/v2/jobs/{id}/evidenceGETGet evidence
/api/v2/jobs/{id}/artifactsGETList artifacts
/api/v2/evidence/verifyPOSTVerify evidence

Rate Limitsโ€‹

ServiceLimitWindow
QSA Token100/minPer client
QSA API1000/minPer tenant
QuantumLock GeneratePer planMonthly
QuantumLock Validate10000/minPer client
Portal API1000/minPer user
Evidence API500/minPer tenant

Headers:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 950
X-RateLimit-Reset: 1704369600

Health Checksโ€‹

All services expose:

GET /health   # Liveness
GET /ready # Readiness

Response:

{
"status": "healthy",
"version": "1.0.0",
"timestamp": "2025-01-04T10:00:00Z",
"checks": {
"database": "ok",
"redis": "ok",
"storage": "ok"
}
}

Observabilityโ€‹

Logging Formatโ€‹

{
"timestamp": "2025-01-04T10:00:00.123Z",
"level": "INFO",
"service": "portal-backend",
"correlation_id": "9b1deb4d-...",
"tenant_id": "550e8400-...",
"user_id": "7c9e6679-...",
"message": "License generated",
"data": {
"license_key": "QCOS-XXXX-****"
}
}

Metrics (Prometheus)โ€‹

http_requests_total{service, method, endpoint, status}
http_request_duration_seconds{service, method, endpoint}
licenses_generated_total{plan, tenant}
evidence_bundles_created_total{tenant}

Tracingโ€‹

All services propagate OpenTelemetry context:

traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
tracestate: softquantus=tenant:abc123

Versioningโ€‹

  • All APIs use path versioning (/api/v1/, /api/v2/)
  • Breaking changes require major version bump
  • 6-month deprecation notice for major changes
  • Parallel support for N and N-1 versions

Deprecation Headers:

Sunset: Sat, 04 Jul 2026 00:00:00 GMT
Deprecation: true
Link: <https://docs.softquantus.com/migration>; rel="deprecation"