> ## Documentation Index
> Fetch the complete documentation index at: https://docs.seleqt.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Sheet syncs preview

## POST /api/v1/public/sheet-syncs/preview/

What a sync would do, without writing anything to the Sheet or to Seleqt: the tab's headers, the totals, and up to 20 sample rows with what the run would change in each. Use it to check a setup before [creating a sync](https://docs.seleqt.ai/api-reference/public/sheet-syncs-create.md), or to try changed settings on an existing one.

Without `sync_id` the preview shows a **first run**: nothing is overwritten on either side, only empty cells and empty lead fields are filled, and a Status that stops outreach applies. With `sync_id` it shows what the **next run** of that sync would do, compared with what the Sheet showed at its last run.

Auth: `X-API-Key`

### Request Body

Takes the same fields as [POST /public/sheet-syncs/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-create.md). To preview an existing sync, send its `sync_id`; any other fields you send override its saved settings for the preview only.

```json theme={null}
{
  "campaign_id": 456,
  "spreadsheet_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789",
  "sheet_name": "Leads",
  "key_field": "email",
  "key_column": "Email",
  "mappings": [
    { "column": "First name", "field": "first_name", "direction": "both" },
    { "column": "Status", "field": "lead_status", "direction": "both" }
  ],
  "status_values": { "Closed lost": "STOPPED" }
}
```

```json theme={null}
{
  "sync_id": 42,
  "create_leads": false
}
```

### Response

```json theme={null}
{
  "success": true,
  "headers": ["Email", "First name", "Last name", "Status"],
  "rows": 214,
  "matched": 208,
  "to_create": 3,
  "to_append": 12,
  "cells_in": 4,
  "cells_out": 57,
  "duplicates": 1,
  "no_key": 2,
  "leads_no_key": 0,
  "missing_columns": [],
  "status_unknown": ["On hold"],
  "warnings": ["1 rows repeat a key already used above — only the first is synced."],
  "sample": [
    {
      "row_number": 2,
      "prospect_id": 2001,
      "action": "update",
      "name": "Alex Doe",
      "key": "alex@acme.com",
      "status": "ACTIVE",
      "changes": [
        { "column": "Status", "direction": "in", "from": "Active", "to": "Closed lost" }
      ],
      "status_value": "Closed lost",
      "status_from_sheet": "STOPPED"
    },
    {
      "row_number": 215,
      "prospect_id": null,
      "action": "create",
      "name": "Maria Jansen",
      "key": "maria@example.nl",
      "status": null,
      "changes": [],
      "status_value": "",
      "status_from_sheet": null
    }
  ]
}
```

| Field | Type | Description |
| - | - | - |
| `headers` | array of strings | The columns found in `header_row`. |
| `rows` | integer | Data rows in the tab. |
| `matched` | integer | Rows matched to a lead. |
| `to_create` | integer | New leads the run would create (at most 500 per run; `0` when `create_leads` is off). |
| `to_append` | integer | Rows the run would add for leads not in the Sheet (`0` when `append_rows` is off). |
| `cells_in` | integer | Lead values the Sheet would change. |
| `cells_out` | integer | Cells Seleqt would write. |
| `duplicates` / `no_key` / `leads_no_key` / `missing_columns` / `status_unknown` | | As in [last run stats](https://docs.seleqt.ai/api-reference/public/sheet-syncs.md#last-run-stats). |
| `warnings` | array of strings | Problems worth showing to the user. |
| `sample` | array | Up to 20 rows. |
| `sample[].action` | string | `update`, `in_sync` (nothing to change) or `create` (a new lead). |
| `sample[].status` | string \| null | The lead's current status. |
| `sample[].changes` | array | `{ column, direction (in \| out), from, to }` for each value that would move. |
| `sample[].status_value` / `status_from_sheet` | string / string \| null | Only with a Status column: the row's Status cell and the lead status it maps to (`null` when it matches none). |

### Error Responses

| Status | `error` | When |
| - | - | - |
| `400` | `Connect Google Sheets first.` | Google Sheets isn't connected in the workspace. |
| `400` | `Pick the lead list or campaign to sync.` | No valid `sync_id`, `campaign_id` or `search_id`. |
| `400` | `The key column "Email" isn't in row 1 of the sheet.` | The response also has `headers`, so you can pick the right column. |
| `400` | Validation and Google errors | As for [POST /public/sheet-syncs/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-create.md#error-responses). |

### Example

```bash theme={null}
curl -X POST -H "X-API-Key: <key>" \
  -H "Content-Type: application/json" \
  -d '{"sync_id": 42}' \
  "https://api.seleqt.ai/api/v1/public/sheet-syncs/preview/"
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.