Back

[SOLVED] Appwrite CLI: How to add permissions to a collection

  • 0
  • Tools
  • Databases
LaurentLP
11 Dec, 2023, 10:31

Hello, I am trying to create collections with the Appwrite CLI, but I can't manage to find the right format for permissions : appwrite databases createCollection --databaseId "my_database_id" --collectionId "my_collection_id" --name "My Collection" --permissions "read"

I get either : ✗ Error Invalid permissions: Invalid permission string format: "read". or : ✗ Error Invalid permissions: Permission "Permission.read(Role.any())" is not allowed. Must be one of: create, read, update, delete, write.

How can I set my permissions with the correct roles? In a more general matter, is there any documentation on Appwrite CLI commands, with examples and correct formats for Windows cmd/powershell?

Thanks in advance fellow appwriters!

TL;DR
Title: [SOLVED] Appwrite CLI: How to add permissions to a collection; Messages: - There's an example of how to pass arrays (specifically permissions) in the CLI's readme. - One user shared their successful format for adding permissions to a collection. - Another user shared their format for adding multiple permissions to a project key. - The solution is to append additional values next to the first one, separated by a space. - One user encountered errors with incorrect permission formats and limited allowed permissions. - The correct format for permissions is `create("any")` or `read("any")`. - No specific
Ernest
11 Dec, 2023, 10:52

This is how you can achieve it. Note that for flags that are arrays (e.g permissions and queries) just append the same flag with additional values.

appwrite databases createCollection --databaseId "db_id' --collectionId "collection_id" --name "new collection" --permissions="create(\"any\")" --permissions="read(\"any\")"

LaurentLP
11 Dec, 2023, 14:07

Thanks a lot for your reply! For me it worked with the following format: appwrite databases createCollection --databaseId "my_database_id" --collectionId "my_collection_id" --name "My Collection" --permissions 'create(\"any\")' --permissions 'read(\"any\")'

I've been stuck for a long time on arrays and I solved it like that (just appending additional values next to the first one, separated by a space): appwrite projects createKey --projectId "test_project_id" --name "test_project_api_key" --scopes "users.read" "users.write" "teams.read" "teams.write" "databases.read" "databases.write" "collections.read" "collections.write" "attributes.read" "attributes.write"

Ernest
11 Dec, 2023, 14:14

Yeah, I've also been stumped with the arrays for a while now. I plan on contributing a few examples to the cli docs because it sorely lacks it.

Drake
11 Dec, 2023, 16:14

FYI, there's an example of how to pass arrays (specifically permissions) under Usage of the readme: https://github.com/appwrite/sdk-for-cli/tree/master?tab=readme-ov-file#usage

Drake
11 Dec, 2023, 16:14

[SOLVED] Appwrite CLI: How to add permissions to a collection

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more