Sync triggers
Create a sync trigger
Add a trigger to a sync: when a record of the chosen table is created, updated or deleted in a source app and passes the filters, the action runs with the record (<<data>>) and its changes (<<changes>>). Send validate_only: true to run every check without storing.
Authorization
AuthorizationstringheaderrequiredBearer <key>, where <key> is a workspace API key or a user API key. See Authentication.
workspace_id*integerThe workspace the resources belong to
base_id*stringThe sync (a sync is called a base in these paths)
uuidregion*stringData region of the sync
"besg""usnv"The trigger to add. The example's host hooks.example.com is a placeholder: replace it with your own HTTPS endpoint; it must resolve publicly. hooks.example.com is a placeholder: replace it with your own host, which the API checks before saving (the example as written is refused).
application/json- body
A trigger of the sync: when a change of the chosen table passes the filters, the action runs
name*stringThe name of the trigger
trigger_type*stringwebhook calls a URL, db_query runs SQL on a database connection, queue adds a message to a queue
"webhook""db_query""queue"table*stringThe table whose changes fire the trigger, by its name in the column_names_from_app app (its id is accepted)
column_names_from_app*stringThe app whose column names the trigger uses: its app type as shown in Stacksync, or its app_id when both apps have the same type
operations*array<string>The changes that fire the trigger, each once: created, updated, deleted
source*array<string>The app or apps whose changes fire the trigger, by app type (or app_id when both apps have the same type); the sync must read changes from that app's table
1 <= items <= 2columns_to_ignore*array<string>Columns of the table left out of the record data the action receives (case sensitive, must exist in the table)
filters*Conditions combined with and or or; a group may hold other groups. An empty and group matches every change
action*||What runs: a cURL command (webhook), a query (db_query) or a queue message (queue)
is_paused?booleanTrue stores the trigger paused; false (the default) runs it
falsevalidate_only?booleanRun every check of the write and answer without writing: a refused write answers the error it would answer
falseThe trigger created
application/json- response
The created trigger
id*stringThe new trigger
uuidmsg*stringTrigger created successfully
curl -X POST 'https://api.stacksync.com/v1/workspaces/0/bases/497f6eca-6276-4993-bfeb-53cbbbba6f08/triggers?region=besg' \ -H 'Content-Type: application/json' \ -d '{ "name": "Notify on new customer accounts", "trigger_type": "webhook", "table": "Account", "column_names_from_app": "salesforce", "operations": [ "created", "updated" ], "source": [ "salesforce" ], "columns_to_ignore": [ "Website" ], "filters": { "type": "group", "operator": "and", "conditions": [ { "type": "condition", "column": "Type", "operator": "eq", "value": "Customer" }, { "type": "group", "operator": "or", "conditions": [ { "type": "condition", "column": "Rating", "operator": "eq", "value": "Hot" }, { "type": "condition", "column": "Website", "operator": "has_ch", "value": "" } ] } ] }, "action": "curl -X POST https://hooks.example.com/accounts -H '\''Content-Type: application/json'\'' -d '\''{\"record\": <<data>>, \"changes\": <<changes>>}'\''"}'{ "id": "0d1e2f3a-4b5c-4d6e-9f70-1a2b3c4d5e6f", "msg": "Trigger created successfully"}