
In my web, I try to create a contact form that allow every visitor can leave a message to specified user.
- Anyone can create message => Anyone can create a document in my
Contact Message
Collection - In the form, I create an input or dropdown to select the person that is receiver ( In example is User
5c1f88b42259e
)
import { Client, Databases, Permission, Role } from "appwrite";
const client = new Client()
.setEndpoint('<APPWRITE_ENDPONT>')
.setProject('<PROJECT_ID>');
const databases = new Databases(client);
let promise = databases.createDocument(
'<DATABASE_ID>',
'<COLLECTION_ID>',
{'actorName': 'Chris Evans', 'height': 183},
[
Permission.read(Role.user("5c1f88b42259e")), // User 5c1f88b42259e can view this document
Permission.delete(Role.user("5c1f88b42259e")), // User 5c1f88b42259e can delete this document
Permission.delete(Role.team("admin")) // Admins can delete this document
]
);
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
In my Contact Message
Collection, I turn on Document security
option and set Any
can create document.
When submit form, it give Error: User session not found.
Can anyone give some solutions or examples?

I think in the response it will show you who can create permissions for. It's not possible to create permissions for another user.

Thank you for response. For anyone come to this topic later, I do some research and found the explanation video
Recommended threads
- Appwrite functions can't connect to data...
I'm trying to create a function that queries my database, but all database operations timeout from within the function, even though CLI access works perfectly. ...
- Sharing cookies
Hi, I’m using Appwrite Cloud, and I have a setup where my Appwrite backend is hosted on a subdomain (e.g., api.example.com), while my frontend (Next.js app) and...
- Organization not exists anymore
Hello! We have a problem with a cloud database. We are on the Free plan, but after a refresh the site wants me to create a new organisation, and I not see the c...
