Bug Report: Dynamic API Keys Cannot Create Documents with User-Specific Permissions
- 0
- Self Hosted
- Databases

Reproduction Steps
- Create an Appwrite function (note: not triggered by a user)
- Initialize client with dynamic API key parsed from
x-appwrite-key
header - Set function scopes to include
documents.write
- Try to create a document with user-specific permissions:
await databases.create_document(
database_id,
collection_idd,
ID.unique(),
data,
[Permission.read(Role.user(user_id))] # This fails with dynamic keys
)
- Create a manual API key with
documents.write
scope - Use manual API key with same code - it works
Expected Behavior
Dynamic API keys with documents.write
scope should have identical capabilities to manual API keys with the same scope.
Actual Behavior
- Dynamic API key: Fails with user_unauthorized, Permissions must be one of: (any, guests)
- Manual API key: Successfully creates documents with
Permission.read(Role.user(userId))
Environment
- Platform: Appwrite version 1.7.4
- SDK: Python SDK version 11.1.0
- Function Runtime: Python 3.9
- Collection: Document security enabled
Additional Context
Discord community evidence:
- https://discord.com/channels/564160730845151244/1333457180149678251/1333457180149678251: User with dynamic key fails, manual API key with documents.write works. Appwrite member: "still not sure why the function scopes didn't work"
- https://discord.com/channels/564160730845151244/1345011727451947120/1345011727451947120: Another user reports identical error: "Permissions must be one of: (any, guests)" with dynamic key having full database scope
Note: This issue has been reported multiple times in the community but the root cause of this inconsistency between dynamic and manual API keys has not been addressed. The underlying problem of why keys with identical scopes behave differently remains unresolved.
Current workaround: Create manual API key with documents.write scope, but this defeats the benefits of using dynamic keys.
Recommended threads
- Unable to Create Relation Attribute in A...
Hello, I’m running a self-hosted Appwrite v1.7.4 instance on my server. I want to create a relation attribute between two collections in the console, but the co...
- Having permission issues with imported s...
Hello, I have my self hosted project on a server, and i wanted to import the schema to my local machine dev instance so I used the json file from the server ...
- Document ID already exists error with ID...
**Problem Summary** I'm building a React Native app with Expo and trying to create profile documents in Appwrite when users sign up. I keep getting this error: ...
