Back up and maintain
Back up
Copy the data folder while the daemon is stopped. Stop it the way you started it:
| Started with | Stop it |
|---|---|
wx daemon start | wx daemon stop |
systemd (wx daemon install) | systemctl --user stop agent-wechat-native |
| Docker Compose | docker compose stop |
Then archive the folder:
tar -czf wechat-backup.tgz -C ~ .local/share/agent-wechatIf you logged in with --official, the WeChat files live outside that folder. Add them to the command:
tar -czf wechat-backup.tgz -C ~ .local/share/agent-wechat xwechat_files .xwechatBack up both. The data folder holds queued sends and recall records, but not chat history. The WeChat profile holds the history, but without the data folder you lose the rest.
With Docker Compose, the data folder is the native-data volume (/var/lib/agent-wechat in the container), not a folder in your home directory. Back up that volume instead. If you use OpenClaw, also back up its consumerStateDir; it records where OpenClaw is in the message stream.
Upgrade
Back up first. An upgrade can change the data folder’s format, and an older wx can’t open a folder a newer version has upgraded. See Storage and backups.
-
Install the new version with the same method you used to install it.
Terminal window npm install -g --allow-scripts=@agent-wechat/cli @agent-wechat/cliTerminal window pnpm add -g @agent-wechat/clipnpm approve-builds -g # select @agent-wechat/cliDownload the new file from the latest release, check its SHA-256 against
wx-vVERSION-checksums.json, and replace the oldwxon yourPATH.Terminal window docker pull ghcr.io/thisnick/agent-wechat-native:latestThis is the tag Keep it running tells you to use in
compose.yaml. Pre-release versions don’t updatelatest. -
Restart the daemon so it runs the new version.
Terminal window wx daemon restartwx --json versionwx daemon restartalso restarts the systemd service made bywx daemon install. With Docker Compose, rundocker compose pullanddocker compose up -dto recreate the container from the new image. If OpenClaw runs the daemon for you (managed mode), restart the Gateway.
Sign out or remove a profile
List profiles with wx accounts list. Use the account ID from that response:
wx --account ACCOUNT_ID auth loginwx --account ACCOUNT_ID auth logoutUse wx --account ACCOUNT_ID auth logout --local to sign out on the daemon and keep saved credentials without sending a logout request to WeChat. Both forms stop automatic reconnection.
After sign-out completes, remove the profile from the hub by repeating its exact ID:
wx accounts remove ACCOUNT_ID --confirm ACCOUNT_ID{ "accountId": "ACCOUNT_ID", "removed": true, "filesRetained": true }Removal unregisters the profile and keeps its local files. wx auth forget --yes is a separate action that forgets saved sign-in credentials; it does not remove the profile.
Rotate or revoke API tokens
-
Create a token for the new client, limited to the account and scopes it needs. See API tokens for the scope list.
Terminal window wx tokens create my-script --accounts ACCOUNT_ID --scopes read --scopes sendThe token is printed once, in the
tokenfield. Store it in your client’s configuration. -
Find the old token’s ID and revoke it.
Terminal window wx tokens listwx tokens revoke TOKEN_ID
Change where data is kept
wx doesn’t move any files when you change the location. A new folder starts empty, with a new owner API token and no profiles, unless you copy the old data there first.
- Stop the daemon and back up the data folder (see Back up).
- Copy the data folder to the new location yourself.
- Set the new location with
dataDirin~/.config/agent-wechat/server/config.toml, or pass--data-dirtowx. See Configuration. - Start the daemon and check
wx accounts list.
Profiles added with --official stay where they are; only the data folder moves.
The default location for each platform is in Storage and backups.