Skip to main content

Learn Rego by Example


This section provides examples of specific Rego features and functions to accelerate your Rego development. If you're just getting started, you might be find the free 'OPA by Example' course a useful as a guided introduction to Rego.

Rego1 is a domain specific policy language designed to help policy authors express policy logic in a clear and concise way. Rego targets a number of domains where policy is required, including, but not limited to, application authorization.

Rego's ancestory lies with Datalog, but Rego adds many new features to make it practical for use in modern security policy use cases such as native support for structured JSON data. Datalog's declarative nature lives on in Rego however, helping authors focus on what policies can express rather than how to execute them.

As you will soon see, such languages are well suited to policy use cases. However, declarative languages are often misunderstood. This sections aims to help new Rego policy authors learn the language by providing practical examples of common contact points.


Interested to see just how much more expressive Rego can be for policy code? Check out the section on Rego Language Comparisons to see how Rego stacks up against general purpose languages.

Take a look into any of the following sections to get started:


  1. Read more about Rego in in the OPA docs