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:
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)), ], }, ) ```
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:
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
)
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:
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:
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!
[SOLVED] Permissions in create_operations() Python SDK
Permissions in create_operations() Python SDK
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...
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.
Recommended threads
- Can't connect GitHub — 500 error at the ...
Appwrite Cloud, Pro plan, SFO region. All my Git connections vanished today — Sites and all 15 Functions now show no repository connected. When I try to add a ...
- GB Hours IS NOT resetting
Hi, I was checking my usage and noticed that all of my usage quotas were reset on August 20, 2026, when my billing cycle renewed. Everything else appears to ha...
- Confused about Appwrite Pro pricing
Hi. I've been subscribed to the $25 Appwrite Pro plan, but I've been getting charged $40. I have two projects on my account. I was wondering where exactly the e...