API contract (OpenAPI)
Upload an OpenAPI document for a route and the gateway validates every request against it before it reaches your API. This is a positive security model: only what the API describes is allowed through.

Setting it up
In the route editor → API contract → Add an API contract:
- Upload a JSON or YAML file (OpenAPI 3.0, 3.1 or 3.2; at most 5 MB; all references must be in the one file) or paste the text.
- The page shows the operations found, the base path, and any warnings.
- The contract starts in Log only — every request is forwarded and the request log shows "Would be refused by the API contract" with the reason.
Watch the request log for a few days of normal use. Each "would be refused" entry from a real client means the description is incomplete. Fix the description and upload it again. When the log stays quiet, switch to Enforce.
What is validated
- The endpoint: method and path must be in the contract (else
404or403) - Parameters (path, query, header, cookie): required ones present, correct type and format, enum, length, range
- The body: correct content type (
415if not), JSON schema (required properties, types,additionalProperties: false, arrays, nested objects) - Credentials: API key header, query parameter or cookie, or Authorization header must be present (token validation is separate)
Modes
| Mode | What happens |
|---|---|
| Log only (default after upload) | Requests are forwarded; violations are logged |
| Enforce | Requests that break the contract get 400, 404, 403 or 415 |
| Off | The document is kept but not used |
Violations page
The contract page lists violations of the last 24 hours, 7 or 30 days, grouped by operation and reason, with counts and links to the request log. Use this to find what to complete before switching to Enforce.
Response checking
Responses are always checked in log-only mode: a status or content type the API does not describe, or a JSON field the response schema does not list (a potential data leak such as passwordHash), appears in the request log. The response is never delayed or blocked.
Example: protecting an API with its OpenAPI document
Your API publishes its document at https://api.example.com/swagger/v1/swagger.json. Download it and save it as api-contract.json.
- Open the route for
api.example.com→ API contract → Add an API contract → uploadapi-contract.json. - The page shows the 23 operations found.
- Leave it in Log only for a week. The request log shows "Would be refused" for 2 operations — a client sends an extra field (
isAdmin). Fix the description: addadditionalProperties: falseto that schema object. - Upload the updated document. The log is clean.
- Switch to Enforce. Any request with an unknown field, missing required parameter, or wrong type gets
400.