Skip to content
Back

[SOLVED] - How to set permissions using the createOperations function?

  • 0
  • Resolved
  • 2
  • Databases
  • Web
  • REST API
jonathan_4685
2 Jan, 2026, 00:41

Hi, I'm trying to create a set of registers in a table using the tableDB.createOperations function, but it seems like it doesnt support/expect the usage of the permissions array, similar to what we have when creating a row.

Something like this below:

TypeScript
const operations = [{
  action: 'create' as const,
  databaseId: DATABASE_ID,
  tableId: TABLE_ID,
  rowId: rowId,
  data: registerData,
  permissions: [
    Permission.read(Role.user(userId)),
    Permission.update(Role.user(userId))
  ]
}]

await tablesDB.createOperations({
  transactionId: tx.$id,
  operations,
})

When I execute the flow, it creates all the operations, but ignoring the permissions array, which is creating a situation where the users dont have access to their own rows.

Do you know if it's possible to define this permissions array using these operations? If it's not possible, how are you handling situations with Row Security where you need to create a bunch of rows at once?

TL;DR
Passing permissions within data as `$permissions` instead of `permissions` fixed the issue with setting permissions using the `createOperations` function.
jonathan_4685
2 Jan, 2026, 00:42

How to set permissions using the createOperations function?

Guille
2 Jan, 2026, 00:58

Have you tried to set permission in data? If I'm not wrong that is how I do it in my project

2 Jan, 2026, 01:09

Just tested it and it doesnt work too. Passing it within data the appwrite throws an "AppwriteException: Invalid document structure: Unknown attribute: "permissions""" I've passed it like this now:

TypeScript
const operations = [{
  action: 'create' as const,
  databaseId: DATABASE_ID,
  tableId: TABLE_ID,
  rowId: rowId,
  data: {
    ...registerData,
    permissions: [
      Permission.read(Role.user(userId)),
      Permission.update(Role.user(userId))
    ]
  }
}]

Is this what you've suggested?

2 Jan, 2026, 11:36

it should be $permissions instead of permissions

4 Jan, 2026, 02:34

It worked <:appwriterocket:823996226894692403> Thank you so much Guille

1
4 Jan, 2026, 02:36

[SOLVED] - How to set permissions using the createOperations function?

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