05 Enterprise administration and integrations · Advanced

Automate with the API, webhooks and a CI release gate

Create a scoped API key, send signed webhooks to your own systems, and fail a release in CI when risk is too high.

Enterprise Lesson 5 of 8 4 min Updated

In this lesson you will learn

  • How API keys and scopes work
  • Which events webhooks send
  • How the release gate decides pass or fail

Threat modeling in your pipeline

The REST API lets pipelines, scripts and internal tools read and update threat models without a person signing in. Webhooks tell your systems when something happens. The release gate turns your risk policy into a pass or fail for a deployment.

Steps

  1. Create an API key

    In Settings, API keys, click New API key. Name it, pick its scopes (for example forests:read and risks:read), and optionally an expiry, the forests it may reach and the IP addresses it may be used from. Copy the key when it's shown: it isn't shown again. Store it as a secret in your CI system.

    ThreatTree's API keys settings with a key named CI release gate (payments service), scopes forests:read and risks:read, all forests, never expires, with Rotate and Revoke buttons.
    A read-only key for a CI release gate.
  2. Add a webhook

    In Settings, Webhooks, click Add webhook, enter an HTTPS URL and tick the events it should receive: a risk becoming high or critical, a model submitted, approved or sent back, threats flagged for re-review, comments, mitigations, imports and diagram changes. Each request is signed; check the signature with the secret shown when you create it.

    ThreatTree's Webhooks settings with an active webhook to a SOAR endpoint for high or critical risks and threats flagged for review, with Send test, Deliveries, Edit, Turn off and New secret buttons.
    A webhook that tells your SOAR about new critical risks.
  3. Gate releases in CI

    Call the release gate for a forest from your pipeline. It fails when an open risk is at or above max_severity (High by default), and optionally when the model isn't approved or threats wait for re-review. It returns the reasons as JSON, or as SARIF for GitHub code scanning. The API documentation has GitHub Actions and Azure Pipelines examples.

People keep the big decisions. The API follows the app's rules: approving a model, signing off an accepted risk, deleting a forest and restoring a backup stay with people in the app.

Practice

Try it

Create an API key with risks:read for one forest, store it as a CI secret, and add the release gate to a pipeline with max_severity set to high.

This lesson covers Enterprise features. Not on Enterprise yet? Talk to us about Enterprise.

Open API keys

Quiz

Check what you learned

Three quick questions. Your answers stay in this browser.

1 Who owns an API key?
2 When does the release gate fail by default?
3 Can an API key approve a threat model?