Skip to content
Back

Permissions in create_operations() Python SDK

  • 0
  • 1
  • Databases
  • Cloud
flo<3ler
17 Oct, 2025, 12:38

How can I set permissions for create_operations()? What even is the correct way to use permissions in Python (using SDK version 13.4.1) ? In my cloud function creating a table works and sets the correct permissions:

TypeScript
            database_id,
            table_id=user_id,
            name=user_name,
            permissions=[
                Permission.read(Role.user(user_id)),
                Permission.write(Role.user(user_id)),
            ],
        )```

but subsequently using `create_operations()` creates a row but does not see any permissions:

tablesDB.create_operations( transaction_id=transaction_id["$id"], operations=[ { "action": "create", "databaseId": userDB_id, "tableId": os.environ["POLICY_COLL_ID"], "rowId": f"{user_id}-policy", "data": { "acceptedTimestamp": datetime_truncated }, "permissions": [ Permission.read(Role.user(user_id)), Permission.write(Role.user(user_id)), ], }, ) ```

TL;DR
The user discovered that the permissions setup that worked for `create_table()` doesn't work for `create_operations()`. They plan to switch away from `create_operations()` for now and might try a different runtime, such as Deno, where it functions as expected.
flo<3ler
17 Oct, 2025, 12:41

I realize this may be an older syntax since I can see this example in the docs at https://appwrite.io/docs/references/cloud/server-python/tablesDB:

TypeScript
result = tables_db.create_table(
    database_id = '<DATABASE_ID>',
    table_id = '<TABLE_ID>',
    name = '<NAME>',
    permissions = ["read("any")"], # optional
    row_security = False, # optional
    enabled = False # optional
)
17 Oct, 2025, 13:06

I looked at https://github.com/appwrite/sdk-for-python/blob/main/appwrite/permission.py and https://github.com/appwrite/sdk-for-python/blob/main/appwrite/role.py.

The API documentations is a bit misleading since the "any" should not have any ticks. So my function now works like this:

TypeScript
table = tablesDB.create_table(
    database_id,
    table_id=user_id,
    name=user_name,
    permissions=[
        f"read(user:{user_id})",
        f"write(user:{user_id})",
    ],
)

but his gives me the error Invalid permissions param: Invalid permission string format: "read(user:68f23ce0001235******). Using the double quotes in string like in the documentations example leads to a formatting error, which then lead to me realizing I need to format them differently.

This now works:

TypeScript
tablesDB.create_operations(
  transaction_id=transaction_id["$id"],
  operations=[
      {
          "action": "create",
          "databaseId": userDB_id,
          "tableId": os.environ["POLICY_COLL_ID"],
          "rowId": f"{user_id}-policy",
          "data": {
              "acceptedTimestamp": datetime.datetime.now(
                  datetime.timezone.utc
              ).isoformat()
          },
          "permissions": [
              f'read("user:{user_id}")',
              f'write("user:{user_id}")',
          ],
      },
  ],
)

So use single quotes on the outside and double quotes on the inside!

17 Oct, 2025, 13:06

[SOLVED] Permissions in create_operations() Python SDK

17 Oct, 2025, 13:08

Permissions in create_operations() Python SDK

17 Oct, 2025, 13:10

I now realized that this only worked for the create_table() function. Using the working string for create_table does not work for create_operations() unfortunately...

17 Oct, 2025, 13:16

Will move back away from create_operations() for now and might move the function to another runtime anyway, in Deno it works with like the documentation.

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