<@U04UQ68083H> what is this API? make an example "...
# ory-copilot
m
@chilly-king-10285 what is this API? make an example "Check the syntax of an OPL file" post /admin/relation-tuples
b
A message from kapa.ai
The API "Check the syntax of an OPL file" is used to validate the syntax of an Ory Permission Language (OPL) file. OPL is a TypeScript-based language used to define permission models in Ory Permissions (Ory Keto). This API helps ensure that your OPL configuration is free of syntax errors before applying it to your permission system. The relevant endpoint is:
Copy code
POST /opl/syntax/check
- The OPL file content should be sent as plain text in the request body. - The response will include any syntax errors found in the OPL file, including their location and error message. Example request:
Copy code
http POST /opl/syntax/check Content-Type: text/plain  import { Namespace, Context } from "@ory/keto-namespace-types"  class User implements Namespace {}  class Document implements Namespace {   related: {     editors: User[]     viewers: User[]   }    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),   } }
Example response (if there are no syntax errors):
Copy code
json {   "errors": [] }
Example response (if there are syntax errors):
Copy code
json {   "errors": [     {       "message": "Unexpected token",       "start": { "Line": 5, "column": 10 },       "end": { "Line": 5, "column": 11 }     }   ] }
Note: The endpoint is
/opl/syntax/check
, not
/admin/relation-tuples
. There is no information in the knowledge sources about a POST
/admin/relation-tuples
endpoint for checking OPL syntax. The correct endpoint for OPL syntax checking is as described above [Ory API Reference](https://www.ory.sh/docs/reference/api) [Ory Keto REST API Reference](https://www.ory.sh/docs/keto/reference/rest-api).
m
what this does? example relation-tuples/batch/check