<@U04UQ68083H> I want to periodically clean all ol...
# ory-copilot
g
@chilly-king-10285 I want to periodically clean all old sessions so we comply with privacy regulations by deleting the related device information. I would like to do this via the api. Is this possible?
c
A message from kapa.ai
New message text here
g
@chilly-king-10285 is there any way to do this in a more efficient way in bulk? I notice the cli clear command that might achieve something similar?
c
A message from kapa.ai
The Ory CLI does provide a
delete
command that can be used to delete resources. However, based on the provided knowledge sources, it does not appear to support bulk deletion of sessions. The
delete
command can be used to delete resources like access tokens, event streams, identities, JSON Web Key Sets, OAuth 2.0 Clients, organizations, and relationships, but there's no explicit mention of sessions. Here's the general usage of the
delete
command:
Copy code
bash ory delete [flags]
Options include:
Copy code
bash  -c, --config string Path to the Ory Network configuration file.    --format string Set the output format. One of default, json, yaml, json-pretty, jsonpath and jsonpointer. (default "default")    -h, --help help for delete    -q, --quiet Be quiet with output printing.    -y, --yes Confirm all dialogs with yes.
You can find more information about the
delete
command in the [Ory CLI documentation](https://www.ory.sh/docs/cli/ory-delete#ory-delete). For bulk deletion of sessions, you might need to write a script that iterates over all the identities and calls the
deleteIdentitySessions
API for each one. Please note that this operation should be done with caution as it will forcefully log out users and delete all their session data. Remember to always comply with GDPR and other privacy regulations when handling user data.