Skip to content
Back

Bug Report: Dynamic API Keys Cannot Create Documents with User-Specific Permissions

  • 0
  • Self Hosted
  • Databases
Leminh
9 Sep, 2025, 16:31

Reproduction Steps

  1. Create an Appwrite function (note: not triggered by a user)
  2. Initialize client with dynamic API key parsed from x-appwrite-key header
  3. Set function scopes to include documents.write
  4. Try to create a document with user-specific permissions:
TypeScript
await databases.create_document(
  database_id,
  collection_idd,
  ID.unique(),
  data,
  [Permission.read(Role.user(user_id))] # This fails with dynamic keys
)
  1. Create a manual API key with documents.write scope
  2. 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:

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.

TL;DR
Dynamic API keys with documents.write scope cannot create documents with user-specific permissions as expected. This inconsistency has been reported multiple times in the community. A workaround is to use manual API keys instead.
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