
You need to use this: https://appwrite.io/docs/server/databases?sdk=python-default#databasesListDocuments

i am inserting into a collection the session id and a time i wish for it to be deleted by the cloud function. It is so because i have a remember me checkbox on my ui. So i do need to create an api key

it depends on the permissions on the collection and document

ok for now i put any on create and delete

@Steven i noticed i was missing some params but for now here is the error i get after fixing An error occurred: HTTPConnectionPool(host='127.0.0.1', port=80): Max retries exceeded with url: /v1/databases/64a671fb266768330926/collections/64cbca90100c2734a432/documents (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff84d91a90>: Failed to establish a new connection: [Errno 111] Connection refused'))

i guess since the function are inside a container they cant point to the hoost localhost , ill try my ip

@Steven does appwrite cloud functions support env variables ? if so how can i refer to them in code ?

Did you read the docs on functions?

@Steven Not entirely no let me get back to it then

Short answer is we have function variables rather than environment variables in the current version of functions

@Steven ok let me comb the docs for it

@Steven i managed to run it and now i am stuck with a permission error An error occurred: app.649338b1262c3cbe564c@service.192.168.1.6 (role: applications) missing scope (account)
i gave all scope to my api key though

i think this snippet is the culprit # Delete the session
account = Account(client)
delete_response = account.delete_session(session_id)
print(delete_response)

You should be using the users API

@Steven with a JWT, will it work since ther is no user connected to trigger this function ? it is supposed to run with CRON automatically

If a user isn't triggering the function, you won't have a JWT token 🧐

@Steven indeed so how do i do the session deleting then ? i though i had to set up an API KEY for such a maintenance use case

Use the users API

@Steven sorry ...i confused both as Accounts ...

@Steven Let me revert as soon as i come back

@Steven It is all good now i fixed it thanks to your guidance.

[SOLVED] Python cloud function failing with Internal runtime error

is it possible to return json data in the "message" field ?

yes. if you still need help, please create a new <#1072905050399191082> post.

ok thanks
Recommended threads
- Unable to connect. Is the computer able ...
I found that there was few other support tickets with same topic, but neither of those seemed to solve my issue. I'm running a function when new user is created...
- Functions rate limit
Is there a way to remove function rate limit for specific users? "2025-06-01T08:45:26.143734953Z [Error] Method: POST 2025-06-01T08:45:26.143738753Z [Error] UR...
- Can't create a function. The user interf...
I am trying to create a server-side function. I am on the free tier. **I already have three functions that work properly** that I created a few months ago. Now,...
