Deploying applications on Unkey is in public beta. To try it, select
Projects in the dashboard sidebar and create a project. Deployed
resources are free until August 1, 2026. We’re eager for feedback, so let us
know what you think on Discord,
X, or email
support@unkey.com.
Policy structure
Every policy has four components:
You can disable a policy by setting
enabled to false. This is useful during incidents when you need to bypass a misbehaving policy without deleting its configuration or triggering a redeploy.
Evaluation order
The gateway evaluates policies in the order they appear in the configuration:- Skip the policy if
enabledisfalse. - Evaluate all match conditions. Skip the policy if any condition doesn’t match the request.
- Execute the policy action. If the action rejects the request, return an error response immediately.
- Move to the next policy.
Match expressions
Match expressions control which requests a policy applies to. You can add match conditions when creating or editing a policy in your project’s policy settings in the dashboard. A policy can have multiple match conditions, and all conditions must match for the policy to run (AND logic). An empty match list applies the policy to all requests.Available match types
All string matching supports three modes:
- Exact: The value must match exactly (for example,
/healthz) - Prefix: The value must start with the specified string (for example,
/api/v1) - Regex: The value must match an RE2 regular expression (for example,
^/users/[0-9]+$)
Combine conditions
To create AND conditions, add multiple match expressions to a single policy. All expressions must match for the policy to run. To create OR conditions, create separate policies with the same action but different match expressions.Policy types
Error response format
When a policy rejects a request, the gateway returns a structured JSON error following the RFC 7807 Problem Details format:type URI is stable per error kind and suitable for programmatic handling. Each policy type maps to a standard HTTP status code: