# Conversation Sync

Source: https://docs.autessa.com/docs/api/poweruser/conversation-sync

> Poweruser endpoints for managing conversation sync configs that export closed agent conversations into AutessaDB tables.

# Conversation Sync

Conversation sync configs automatically export finished agent conversations into your AutessaDB tables — the full transcript lands in a column of a table you choose, matched to an existing row or inserted as a new one, so downstream tools, triggers, and reports can work with conversation data like any other row.

> All paths on this page are relative to `https://api.autessa.com/autessa_poweruser/conversation-sync`. Every request is a POST with a JSON body, and every ID is an opaque string. See the [Poweruser API overview](/docs/api/poweruser.md) for authentication and conventions.

## How syncing works

Each config is a standing rule that runs asynchronously whenever a
conversation is logged for your company:

1. **Filter** — only `enabled` configs run. A config can restrict itself to
  specific agents (`agentIds`), to conversations that do or don't have an
  evaluation (`requiresEvaluation`), and to production traffic only
  (`allowSandboxConversations: false` skips Builder sandbox conversations and
  syncs only conversations started with an API key).
2. **Write** — for every entry in `tableUpdates`, the conversation's
  transcript JSON is written into `conversationJsonColumn` on rows of the
  target AutessaDB table where `matchColumn` equals the conversation ID.
  `additionalColumns` are updated at the same time, with
  [template variables](#template-variables) substituted.
3. **No match** — if no row matches, the entry's `onNoMatch` behavior
  decides: `SKIP` drops the write, `INSERT` creates a new row (upsert) that
  includes the match column set to the conversation ID.

Multiple configs can match the same conversation; each runs independently,
and a failure in one config or one table update does not stop the others.
Because the data lands in regular AutessaDB rows, you can chain triggers on
the target table to post-process transcripts.

---

## The conversation sync config object

- `id` (string) — Unique config identifier.
- `name` (string) — Display name. Must be unique within the company.
- `description` (string) — What the config is for.
- `enabled` (boolean) — Whether the config runs. Disabled configs are kept but never match.
- `agentIds` (array<string>) — Agents whose conversations this config syncs. `null` means all agents.
- `requiresEvaluation` (boolean) — `true` syncs only conversations that have an evaluation, `false` only those without one, `null` doesn't filter on evaluation at all.
- `allowSandboxConversations` (boolean) — When `false` (the default), only conversations started with an API key are synced; Builder sandbox test conversations are skipped.
- `tableUpdates` (array<TableUpdate>) — The AutessaDB writes to perform for each matching conversation. See [table update entries](#table-update-entries) below.
- `createdAt` (string) — ISO-8601 creation timestamp.
- `updatedAt` (string) — ISO-8601 timestamp of the last update.

### Table update entries

- `tableId` (string) — The AutessaDB table to update.
- `matchColumn` (string) — Column name matched against the conversation ID to find the target row (for example `"conversation_id"`).
- `conversationJsonColumn` (string) — Column that receives the conversation transcript as a JSON array of log entries.
- `additionalColumns` (map<string, string>) — Extra columns to set on the matched row. Values are literal strings with [template variables](#template-variables) substituted. Target columns must be `SHORT_TEXT` or `LONG_TEXT`.
- `onNoMatch` (string) — `SKIP` (default) — do nothing when no row matches. `INSERT` — insert a new row containing the conversation JSON, the additional columns, and the match column set to the conversation ID.
- `includeToolCalls` (boolean) — Whether the JSON written to `conversationJsonColumn` includes `TOOL_REQUEST`/`TOOL_RESPONSE` log entries. Defaults to `true`.

### Template variables

Values in `additionalColumns` may embed these placeholders:

| Variable | Substituted with |
|----------|------------------|
| `@@{conversationId}` | The conversation's ID. |
| `@@{closeDate}` | When the conversation closed. |
| `@@{agentId}` | The agent's ID. |
| `@@{agentVersion}` | The agent version that ran the conversation. |
| `@@{apiKeyId}` | The API key that started the conversation, if any. |
| `@@{companyId}` | Your company's ID. |
| `@@{channel}` | Where the conversation happened: `PHONE`, `SMS`, `WEB_CHAT`, `APP`, or `API`. |
| `@@{businessNumber}` | For phone calls and texts, your phone number the conversation was on. Empty otherwise. |
| `@@{otherNumber}` | For phone calls and texts, the other person's phone number. Empty otherwise. |
| `@@{language}` | For agents that [speak more than one language](/docs/guide/agentic/phone-numbers.md#agents-that-speak-more-than-one-language), the language the conversation settled on, such as `es-US`. Empty otherwise. |
| `@@{conversation}` | Full transcript JSON — always includes tool calls. |
| `@@{shortened_conversation}` | Transcript JSON without tool calls. |

When the agent has [Protect sensitive data](/docs/guide/agentic/sensitive-data.md) on, `@@{conversation}` and `@@{shortened_conversation}` contain placeholders such as `[card ending 4242 — saved as PM_1]`, never the values.

```json title="Conversation sync config object"
{
  "id": "V1StGXR8Z5",
  "name": "Closed support tickets",
  "description": "Writes finished support conversations back onto the ticket row.",
  "enabled": true,
  "agentIds": ["aG9dK2mP4q"],
  "requiresEvaluation": null,
  "allowSandboxConversations": false,
  "tableUpdates": [
    {
      "tableId": "tB6xN4rW8z",
      "matchColumn": "conversation_id",
      "conversationJsonColumn": "transcript",
      "additionalColumns": {
        "status": "closed",
        "closed_at": "@@{closeDate}",
        "agent_version": "@@{agentVersion}"
      },
      "onNoMatch": "INSERT",
      "includeToolCalls": true
    }
  ],
  "createdAt": "2026-06-12T09:30:00",
  "updatedAt": "2026-06-28T17:42:10"
}
```

---

## Create a config

**POST** `/conversation-sync/create`

Creates a new sync config for the company. The name must be unique within
the company — creation fails with an error message otherwise. The config
starts matching conversations immediately unless you pass `enabled: false`.

### Request parameters

- `name` (string, required) — Display name, unique within the company.
- `description` (string) — What the config is for.
- `enabled` (boolean) — Whether the config runs. Defaults to `true`.
- `agentIds` (array<string>) — Restrict to these agents. Omit or send an empty array to sync all agents.
- `requiresEvaluation` (boolean) — `true` = only evaluated conversations, `false` = only unevaluated ones. Omit to sync regardless of evaluation.
- `allowSandboxConversations` (boolean) — Also sync Builder sandbox conversations. Defaults to `false` (API-key conversations only).
- `tableUpdates` (array<TableUpdate>, required) — The writes to perform, in the [table update entry](#table-update-entries) shape.

### Response

- `configId` (string) — The new config's ID.
- `message` (string) — Confirmation message.
- `errors` (array<string>) — Error messages, if any occurred (for example `"A conversation sync config with this name already exists"`).

**cURL:**

```bash
curl https://api.autessa.com/autessa_poweruser/conversation-sync/create \
  -X POST \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Closed support tickets",
    "description": "Writes finished support conversations back onto the ticket row.",
    "agentIds": ["aG9dK2mP4q"],
    "tableUpdates": [
      {
        "tableId": "tB6xN4rW8z",
        "matchColumn": "conversation_id",
        "conversationJsonColumn": "transcript",
        "additionalColumns": {
          "status": "closed",
          "closed_at": "@@{closeDate}"
        },
        "onNoMatch": "INSERT"
      }
    ]
  }'
```

**JavaScript:**

```javascript
const response = await fetch(
  'https://api.autessa.com/autessa_poweruser/conversation-sync/create',
  {
    method: 'POST',
    headers: {
      'Authorization': process.env.POWERUSER_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Closed support tickets',
      description: 'Writes finished support conversations back onto the ticket row.',
      agentIds: ['aG9dK2mP4q'],
      tableUpdates: [
        {
          tableId: 'tB6xN4rW8z',
          matchColumn: 'conversation_id',
          conversationJsonColumn: 'transcript',
          additionalColumns: { status: 'closed', closed_at: '@@{closeDate}' },
          onNoMatch: 'INSERT'
        }
      ]
    })
  }
);

const { configId } = await response.json();
```

**Python:**

```python
import os
import requests

response = requests.post(
    'https://api.autessa.com/autessa_poweruser/conversation-sync/create',
    headers={'Authorization': os.environ['POWERUSER_KEY']},
    json={
        'name': 'Closed support tickets',
        'description': 'Writes finished support conversations back onto the ticket row.',
        'agentIds': ['aG9dK2mP4q'],
        'tableUpdates': [
            {
                'tableId': 'tB6xN4rW8z',
                'matchColumn': 'conversation_id',
                'conversationJsonColumn': 'transcript',
                'additionalColumns': {'status': 'closed', 'closed_at': '@@{closeDate}'},
                'onNoMatch': 'INSERT'
            }
        ]
    }
)

config_id = response.json()['configId']
```

```json title="Response"
{
  "configId": "V1StGXR8Z5",
  "message": "Conversation sync config created successfully",
  "errors": []
}
```

---

## Get a config

**POST** `/conversation-sync/get`

Retrieves a single sync config. Configs are company-scoped — requesting a
config that belongs to another company returns an error.

### Request parameters

- `id` (string, required) — The config to fetch.

### Response

- `config` (ConversationSyncConfig) — The [conversation sync config object](#the-conversation-sync-config-object).
- `errors` (array<string>) — Error messages, if any occurred.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/conversation-sync/get \
  -X POST \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "id": "V1StGXR8Z5" }'
```

```json title="Response (truncated)"
{
  "config": {
    "id": "V1StGXR8Z5",
    "name": "Closed support tickets",
    "enabled": true,
    "agentIds": ["aG9dK2mP4q"],
    "allowSandboxConversations": false,
    "tableUpdates": [
      {
        "tableId": "tB6xN4rW8z",
        "matchColumn": "conversation_id",
        "conversationJsonColumn": "transcript",
        "onNoMatch": "INSERT",
        "includeToolCalls": true
      }
    ],
    "createdAt": "2026-06-12T09:30:00",
    "updatedAt": "2026-06-28T17:42:10"
  },
  "errors": []
}
```

---

## List all configs

**POST** `/conversation-sync/all`

Lists every sync config in the company, enabled or not.

### Request parameters

None — send an empty object `{}`.

### Response

- `configs` (array<ConversationSyncConfig>) — All configs, each in the [conversation sync config object](#the-conversation-sync-config-object) shape.
- `totalCount` (integer) — Number of configs returned.
- `errors` (array<string>) — Error messages, if any occurred.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/conversation-sync/all \
  -X POST \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

```json title="Response (truncated)"
{
  "configs": [
    {
      "id": "V1StGXR8Z5",
      "name": "Closed support tickets",
      "enabled": true,
      "agentIds": ["aG9dK2mP4q"],
      "allowSandboxConversations": false,
      "tableUpdates": [{ "tableId": "tB6xN4rW8z", "matchColumn": "conversation_id" }]
    }
  ],
  "totalCount": 1,
  "errors": []
}
```

---

## Update a config

**POST** `/conversation-sync/update`

Partially updates a config: only the fields you send are changed, everything
else keeps its current value. Renames are checked for uniqueness. Note that
`tableUpdates` is replaced wholesale when present — send the complete list
you want, not a delta.

### Request parameters

- `id` (string, required) — The config to update.
- `name` (string) — New display name, unique within the company.
- `description` (string) — New description.
- `enabled` (boolean) — Enable or disable the config.
- `agentIds` (array<string>) — New agent filter. Send an empty array `[]` to clear the filter and sync all agents.
- `requiresEvaluation` (boolean) — New evaluation filter.
- `allowSandboxConversations` (boolean) — New sandbox allowance.
- `tableUpdates` (array<TableUpdate>) — Full replacement list of [table update entries](#table-update-entries).

### Response

- `message` (string) — Confirmation message.
- `errors` (array<string>) — Error messages, if any occurred.

**cURL:**

```bash
curl https://api.autessa.com/autessa_poweruser/conversation-sync/update \
  -X POST \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "V1StGXR8Z5",
    "enabled": false,
    "agentIds": []
  }'
```

**JavaScript:**

```javascript
await fetch(
  'https://api.autessa.com/autessa_poweruser/conversation-sync/update',
  {
    method: 'POST',
    headers: {
      'Authorization': process.env.POWERUSER_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      id: 'V1StGXR8Z5',
      enabled: false,
      agentIds: []
    })
  }
);
```

**Python:**

```python
import os
import requests

requests.post(
    'https://api.autessa.com/autessa_poweruser/conversation-sync/update',
    headers={'Authorization': os.environ['POWERUSER_KEY']},
    json={'id': 'V1StGXR8Z5', 'enabled': False, 'agentIds': []}
)
```

```json title="Response"
{
  "message": "Conversation sync config updated successfully",
  "errors": []
}
```

---

## Delete a config

**POST** `/conversation-sync/delete`

Permanently deletes a sync config. Conversations that were already synced
stay in their AutessaDB tables; only future syncing stops.

### Request parameters

- `id` (string, required) — The config to delete.

### Response

- `message` (string) — Confirmation message.
- `errors` (array<string>) — Error messages, if any occurred.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/conversation-sync/delete \
  -X POST \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "id": "V1StGXR8Z5" }'
```

```json title="Response"
{
  "message": "Conversation sync config deleted successfully",
  "errors": []
}
```

---

## Errors

| Status | When |
|--------|------|
| `200` | Success — check `errors` for validation messages (duplicate config name, `"You do not have access to this config"` for another company's config). |
| `401` | Invalid or missing poweruser key. |
| `403` | Scoped key without the endpoint in its allow-list. |
| `408` | Server-side error; `errors` contains the message. |

Sync execution itself is asynchronous — write failures against the target
table (unknown column names, unsupported column types) are logged
server-side and never surface through these endpoints, so double-check
column names in `tableUpdates` against the target table's schema.

---

## Related

- [Poweruser API overview](/docs/api/poweruser.md)
- [Agent history guide](/docs/guide/agentic/agent-history.md)
- [Agents (Poweruser API)](/docs/api/poweruser/agents.md)
- [Managers (Poweruser API)](/docs/api/poweruser/managers.md)

