<@U04UQ68083H> How can i use the Ory Permission La...
# ory-copilot
h
@chilly-king-10285 How can i use the Ory Permission Language in self-hosted ory service
c
A message from kapa.ai
The Ory Permission Language (OPL) is a developer-friendly configuration language that you can use to create permission rules for your application. It is defined as a subset of TypeScript and is designed to be quick to learn. You can create permission rules with OPL using the Ory Console. Here is an example of OPL code:
Copy code
typescript import { Namespace, Context } from "@ory/keto-namespace-types"      class User implements Namespace {}      class Document implements Namespace {    // All relationships for a single document.    related: {    editors: User[]    viewers: User[]    }       // The permissions derived from the relationships and context.    permits = {    // A permission is a function that takes the context and returns a boolean. It can reference `this.related` and `this.permits`.    write: (ctx: Context): boolean => this.related.editors.includes(ctx.subject),    read: (ctx: Context): boolean => this.permits.write(ctx) || this.related.viewers.includes(ctx.subject),    }   }
For self-hosting Ory services, you should use the respective client. More information about self-hosting can be found in the [self-hosting documentation](https://www.ory.sh/docs/ecosystem/projects) for each service under Reference/SDK. Before using the SDK, consult the Ory [REST API documentation](https://www.ory.sh/docs/reference/api), which includes code samples and examples for various programming languages. Sources: - [Ory Permission Language](https://www.ory.sh/docs/keto#ory-permission-language) - [Ory SDK](https://www.ory.sh/docs/sdk)