# AutessaDB Triggers

Source: https://docs.autessa.com/docs/api/poweruser/autessadb-triggers

> Poweruser API reference for creating, managing, and auditing AutessaDB triggers that fire agents, tools, managers, or database updates on row changes.

# AutessaDB Triggers

A trigger is attached to an AutessaDB table and fires an action — invoke an agent, invoke a tool, invoke a manager, or update an AutessaDB table — whenever rows are inserted, updated, or deleted. A trigger's condition names the database event it listens for and, optionally, column filters that narrow it down to specific column changes or values. Triggers execute asynchronously after the row operation commits.

> All endpoints are **POST** with a JSON body and require a poweruser key in the `Authorization` header, in the form `pwrusr:{id}:{secret}`. Every request identifies the table the trigger lives on via its `tableId`.

---

## Base URL

```
https://api.autessa.com/autessa_poweruser/autessadb/trigger
```

---

## Trigger anatomy

A trigger definition is a single JSON object. The same shape is sent when creating or updating a trigger and returned by every endpoint that responds with a trigger.

Exactly **one** of the four action config fields must be set, and it must match `triggerType` — otherwise the request is rejected with an error.

- `triggerId` (string) — Unique identifier for the trigger — a UUID string. Assigned by the server on `/add` (any value you send is overwritten) and immutable afterwards.
- `triggerName` (string) — Human-readable name for the trigger.
- `description` (string) — Optional description of what the trigger does.
- `triggerType` (string, required) — The kind of action this trigger performs. One of `INVOKE_AGENT`, `INVOKE_TOOL`, `INVOKE_MANAGER`, `UPDATE_AUTESSADB`.
- `condition` (object, required) — When the trigger should fire. See [Trigger condition](#trigger-condition).
- `invokeAgentActionConfig` (object) — Action config for `INVOKE_AGENT` triggers. See [Invoke an agent](#invoke-an-agent).
- `invokeToolActionConfig` (object) — Action config for `INVOKE_TOOL` triggers. See [Invoke a tool](#invoke-a-tool).
- `invokeManagerActionConfig` (object) — Action config for `INVOKE_MANAGER` triggers. See [Invoke a manager](#invoke-a-manager).
- `updateDbActionConfig` (object) — Action config for `UPDATE_AUTESSADB` triggers. See [Update AutessaDB](#update-autessadb).
- `enabled` (boolean) — Whether the trigger is active. Defaults to `true`. Disabled triggers never fire.
- `priority` (integer) — Execution ordering when multiple triggers match the same operation — lower numbers run first. Defaults to `100`.

Each table also has table-level trigger settings (configured on the table itself, not through these endpoints): a master `enabled` switch that silences all triggers on the table, and `maxTriggersPerOperation` (default `10`) that caps how many matching triggers fire for a single row operation. When more triggers match than the cap allows, the highest-priority (lowest number) triggers win.

```json title="Complete trigger definition"
{
  "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d",
  "triggerName": "New lead follow-up",
  "description": "Qualify every new lead and store the summary on the row.",
  "triggerType": "INVOKE_AGENT",
  "condition": {
    "event": "INSERT",
    "filterMode": "SPECIFIED_COLUMNS",
    "logicalOperator": "AND",
    "columnFilters": [
      {
        "columnName": "status",
        "operator": "EQUALS",
        "compareValue": { "textValue": "new" },
        "caseSensitive": false
      }
    ]
  },
  "invokeAgentActionConfig": {
    "agentExecutionRequest": {
      "agentId": "kTn4vB2p9Q",
      "version": { "versionState": "PUBLISHED" },
      "input": [
        {
          "inputType": "TEXT",
          "content": "Qualify this lead: @@{name} from @@{company}. Message: @@{message}"
        }
      ],
      "environmentVariables": {
        "LEAD_EMAIL": "@@{email}"
      },
      "executionOutputMode": "TEXT"
    },
    "storeOutputInColumn": true,
    "outputColumnName": "qualification_summary",
    "continueOnError": true
  },
  "enabled": true,
  "priority": 100
}
```

### Trigger condition

The `condition` object decides when the trigger fires.

- `event` (string, required) — The database event to listen for. One of `INSERT`, `UPDATE`, `DELETE`, or `ANY` (fires on all three).
- `filterMode` (string) — How column filters are applied: `ANY_COLUMN`, `SPECIFIED_COLUMNS`, or `ALL_EXCEPT_SPECIFIED`. See [Column filters](#column-filters). If omitted, the server treats a condition **with** `columnFilters` as `SPECIFIED_COLUMNS` and a condition **without** them as `ANY_COLUMN`.
- `columnFilters` — "> The column filters to evaluate. See [Column filters](#column-filters).
- `logicalOperator` (string) — How multiple column filters combine in `SPECIFIED_COLUMNS` mode: `AND` (all must match — the default), `OR` (any must match), or `XOR` (exactly one must match).

```json title="Condition: high-value deal moved to won"
{
  "event": "UPDATE",
  "filterMode": "SPECIFIED_COLUMNS",
  "logicalOperator": "AND",
  "columnFilters": [
    {
      "columnName": "stage",
      "operator": "EQUALS",
      "compareValue": { "textValue": "won" }
    },
    {
      "columnName": "deal_value",
      "operator": "GREATER_THAN",
      "compareValue": { "integerValue": 10000 }
    }
  ]
}
```

### Variable substitution

Action configs can reference the triggering row's data with the `@@{columnName}` placeholder syntax. Placeholders inside input content, tool variables, environment variables, and prompt template variables are replaced with the actual column values at execution time. On `UPDATE` events, `@@{old.columnName}` references the value before the change.

### Invoke an agent

`invokeAgentActionConfig` — for `INVOKE_AGENT` triggers. Each firing creates a fresh, single-turn, autonomous agent conversation; do not set a `conversationId` inside the execution request.

- `agentExecutionRequest` (object, required) — The agent execution request, with the same shape as the Agent API execute call. Fields: `agentId` (string, required), `version` (object with `versionState` — `PUBLISHED`, and optionally `versionNumber`; defaults to the published version), `input` (array of multimodal inputs; each has `inputType` — `TEXT`, `AUDIO`, `IMAGE`, `FILE`, `IMAGE_URL`, `FILE_URL` — and its content fields, e.g. `content` for `TEXT`), `environmentVariables` (object of string key-value pairs), `promptTemplateVariables` (object of string key-value pairs), and `executionOutputMode` (`TEXT` or `AUDIO`). Input content and variable values support `@@{columnName}` substitution.
- `storeOutputInColumn` (boolean) — If `true`, the agent's text output is written back to a column of the triggering record. Defaults to `false`.
- `outputColumnName` (string) — Name of the column that receives the agent output. Only used when `storeOutputInColumn` is `true`.
- `continueOnError` (boolean) — If `true` (the default), the trigger completes even when the agent invocation fails. If `false`, an agent failure fails the whole trigger.

```json title="invokeAgentActionConfig"
{
  "agentExecutionRequest": {
    "agentId": "kTn4vB2p9Q",
    "version": { "versionState": "PUBLISHED" },
    "input": [
      {
        "inputType": "TEXT",
        "content": "Analyze this feedback: @@{customer_feedback}"
      }
    ],
    "environmentVariables": {
      "CUSTOMER_ID": "@@{customer_id}"
    },
    "executionOutputMode": "TEXT"
  },
  "storeOutputInColumn": true,
  "outputColumnName": "analysis",
  "continueOnError": true
}
```

### Invoke a tool

`invokeToolActionConfig` — for `INVOKE_TOOL` triggers.

- `toolExecutionRequest` (object, required) — The tool execution request. Fields: `toolId` (string, required), `variables` (object of string key-value pairs — the tool's arguments), `environmentVariables` (object of string key-value pairs), and `privateVariables` (object of string key-value pairs that are not logged). All three maps support `@@{columnName}` substitution in their values.
- `storeResultInColumn` (boolean) — If `true`, the tool execution result is written back to a column of the triggering record. Defaults to `false`.
- `resultColumnName` (string) — Name of the column that receives the tool result. Only used when `storeResultInColumn` is `true`.
- `continueOnError` (boolean) — If `true` (the default), the trigger completes even when the tool invocation fails. If `false`, a tool failure fails the whole trigger.

```json title="invokeToolActionConfig"
{
  "toolExecutionRequest": {
    "toolId": "pQ7wE2rT9y",
    "variables": {
      "email": "@@{user_email}",
      "priority": "high"
    },
    "environmentVariables": {
      "REGION": "us-west-2"
    }
  },
  "storeResultInColumn": false,
  "continueOnError": true
}
```

### Invoke a manager

`invokeManagerActionConfig` — for `INVOKE_MANAGER` triggers. Like agent triggers, each firing creates a fresh, single-turn conversation; do not set a `conversationId`.

- `managerExecutionRequest` (object, required) — The manager execution request. Fields: `managerId` (string, required), `input` (array of multimodal inputs, same shape as agent input), `environmentVariables` (object of string key-value pairs), `promptTemplateVariables` (object of string key-value pairs), and `executionOutputMode` (`TEXT` or `AUDIO`). Input content and variable values support `@@{columnName}` substitution.
- `storeOutputInColumn` (boolean) — If `true`, the manager's text output is written back to a column of the triggering record. Defaults to `false`.
- `outputColumnName` (string) — Name of the column that receives the manager output. Only used when `storeOutputInColumn` is `true`.
- `continueOnError` (boolean) — If `true` (the default), the trigger completes even when the manager invocation fails. If `false`, a manager failure fails the whole trigger.

```json title="invokeManagerActionConfig"
{
  "managerExecutionRequest": {
    "managerId": "mR5tY8uI3o",
    "input": [
      {
        "inputType": "TEXT",
        "content": "Handle escalation for ticket @@{ticket_id}: @@{summary}"
      }
    ],
    "executionOutputMode": "TEXT"
  },
  "storeOutputInColumn": false,
  "continueOnError": true
}
```

### Update AutessaDB

`updateDbActionConfig` — for `UPDATE_AUTESSADB` triggers. Performs a database operation against another (or the same) AutessaDB table when the trigger fires.

- `targetTableId` (string, required) — The table the operation is performed on.
- `operation` (string, required) — The operation to perform: `INSERT` (create a record from `values`), `UPDATE` (modify records selected by `recordId` or `whereGroups`), `UPSERT` (insert, or update on conflict per `conflictResolution`, using `values` and `whereGroups` for conflict detection), or `DELETE` (remove records selected by `recordId` or `whereGroups`).
- `values` (object) — Column values for `INSERT`, `UPDATE`, and `UPSERT` — a map from column name to a column value object. Each value object carries `columnType` (one of the AutessaDB column types) plus the matching typed field: `textValue` (string), `integerValue` (integer), `floatValue` (float), `booleanValue` (boolean), `multiSelectValue` (array<string>), `filePath` (string, for file-backed types), or `variableValue` (string with `@@{columnName}` placeholders, resolved and parsed to the column's type at execution time). String values also support `@@{columnName}` substitution.
- `recordId` (integer) — Record ID for single-row `UPDATE` or `DELETE`. When set, `whereGroups` is ignored.
- `whereGroups` — "> WHERE conditions for batch `UPDATE`/`DELETE`, or conflict detection for `UPSERT`. Each group has `logicalOperator` (`"AND"` or `"OR"`, combining the conditions inside the group) and `conditions` — an array of objects with `columnName` (string), `operator` (string, e.g. `EQUALS`, `NOT_EQUALS`, `GREATER_THAN`, `LESS_THAN`, `IN`, `NOT_IN`, `IS_NULL`, `IS_NOT_NULL`), and `value`.
- `groupsLogicalOperator` (string) — How multiple WHERE groups combine: `"AND"` or `"OR"`. Defaults to `"OR"`.
- `conflictResolution` (string) — UPSERT conflict strategy: `REPLACE` (replace the entire record — the default), `MERGE` (merge fields, new values win), `SKIP` (leave the existing record untouched), or `ERROR` (fail the trigger on conflict).
- `skipIfTargetTableMissing` (boolean) — If `true`, the trigger does not fail when the target table is missing or inaccessible. Defaults to `false`.

```json title="updateDbActionConfig"
{
  "targetTableId": "zX8cV3bN6m",
  "operation": "UPSERT",
  "values": {
    "customer_email": {
      "columnType": "SHORT_TEXT",
      "variableValue": "@@{email}"
    },
    "total_orders": {
      "columnType": "INTEGER",
      "integerValue": 1
    },
    "last_seen": {
      "columnType": "SHORT_TEXT",
      "variableValue": "@@{updated_at}"
    }
  },
  "whereGroups": [
    {
      "logicalOperator": "AND",
      "conditions": [
        {
          "columnName": "customer_email",
          "operator": "EQUALS",
          "value": "@@{email}"
        }
      ]
    }
  ],
  "groupsLogicalOperator": "OR",
  "conflictResolution": "MERGE",
  "skipIfTargetTableMissing": false
}
```

---

## Column filters

Column filters narrow a condition down from "any row event" to specific column changes or values. How they are applied depends on the condition's `filterMode`:

- **`ANY_COLUMN`** — the trigger fires whenever anything about the row changed. Every column is compared between the old and new record (inserts and deletes always count as a change), including columns added to the table after the trigger was created. `columnFilters` are not evaluated in this mode.

- **`SPECIFIED_COLUMNS`** — only the listed `columnFilters` are evaluated, each with its `operator` and `compareValue`, combined with the condition's `logicalOperator` (`AND`, `OR`, or `XOR`). Columns added later are ignored. An empty filter list in this mode means the trigger never fires.

- **`ALL_EXCEPT_SPECIFIED`** — the trigger fires when any column **not** named in `columnFilters` changed. Filters are used only for their `columnName` here (operators and compare values are ignored). Columns added later are included.

A filter that names a column that does not exist in the table schema never matches.

### ColumnFilter

- `columnName` (string, required) — The column the filter applies to.
- `operator` (string, required) — The comparison operator. See [Filter operators](#filter-operators).
- `compareValue` (object) — Typed comparison value, required by value-comparison operators. See below.
- `caseSensitive` (boolean) — Whether text comparisons (`EQUALS`, `NOT_EQUALS`, `CONTAINS`, `STARTS_WITH`, `ENDS_WITH`) are case-sensitive. Defaults to `true`.

### ColumnFilterValue

A type-safe wrapper — populate the one field that matches the column's type, or use `variableValue` for dynamic comparison.

- `textValue` (string) — For `SHORT_TEXT`, `LONG_TEXT`, `SINGLE_SELECT`, and file-backed column types. For text columns this may itself contain `@@{columnName}` placeholders, resolved at evaluation time. Also used as the single value checked by the multi-select operators.
- `integerValue` (integer) — For `INTEGER` columns.
- `floatValue` (float) — For `FLOAT` columns.
- `booleanValue` (boolean) — For `BOOLEAN` columns.
- `multiSelectValue` — "> For `MULTI_SELECT` columns.
- `variableValue` (string) — A variable reference using `@@{columnName}` or `@@{old.columnName}` notation. When set, it takes precedence over the typed fields: the placeholder is replaced with the row's actual data at evaluation time, then parsed to the compared column's type (for `MULTI_SELECT`, as a comma-separated list). For example, comparing `unit_price` with `variableValue` `"@@{old.unit_price}"` fires on price changes relative to the previous value.

```json title="Filter: status changed to a closed state"
{
  "columnName": "status",
  "operator": "CHANGED"
}
```

```json title="Filter: tag added to a multi-select"
{
  "columnName": "tags",
  "operator": "VALUE_ADDED",
  "compareValue": { "textValue": "vip" }
}
```

```json title="Filter: dynamic comparison against another column"
{
  "columnName": "quantity",
  "operator": "GREATER_THAN",
  "compareValue": { "variableValue": "@@{reorder_threshold}" }
}
```

### Filter operators

Value-comparison operators are evaluated against the **new** (post-operation) value of the column; the change-detection and multi-select add/remove operators compare the old and new values. On `INSERT` the old record is empty; on `DELETE` the new record is empty.

| Operator | Meaning | Column types |
| --- | --- | --- |
| `CHANGED` | The column's value differs between old and new record. | All |
| `BECAME_NULL` | The column had a value and is now empty. | All |
| `BECAME_NON_NULL` | The column was empty and now has a value. | All |
| `EQUALS` | New value equals `compareValue` (honors `caseSensitive` for text). | All |
| `NOT_EQUALS` | New value does not equal `compareValue`. | All |
| `NULL` | New value is empty. | All |
| `NOT_NULL` | New value is present. | All |
| `GREATER_THAN` | New value is greater than `compareValue`. | `INTEGER`, `FLOAT` |
| `LESS_THAN` | New value is less than `compareValue`. | `INTEGER`, `FLOAT` |
| `GREATER_OR_EQUAL` | New value is greater than or equal to `compareValue`. | `INTEGER`, `FLOAT` |
| `LESS_OR_EQUAL` | New value is less than or equal to `compareValue`. | `INTEGER`, `FLOAT` |
| `CONTAINS` | New text contains `compareValue.textValue` as a substring. | `SHORT_TEXT`, `LONG_TEXT` |
| `STARTS_WITH` | New text starts with `compareValue.textValue`. | `SHORT_TEXT`, `LONG_TEXT` |
| `ENDS_WITH` | New text ends with `compareValue.textValue`. | `SHORT_TEXT`, `LONG_TEXT` |
| `VALUE_ADDED` | `compareValue.textValue` is in the new selection but was not in the old one. | `MULTI_SELECT` |
| `VALUE_REMOVED` | `compareValue.textValue` was in the old selection but is not in the new one. | `MULTI_SELECT` |
| `CONTAINS_VALUE` | The new selection contains `compareValue.textValue`. | `MULTI_SELECT` |
| `IS_TRUE` | New value is `true`. | `BOOLEAN` |
| `IS_FALSE` | New value is `false`. | `BOOLEAN` |

For file-backed column types (`FILE`, `IMAGE`, `AUDIO`, `VIDEO`), value comparisons operate on the stored file path.

---

## Add Trigger **POST** `/add`

Creates a trigger on a table. The server assigns the `triggerId` (a UUID string) — any `triggerId` in the submitted trigger is ignored. The trigger must have exactly one action config set, matching its `triggerType`. Requires **publish** or **admin** access to the table.

### Request Body

- `tableId` (string, required) — The table to attach the trigger to.
- `trigger` (object, required) — The full trigger definition. See [Trigger anatomy](#trigger-anatomy).

### Response

- `trigger` (object) — The stored trigger, including its server-assigned `triggerId`.
- `errors` — "> Error messages if the request failed. Absent on success.

**cURL:**

```bash
curl https://api.autessa.com/autessa_poweruser/autessadb/trigger/add \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableId": "aB3xK9mQ2w",
    "trigger": {
      "triggerName": "New lead follow-up",
      "description": "Qualify every new lead and store the summary on the row.",
      "triggerType": "INVOKE_AGENT",
      "condition": {
        "event": "INSERT",
        "filterMode": "SPECIFIED_COLUMNS",
        "logicalOperator": "AND",
        "columnFilters": [
          {
            "columnName": "status",
            "operator": "EQUALS",
            "compareValue": { "textValue": "new" },
            "caseSensitive": false
          }
        ]
      },
      "invokeAgentActionConfig": {
        "agentExecutionRequest": {
          "agentId": "kTn4vB2p9Q",
          "version": { "versionState": "PUBLISHED" },
          "input": [
            {
              "inputType": "TEXT",
              "content": "Qualify this lead: @@{name} from @@{company}. Message: @@{message}"
            }
          ],
          "environmentVariables": { "LEAD_EMAIL": "@@{email}" },
          "executionOutputMode": "TEXT"
        },
        "storeOutputInColumn": true,
        "outputColumnName": "qualification_summary",
        "continueOnError": true
      },
      "enabled": true,
      "priority": 100
    }
  }'
```

**JavaScript:**

```javascript
const response = await fetch(
  'https://api.autessa.com/autessa_poweruser/autessadb/trigger/add',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': process.env.POWERUSER_KEY
    },
    body: JSON.stringify({
      tableId: 'aB3xK9mQ2w',
      trigger: {
        triggerName: 'New lead follow-up',
        triggerType: 'INVOKE_AGENT',
        condition: {
          event: 'INSERT',
          filterMode: 'SPECIFIED_COLUMNS',
          columnFilters: [
            {
              columnName: 'status',
              operator: 'EQUALS',
              compareValue: { textValue: 'new' },
              caseSensitive: false
            }
          ]
        },
        invokeAgentActionConfig: {
          agentExecutionRequest: {
            agentId: 'kTn4vB2p9Q',
            input: [
              {
                inputType: 'TEXT',
                content: 'Qualify this lead: @@{name} from @@{company}.'
              }
            ],
            executionOutputMode: 'TEXT'
          },
          storeOutputInColumn: true,
          outputColumnName: 'qualification_summary'
        }
      }
    })
  }
);

const data = await response.json();
console.log(data.trigger.triggerId);
```

**Python:**

```python
import os
import requests

response = requests.post(
    'https://api.autessa.com/autessa_poweruser/autessadb/trigger/add',
    headers={'Authorization': os.environ['POWERUSER_KEY']},
    json={
        'tableId': 'aB3xK9mQ2w',
        'trigger': {
            'triggerName': 'New lead follow-up',
            'triggerType': 'INVOKE_AGENT',
            'condition': {
                'event': 'INSERT',
                'filterMode': 'SPECIFIED_COLUMNS',
                'columnFilters': [
                    {
                        'columnName': 'status',
                        'operator': 'EQUALS',
                        'compareValue': {'textValue': 'new'},
                        'caseSensitive': False
                    }
                ]
            },
            'invokeAgentActionConfig': {
                'agentExecutionRequest': {
                    'agentId': 'kTn4vB2p9Q',
                    'input': [
                        {
                            'inputType': 'TEXT',
                            'content': 'Qualify this lead: @@{name} from @@{company}.'
                        }
                    ],
                    'executionOutputMode': 'TEXT'
                },
                'storeOutputInColumn': True,
                'outputColumnName': 'qualification_summary'
            }
        }
    }
)

print(response.json()['trigger']['triggerId'])
```

```json title="JSON"
{
  "trigger": {
    "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d",
    "triggerName": "New lead follow-up",
    "description": "Qualify every new lead and store the summary on the row.",
    "triggerType": "INVOKE_AGENT",
    "condition": {
      "event": "INSERT",
      "filterMode": "SPECIFIED_COLUMNS",
      "logicalOperator": "AND",
      "columnFilters": [
        {
          "columnName": "status",
          "operator": "EQUALS",
          "compareValue": { "textValue": "new" },
          "caseSensitive": false
        }
      ]
    },
    "invokeAgentActionConfig": {
      "agentExecutionRequest": {
        "agentId": "kTn4vB2p9Q",
        "version": { "versionState": "PUBLISHED" },
        "input": [
          {
            "inputType": "TEXT",
            "content": "Qualify this lead: @@{name} from @@{company}. Message: @@{message}"
          }
        ],
        "environmentVariables": { "LEAD_EMAIL": "@@{email}" },
        "executionOutputMode": "TEXT"
      },
      "storeOutputInColumn": true,
      "outputColumnName": "qualification_summary",
      "continueOnError": true
    },
    "enabled": true,
    "priority": 100
  }
}
```

---

## Update Trigger **POST** `/update`

Replaces an existing trigger's definition. This is a **full replacement**, not a patch — send the complete trigger object. The top-level `triggerId` identifies the trigger and always wins over any `triggerId` inside the `trigger` object. The replacement must pass the same validation as `/add` (exactly one action config, matching the `triggerType`). Requires **admin** access to the table.

### Request Body

- `tableId` (string, required) — The table the trigger belongs to.
- `triggerId` (string, required) — UUID of the trigger to update.
- `trigger` (object, required) — The complete replacement definition. See [Trigger anatomy](#trigger-anatomy).

### Response

- `trigger` (object) — The updated trigger.
- `errors` — "> Error messages if the request failed. Absent on success.

**cURL:**

```bash
curl https://api.autessa.com/autessa_poweruser/autessadb/trigger/update \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableId": "aB3xK9mQ2w",
    "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d",
    "trigger": {
      "triggerName": "New lead follow-up",
      "triggerType": "INVOKE_AGENT",
      "condition": {
        "event": "INSERT",
        "filterMode": "SPECIFIED_COLUMNS",
        "columnFilters": [
          {
            "columnName": "status",
            "operator": "EQUALS",
            "compareValue": { "textValue": "new" },
            "caseSensitive": false
          }
        ]
      },
      "invokeAgentActionConfig": {
        "agentExecutionRequest": {
          "agentId": "kTn4vB2p9Q",
          "input": [
            {
              "inputType": "TEXT",
              "content": "Qualify this lead: @@{name} from @@{company}."
            }
          ],
          "executionOutputMode": "TEXT"
        },
        "storeOutputInColumn": true,
        "outputColumnName": "qualification_summary"
      },
      "enabled": true,
      "priority": 50
    }
  }'
```

**JavaScript:**

```javascript
const response = await fetch(
  'https://api.autessa.com/autessa_poweruser/autessadb/trigger/update',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': process.env.POWERUSER_KEY
    },
    body: JSON.stringify({
      tableId: 'aB3xK9mQ2w',
      triggerId: '3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d',
      trigger: updatedTriggerDefinition  // full trigger object
    })
  }
);

const data = await response.json();
```

**Python:**

```python
import os
import requests

response = requests.post(
    'https://api.autessa.com/autessa_poweruser/autessadb/trigger/update',
    headers={'Authorization': os.environ['POWERUSER_KEY']},
    json={
        'tableId': 'aB3xK9mQ2w',
        'triggerId': '3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d',
        'trigger': updated_trigger_definition,  # full trigger object
    },
)

data = response.json()
```

```json title="JSON"
{
  "trigger": {
    "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d",
    "triggerName": "New lead follow-up",
    "triggerType": "INVOKE_AGENT",
    "condition": {
      "event": "INSERT",
      "filterMode": "SPECIFIED_COLUMNS",
      "columnFilters": [
        {
          "columnName": "status",
          "operator": "EQUALS",
          "compareValue": { "textValue": "new" },
          "caseSensitive": false
        }
      ]
    },
    "invokeAgentActionConfig": {
      "agentExecutionRequest": {
        "agentId": "kTn4vB2p9Q",
        "input": [
          {
            "inputType": "TEXT",
            "content": "Qualify this lead: @@{name} from @@{company}."
          }
        ],
        "executionOutputMode": "TEXT"
      },
      "storeOutputInColumn": true,
      "outputColumnName": "qualification_summary",
      "continueOnError": true
    },
    "enabled": true,
    "priority": 50
  }
}
```

---

## Delete Trigger **POST** `/delete`

Permanently removes a trigger from a table. Requires **admin** access to the table.

### Request Body

- `tableId` (string, required) — The table the trigger belongs to.
- `triggerId` (string, required) — UUID of the trigger to delete.

### Response

- `errors` — "> Error messages if the request failed. Absent on success — a successful delete returns an empty JSON object.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/autessadb/trigger/delete \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableId": "aB3xK9mQ2w",
    "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d"
  }'
```

```json title="JSON"
{}
```

---

## Enable Trigger **POST** `/enable`

Sets a trigger's `enabled` flag to `true` so it resumes firing. Requires **admin** access to the table.

### Request Body

- `tableId` (string, required) — The table the trigger belongs to.
- `triggerId` (string, required) — UUID of the trigger to enable.

### Response

- `trigger` (object) — The trigger with `enabled` set to `true`.
- `errors` — "> Error messages if the request failed. Absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/autessadb/trigger/enable \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableId": "aB3xK9mQ2w",
    "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d"
  }'
```

```json title="JSON"
{
  "trigger": {
    "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d",
    "triggerName": "New lead follow-up",
    "triggerType": "INVOKE_AGENT",
    "enabled": true,
    "priority": 100
  }
}
```

---

## Disable Trigger **POST** `/disable`

Sets a trigger's `enabled` flag to `false`. The trigger definition is kept but it stops firing until re-enabled. Requires **admin** access to the table.

### Request Body

- `tableId` (string, required) — The table the trigger belongs to.
- `triggerId` (string, required) — UUID of the trigger to disable.

### Response

- `trigger` (object) — The trigger with `enabled` set to `false`.
- `errors` — "> Error messages if the request failed. Absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/autessadb/trigger/disable \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableId": "aB3xK9mQ2w",
    "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d"
  }'
```

```json title="JSON"
{
  "trigger": {
    "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d",
    "triggerName": "New lead follow-up",
    "triggerType": "INVOKE_AGENT",
    "enabled": false,
    "priority": 100
  }
}
```

---

## Get Trigger **POST** `/get`

Fetches a single trigger's definition. Requires any access level to the table.

### Request Body

- `tableId` (string, required) — The table the trigger belongs to.
- `triggerId` (string, required) — UUID of the trigger to fetch.

### Response

- `trigger` (object) — The trigger definition. See [Trigger anatomy](#trigger-anatomy).
- `errors` — "> Error messages if the request failed. Absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/autessadb/trigger/get \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableId": "aB3xK9mQ2w",
    "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d"
  }'
```

```json title="JSON"
{
  "trigger": {
    "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d",
    "triggerName": "New lead follow-up",
    "triggerType": "INVOKE_AGENT",
    "condition": {
      "event": "INSERT",
      "filterMode": "SPECIFIED_COLUMNS",
      "columnFilters": [
        {
          "columnName": "status",
          "operator": "EQUALS",
          "compareValue": { "textValue": "new" },
          "caseSensitive": false
        }
      ]
    },
    "invokeAgentActionConfig": {
      "agentExecutionRequest": {
        "agentId": "kTn4vB2p9Q",
        "input": [
          {
            "inputType": "TEXT",
            "content": "Qualify this lead: @@{name} from @@{company}."
          }
        ],
        "executionOutputMode": "TEXT"
      },
      "storeOutputInColumn": true,
      "outputColumnName": "qualification_summary",
      "continueOnError": true
    },
    "enabled": true,
    "priority": 100
  }
}
```

---

## List Triggers **POST** `/all`

Lists every trigger configured on a table. Requires any access level to the table.

### Request Body

- `tableId` (string, required) — The table to list triggers for.

### Response

- `triggers` — "> All triggers on the table. Each element is a full trigger definition — see [Trigger anatomy](#trigger-anatomy).
- `errors` — "> Error messages if the request failed. Absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/autessadb/trigger/all \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableId": "aB3xK9mQ2w"
  }'
```

```json title="JSON"
{
  "triggers": [
    {
      "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d",
      "triggerName": "New lead follow-up",
      "triggerType": "INVOKE_AGENT",
      "enabled": true,
      "priority": 100
    },
    {
      "triggerId": "7a1d4e9b-2c5f-4b8a-9d3e-6f0c8b2a4e7d",
      "triggerName": "Sync won deals to customers",
      "triggerType": "UPDATE_AUTESSADB",
      "enabled": true,
      "priority": 200
    }
  ]
}
```

---

## Execution History **POST** `/history`

Returns the trigger execution log for a table, one calendar month at a time, newest first. Results are paginated with a server-defined page size (50 by default). Requires any access level to the table, and returns only the firings you may see: those that ran as you, every firing if you're an Admin of the table, and every firing for company Admins.

### Request Body

- `tableId` (string, required) — The table whose trigger history to fetch.
- `year` (integer, required) — Calendar year to filter by (e.g. `2026`). Must be between 2000 and next year.
- `month` (integer, required) — Calendar month to filter by, `1`–`12`.
- `page` (integer) — Zero-based page number. Defaults to `0`. Negative values are treated as `0`.

### Response

- `triggerEvents` — "> The trigger events for the requested page. Each event has the following fields: - `eventId` (string) — unique identifier of the execution event, a UUID string. - `tableId` (string) — the table the trigger ran on. - `triggerId` (string) — UUID of the trigger that fired. - `triggerDefinition` (object) — the trigger's current full definition (see [Trigger anatomy](#trigger-anatomy)), looked up at read time. `null` if the trigger has since been deleted. - `triggerEvent` (string) — JSON-encoded payload describing what fired the trigger, including the before/after records of the row operation. - `triggerResponse` (string) — JSON-encoded result of the trigger execution. - `createdAt` (string) — when the trigger fired, as an ISO-8601 UTC timestamp.
- `totalElements` (integer) — Total number of trigger events in the requested month.
- `totalPages` (integer) — Total number of pages.
- `currentPage` (integer) — The zero-based page number returned.
- `pageSize` (integer) — Number of events per page.
- `hasNext` (boolean) — Whether a next page exists.
- `hasPrevious` (boolean) — Whether a previous page exists.
- `errors` — "> Error messages if the request failed. Absent on success.

**cURL:**

```bash
curl https://api.autessa.com/autessa_poweruser/autessadb/trigger/history \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableId": "aB3xK9mQ2w",
    "year": 2026,
    "month": 6,
    "page": 0
  }'
```

**JavaScript:**

```javascript
const response = await fetch(
  'https://api.autessa.com/autessa_poweruser/autessadb/trigger/history',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': process.env.POWERUSER_KEY
    },
    body: JSON.stringify({
      tableId: 'aB3xK9mQ2w',
      year: 2026,
      month: 6,
      page: 0
    })
  }
);

const data = await response.json();
for (const event of data.triggerEvents) {
  console.log(event.createdAt, event.triggerDefinition?.triggerName);
}
```

**Python:**

```python
import os
import requests

response = requests.post(
    'https://api.autessa.com/autessa_poweruser/autessadb/trigger/history',
    headers={'Authorization': os.environ['POWERUSER_KEY']},
    json={
        'tableId': 'aB3xK9mQ2w',
        'year': 2026,
        'month': 6,
        'page': 0,
    },
)

data = response.json()
for event in data['triggerEvents']:
    print(event['createdAt'], event['eventId'])
```

```json title="JSON"
{
  "triggerEvents": [
    {
      "eventId": "b6e2f8a4-1c3d-4e5f-9a7b-8c0d2e4f6a1b",
      "tableId": "aB3xK9mQ2w",
      "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d",
      "triggerDefinition": {
        "triggerId": "3f8c2a1e-9b4d-4c6a-8e2f-1d5a7b9c0e3d",
        "triggerName": "New lead follow-up",
        "triggerType": "INVOKE_AGENT",
        "enabled": true,
        "priority": 100
      },
      "triggerEvent": "{\"event\":\"INSERT\",\"newRecord\":{\"name\":{\"columnType\":\"SHORT_TEXT\",\"textValue\":\"Ada Lovelace\"},\"status\":{\"columnType\":\"SHORT_TEXT\",\"textValue\":\"new\"}}}",
      "triggerResponse": "{\"status\":\"SUCCESS\",\"output\":\"Qualified: strong fit, recommend follow-up call.\"}",
      "createdAt": "2026-06-15T09:21:07"
    }
  ],
  "totalElements": 42,
  "totalPages": 1,
  "currentPage": 0,
  "pageSize": 50,
  "hasNext": false,
  "hasPrevious": true
}
```

---

## Errors

All responses share the same envelope. On failure the response contains an `errors` array of human-readable messages — server-side exceptions are caught and folded into `errors` rather than surfaced as raw stack traces — and the HTTP status is non-2xx whenever `errors` is present. The envelope may also carry `deprecationWarnings` (array<string>) on otherwise-successful calls.

Common failure cases:

- **401** — missing or invalid poweruser key, or insufficient table access: creating a trigger requires publish or admin access; updating, deleting, enabling, or disabling requires admin access; reads require any access to the table.

- **Validation errors** — missing `trigger` or `triggerId`, a trigger whose action config does not match its `triggerType` (or with zero / more than one action config set), a missing `year`/`month` on `/history`, a month outside `1`–`12`, or a year outside the accepted range.

- **Not found** — unknown `tableId` or a `triggerId` that does not exist on the table.

---

## Related

- [Poweruser API overview](/docs/api/poweruser.md)
- [AutessaDB Tables (Poweruser API)](/docs/api/poweruser/autessadb-tables.md)
- [AutessaDB Query (Poweruser API)](/docs/api/poweruser/autessadb-query.md)
- [AutessaDB client API](/docs/api/autessadb.md)
- [Triggers guide](/docs/guide/autessadb/triggers.md)
- [Tables guide](/docs/guide/autessadb/tables.md)

