Overview
PowerSync provides a HTTP endpoint/api/sync-rules/v1/deploy to update sync rules without redeploying the service.This is useful for making quick adjustments or experimenting with synchronization logic at runtime.
Usage
1. Configure API token
Add an API token to yourpowersync.yaml:
powersync.yaml
2. Deploy Sync Rules
You can deploy sync rules either from a file:200 OK response with the following body.
The slot_name identifies the newly created logical replication slot.
Troubleshooting
If you get the following error - this indicates that sync rules are already defined in yourpowersync.yaml file.
401 Unauthorized error, double-check that your API token is correct and matches the token in your config file.
Notes
Some important points to remember:
- Sync rules deployed via the API get overwritten if sync rules are later added to
powersync.yamland the service is restarted. - Keep your API token secure. Store it in an environment variable or a secure vault.