bland-finland-95044
04/10/2025, 6:10 PMgroup:admins#member@user:john
brief-egg-61061
04/10/2025, 6:10 PMbrief-egg-61061
04/10/2025, 6:10 PMgroup:admins#member@user:john
, you can use the Ory CLI. Here's how to do it: ## Creating Relationships You can create relationships using the Ory CLI in several ways: 1. Using echo and pipe: bash echo "groups:devs#member@tom" \ | ory parse relation-tuples --project <project-id> --workspace <workspace-id> --format=json \ | ory create relation-tuples --project <project-id> --workspace <workspace-id>
[Configure Ory Permissions](https://www.ory.sh/docs/guides/cli/configure-permission-service#manage-relation-tuples) 2. Using a JSON file: Create a JSON file with your relationships and then use the ory create relationships
command: bash ory create relationships relationships.json
[Get started with Ory Permissions](https://www.ory.sh/docs/guides/permissions/overview#example) The JSON file should contain your relationships in the proper format. 3. Using the ory create relationships
command: This command allows you to create relationships from JSON files. You can either provide a file or use standard input: bash ory create relationships [flags]
[Ory CLI Reference](https://www.ory.sh/docs/cli/ory-create-relationships#ory-create-relationships) ## Relationship Format The relationship format you're looking for follows this pattern: namespace:object#relation@subject
Where: - namespace
is the type of object (like "group") - object
is the specific instance (like "admins") - relation
is the relationship type (like "member") - subject
is who has this relationship (like "user:john") ## Viewing Relationships After creating relationships, you can list them to verify they were created correctly: bash ory list relation-tuples --project <project-id> --workspace <workspace-id>
[Configure Ory Permissions](https://www.ory.sh/docs/guides/cli/configure-permission-service#manage-relation-tuples) Remember to replace <project-id>
and <workspace-id>
with your actual project and workspace IDs.bland-finland-95044
04/10/2025, 6:11 PMbrief-egg-61061
04/10/2025, 6:11 PMbrief-egg-61061
04/10/2025, 6:11 PMgroup:admins#member@user:john
, you can use the Ory API or the Ory CLI. Here's how to do it: ## Using the Ory CLI You can list relationships using the Ory CLI with the following command: bash ory list relation-tuples --project <project-id> --workspace <workspace-id>
[Configure Ory Permissions](https://www.ory.sh/docs/guides/cli/configure-permission-service#manage-relation-tuples) This will return your relationships in a tabular format: NAMESPACE OBJECT RELATION NAME SUBJECT groups devs member tom NEXT PAGE TOKEN IS LAST PAGE true
## Using the Ory API You can also retrieve relationships using the Ory API by making a GET request to the /relation-tuples
endpoint: ### API Endpoint GET /relation-tuples
[Ory API Reference](https://www.ory.sh/docs/reference/api) ### Query Parameters You can filter the relationships by providing these optional parameters: - namespace
- Namespace of the Relationship - object
- Object of the Relationship - relation
- Relation of the Relationship - subject_id
- SubjectID of the Relationship - subject_set.namespace
, subject_set.object
, subject_set.relation
- For Subject Set filtering - page_token
- For pagination - page_size
- Number of results per page ### Example Request GET /relation-tuples?namespace=group&object=admins&relation=member
The API will return a JSON response with the relationships that match your query criteria. ### Authentication To perform this operation, you must be authenticated using an Ory Access Token: Authorization: Bearer <your-access-token>
[Ory API Reference](https://www.ory.sh/docs/reference/api) ## Response Format The API response will be in JSON format, which you may need to parse to get the specific format you want (group:admins#member@user:john
). The response structure includes: json { "relation_tuples": [ { "namespace": "group", "object": "admins", "relation": "member", "subject_id": "user:john" } ], "next_page_token": "" }
You would need to transform this JSON response into your desired string format. Remember to replace <project-id>
and <workspace-id>
with your actual project and workspace IDs when using the CLI.