API Contracts and Asynchronous Operations
This page holds the V3 API contract rules that sit alongside APIM policy:
OpenAPI and versioning, rate-limit sizing, the asynchronous 202 Accepted
pattern, and 5xx diagnosis. The normative rules are in the API Management
guidelines; the decisions are
ADR-0020
(REST and async REST) and
ADR-0005
(CloudEvents and AsyncAPI).
Contract conventions
| Concern | Rule |
|---|---|
| Format | HTTP/JSON with an OpenAPI 3.x contract in the service repository |
| Versioning | URI-path major version (/v1). Compatible additions stay within a major version. |
| Pagination | Bounded opaque-cursor pagination for collections |
| Errors | Stable envelope: code, safe message, optional details, correlation ID |
| Long-running work | 202 Accepted with Location and Retry-After |
| Asynchronous integration | CloudEvents payloads described by AsyncAPI |
| Security declaration | Describes the real trust model; it is documentation, not enforcement |
Publish an API
- Author and validate the OpenAPI 3.x contract in the service repository.
- Choose the API category: MFE BFF, role-based API, integration ingress, or provider webhook (see Service onboarding).
- Add the APIM API, product association, backend, and operations through IaC.
- Inherit platform policy for correlation, authentication, safe errors, diagnostics, and baseline limits; for MFE BFFs, use the MFE product.
- Add operation-specific permission, rate limit, transformation, or cache policy.
- Run OpenAPI compatibility checks, policy linting, deployment plan, and positive and negative security tests.
- Verify the route through Front Door, Application Gateway, and APIM, including correlation across APIM and backend logs.
Add a major API version
- Publish a new
/vNAPI in the existing version set; do not overwrite the old contract. - Deploy both versions and add deprecation and sunset metadata to the old one.
- Publish updated client artifacts where used.
- Track consumers and remove the old version only after the agreed migration.
Apply rate limiting
Choose a stable authenticated key: user oid for a BFF route, client application
for a workload route, tenant tid for a per-customer quota, or source IP for a
provider webhook. Size limits from measured peak and downstream capacity. Verify
429 and Retry-After, and alert on sustained throttling rather than silently
dropping requests.
Deployed reference points:
| Scope | Key | Limit |
|---|---|---|
| MFE product | API ID + oid | 300 calls per 60 seconds |
| MFE product | tid | 5,000 calls and 40,000 KB per hour |
| Signet external API | Source IP / user | 300 per minute per IP, 30 per minute per user, 120 per hour per user quota |
| Pigeon Twilio webhook | API ID + source IP | 100 per 60 seconds |
| Phoenix Graph webhook | Source IP | 500 per 60 seconds |
| Global backend | API ID | Concurrency 30 (Alpha, Beta) or 200 (Gamma, Production) |
A representative API-scope policy is:
<rate-limit-by-key
calls="{{route-limit}}"
renewal-period="60"
counter-key="@(context.Api.Id + "-" + ((Jwt)context.Variables["jwt"]).Claims.GetValueOrDefault("oid", "none"))" />
The "none" fallback places every caller without an oid in one shared bucket.
That is acceptable only because global policy has already rejected callers
without a valid token. Do not use this pattern on routes that bypass global
inbound policy.
Implement an asynchronous operation
- Accept the command and create an idempotent operation record.
- Publish a Service Bus command or start a Temporal workflow.
- Return
202 Accepted,Location: /operations/{id}, andRetry-After. - Expose
pending,running,succeeded, andfailedstates without leaking internal errors. - On completion, return a result or
303 See Otherto the created resource. - Propagate the correlation ID through the operation record, message or workflow, domain events, and final response.
The operation-status route is authorized like any other route. A caller must not be able to read another tenant’s operation by guessing its ID.
Diagnose a 5xx increase
- Split failures into APIM policy errors, connectivity errors, and backend 5xx.
With
fail-on-error-status-code="true", backend errors also run the error trace fragment. - Compare the onset with API, policy, edge, identity, and backend deployments.
- Check APIM capacity and autoscale events; the gateway scales on the
Capacitymetric. - Trace representative correlation IDs end to end.
- Roll back the responsible IaC change when evidence supports it. Do not weaken authentication or capability checks to restore traffic.
- Record the failure mode and add a regression test or alert improvement.
See Deployment and debugging for the full failure-isolation table.