Transcend Docs

Policy Engine

Run your own policies against a user's stored preferences and get an allow, deny, or escalate decision for each purpose.

Policy Engine answers one question for your applications: may we use this person's data for this purpose? You write the rules as code. Transcend runs them against the person's stored preferences and returns a decision for each purpose.

Use Policy Engine when a stored opt-in or opt-out is not enough to decide. For example, you can deny a purpose in one region, require a recent choice, or send unclear cases to review.

How it works

Your application calls the Permissions API on Sombra with a user identifier and optional context, such as the user's region. Sombra loads the user's preference record from the Preference Store. It adds every configured purpose, including the ones the user never set. Sombra then runs your active policy and returns its decisions.

Policies are written in Rego, the policy language of Open Policy Agent (OPA). Policy Engine uses Rego v1. Sombra runs your policies with OPA, so your application never calls OPA directly. Transcend meters each successful Permissions API call as one decision.

Bundles, versions, and activation

You ship policies as a bundle: a folder with an OPA .manifest file, .rego files, and optional data.json files.

  • Upload creates an immutable bundle version. A new version does nothing until you activate it.
  • Activate makes one version live. Each bundle has at most one active version.
  • Roll back by activating an earlier version. Every uploaded version stays available.
  • Deactivate stops serving the bundle. Calls that need it then fail.

The Permissions API reads only the bundle named permissions. Publish your Permissions policy under that name.

Transcend rejects an upload when the compressed bundle is larger than 5 KB or the uncompressed files total more than 50 KB. Transcend also checks every .rego file and rejects a bundle that does not compile.

Package names

Write packages under the root your .manifest declares, such as package permissions.purposes.analytics. Transcend moves each bundle into a private namespace for your organization when it loads. A policy can read data only from its own bundle.

Policy input

Sombra builds the input document. Your application supplies only context. The input matches a published JSON Schema, which the Transcend CLI copies into each Permissions bundle as input.schema.json.

Prop

Type

Each entry in preferences has these fields:

Prop

Type

For example:

{
  "preferences": [
    {
      "name": "Analytics",
      "choice": true,
      "days_since_choice": 42
    },
    {
      "name": "SaleOfInfo",
      "choice": null
    }
  ],
  "context": {
    "region": "US-CA"
  }
}

Policy result

Sombra evaluates the purposes package under your bundle root, such as data.permissions.purposes. Each child package is one purpose. Its last name segment becomes the key in the response.

Each purpose package must define a result object with a decision field:

decisionMeaning
allowYour application may use the data for this purpose.
denyYour application may not use the data for this purpose.
escalateYour policy cannot decide. Send the case for review.

Other fields in result, such as reason_code, pass through to the caller unchanged. A policy that evaluates the example input above can return:

{
  "result": {
    "analytics": {
      "result": { "decision": "allow", "reason_code": "explicit_allow" }
    },
    "sale_of_info": {
      "result": { "decision": "escalate", "reason_code": "undecided_in_california" }
    }
  },
  "decision_id": "50602cdf-43b9-4cf7-b669-c77b2f6b1082"
}

Every key under purposes must be a purpose package with a result. A helper rule placed directly in the purposes package breaks the response. Put helpers in a separate package, such as permissions.helpers.

Failure behavior

Policy Engine fails closed. When it cannot produce a valid decision, the Permissions API returns an error instead of a guess. Treat any response other than 200 as "not permitted."

StatusCause
400The request body is invalid, or the identifier is not configured or matches more than one record.
503No permissions bundle is active, or Sombra is still loading your bundle.
503A purpose has no valid result.decision. The error says Policy engine returned an invalid result.

The first request for your organization after Sombra starts can return 503 for a few seconds while your bundle loads. Retry with a short backoff. A newly activated version also takes effect after a short delay.

Scopes

Policy Engine uses three scopes. Each scope includes the one above it.

TitleDescriptionTypeProductsDependencies
View PolicyView Policy Engine policy bundles and their versions.ViewPolicy Engine
    Manage PolicyCreate and upload Policy Engine policy bundles and versions. Uploaded versions are inert until activated.ModifyPolicy Engine
    • View Policy
    Activate PolicyActivate a Policy Engine bundle version, making it the live policy. Includes all Manage Policy permissions.ModifyPolicy Engine
    • Manage Policy

    The Permissions API reads preference records, so its API key needs one of these scopes:

    TitleDescriptionTypeProductsDependencies
    View Managed Consent Database Admin APIAbility to query user consent preferences with the Managed Consent Database Admin APIViewConsent Management, Preference Management
      Modify User Stored PreferencesAbility to make updates to user stored consent preferencesModifyConsent Management, Preference Management
      • View Managed Consent Database Admin API

      Guides

      On this page