Before you start: this requires a Tyk license with API Governance enabled. Without the license’s governance scope, every governance endpoint, including this one, returns 403 Forbidden, regardless of the token’s own permissions. Contact your Tyk account team to have it enabled.
For the underlying endpoint itself, including request and response schemas, limits, and error codes, see the Governance Evaluation API reference.
Set Up the Check
The fastest way to get a governance check running is a small reference script. It is a thin wrapper around one API call, so it works the same way in any CI system.Step 1: Get the Script
Copy the script below into your repo, for example asscripts/governance-check.sh, and make it executable with chmod +x scripts/governance-check.sh.
It takes a spec file plus either --categories or --ruleset-ids, and optionally --api-id, --api-name, and --strictness. It requires curl and jq, and reads TYK_DASHBOARD_URL and TYK_DASHBOARD_TOKEN from the environment.
What it does, in order: posts the spec to the sandbox endpoint, prints the full JSON result, fails outright if the response could not be parsed or came back truncated, then sums Error and Warn counts across only those rulesets whose action is not none and exits according to your strictness setting.
Step 2: Add It to Your Pipeline
Drop a step into your existing pipeline configuration that calls the script. The script itself does not change between platforms, only the surrounding config does. GitHub Actions, a step in.github/workflows/*.yml:
.gitlab-ci.yml:
Jenkinsfile:
Step 3: Configure Authentication
TYK_DASHBOARD_TOKEN is the standard Tyk Dashboard user API token, the same one used to call any other Dashboard API endpoint such as GET /api/apis or POST /api/apis/oas. It is not a separate governance-specific credential. Find it in Tyk Dashboard under your user profile’s API Access Credentials.
The token inherits that user’s permissions, and because the sandbox endpoints are exposed as POST requests, the token’s user needs apis: write permission, not just apis: read.
Use a dedicated user and token for CI rather than a personal one, and set both TYK_DASHBOARD_TOKEN and TYK_DASHBOARD_URL as secrets in your CI provider, using GitHub Actions secrets, GitLab CI/CD variables, Jenkins credentials, or the equivalent. Never commit them to the repo.
Step 4: Point It at Your Spec and Ruleset
The script needs two things, passed as arguments in the pipeline step above:- Which spec file to check. The OAS file already in your repo, for example
openapi.yaml. It does not need to be imported into Tyk Dashboard. - Which rulesets to check it against, either
--categories, meaning the categories your governance owner has linked rulesets to, resolved at check time, or--ruleset-ids, meaning specific ruleset IDs if you want a fixed set regardless of category changes. Pick one. See Best Practices for when to use which.
--api-id is optional but recommended. It keeps issue IDs stable across commits instead of changing every time the file is edited. You can also pass --api-name for a human-readable label in the response; it is purely cosmetic and has no effect on gating.
Not sure what to pass for categories or ruleset IDs? Both are visible in Tyk Dashboard under Governance > Rulesets: each ruleset’s detail page shows its linked categories and its ID. To script the lookup instead, GET /api/rulesets lists every ruleset in your organization along with its categories.
Step 5: Choose Your Strictness Level
Add--strictness strict or --strictness permissive if the default does not match your team’s policy:
strict: fails the build on any Error or Warn severity issue.standard(the default): fails the build only on Error severity issues, matching how compliance is defined in Tyk Dashboard.permissive: never fails on severity, and only reports, like Tyk Dashboard’s own soft warning. Useful while you are first rolling this out to a team and do not want it breaking builds yet.
action is not none count toward the pass or fail decision. A none ruleset is visibility-only in Tyk Dashboard too, with no Deployment Warning, so a violation on one is reported but never fails the build, regardless of strictness.
Step 6: Run the Pipeline
From here it is automatic. When a developer pushes a commit or opens a pull request, the pipeline step:- Reads the spec file.
- Sends it to the Tyk Dashboard sandbox endpoint, along with the rulesets or category.
- Gets back the list of issues, each with a severity, its exact location in the spec, and “how to fix” guidance.
- Prints the full result in the pipeline log.
- Exits
0if the result passes your strictness setting, or non-zero if it does not, stopping the pipeline there.
--strictness permissive against a spec you suspect has issues. It prints the same result without ever exiting non-zero, which is a safe way to try this out before switching to standard or strict.
Step 7: Fix and Re-Run
If the check fails, read thehow_to_fix text on each failing issue, which points to exactly where in the spec the problem is. Make the change and push again. The check re-runs automatically on the next pipeline run.
For fixing the same issues inside Tyk Dashboard instead, see Remediate Issues.
Best Practices
- Pass
api_id. Without it, issue IDs are derived from a content hash of the spec and change on every edit, making it hard to track a specific issue across commits. Pass a stable identifier; your API or repo name works well. - Treat
truncated: trueas a failure, not a warning. Truncation only caps the itemized issue list at the top 1,000 entries;error_count,warn_countstay accurate regardless. So the build fails or passes either way correctly; what you lose is visibility into every issue’s exact location andhow_to_fixguidance past the cutoff. Fail the build and narrow the ruleset or category scope so you can actually see and fix everything, rather than working from a partial list. - Choose
ruleset_idswhen you want a fixed, explicit set of checks, for example a security baseline every pipeline must pass regardless of what else is active in the organization. Choosecategorieswhen you want the pipeline to pick up whatever rulesets a platform team currently has linked to that category, so CI tracks the same governance scope Tyk Dashboard applies without pipeline config changes every time a ruleset changes. Note that category-based resolution returns only active, non-template rulesets; to test against a ruleset still marked as a template, reference it explicitly withruleset_ids. - Use a dedicated token for CI, not a personal one. Create or designate a user for pipeline use with
apis: writepermission, rather than reusing an individual’s personal credentials. - Store the token as a pipeline secret. Use your CI provider’s built-in secrets manager rather than committing it or passing it as a plain environment variable in a script.
FAQ
Does this import my API into Tyk Dashboard?
Does this import my API into Tyk Dashboard?
No. The sandbox endpoint evaluates the submitted document and returns results. Nothing is saved, and no API record is created. It is a one-off check, not an onboarding step.
Can I evaluate an API that isn't in Tyk Dashboard yet?
Can I evaluate an API that isn't in Tyk Dashboard yet?
Yes, that is the main use case. You do not need to import or register an API before running this check, which is what makes it useful for shift-left validation on a spec that is still just a file in your repo.
Can I use this for MCP specs?
Can I use this for MCP specs?
Not yet. This endpoint currently supports Tyk OAS APIs only.
Do I need to keep a copy of the ruleset definition in my repo?
Do I need to keep a copy of the ruleset definition in my repo?
No. Rulesets live in Tyk Dashboard, and you reference them from your pipeline by
ruleset_ids or categories, so the pipeline always checks against whatever the platform team currently has configured.Why does my pipeline pass when the spec is non-compliant?
Why does my pipeline pass when the spec is non-compliant?
Almost always because the check is gating on the HTTP status code, which is
200 whenever the evaluation ran successfully, even with Error-severity issues. Violations live in the response body. See Gating Correctly in the Governance Evaluation API reference.How many categories or ruleset IDs can I pass in one call?
How many categories or ruleset IDs can I pass in one call?
Twenty of each, and category resolution is also capped at 20 resolved rulesets. This limit applies to the sandbox endpoint only, not to Tyk Dashboard. See Limits in the Governance Evaluation API reference.