> ## 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

## Google Sheet Syncs API

A Google Sheet sync keeps one tab of a Google spreadsheet and one lead list or campaign in step, both ways. Each row is a lead, matched by a **key column** (email or LinkedIn URL). You choose which column is which lead field and which way each column flows. A column mapped to **Status** carries the [lead status](https://docs.seleqt.ai/api-reference/public/lead-status.md) — a row set to "Stopped" (or a value you map to it) stops all outreach to that person in every campaign.

### Before you start

* Google Sheets must be connected in the app (**Settings › Integrations › Google Sheets**).
* Seleqt only has access to spreadsheets the connected Google account picked in Seleqt (Google's `drive.file` permission). **Pick the spreadsheet once in the app** (with the Google picker, e.g. when setting up a sync or an export). After that, the API can create and manage syncs for it with its `spreadsheet_id` (the long ID in the spreadsheet's URL: `docs.google.com/spreadsheets/d/<spreadsheet_id>/edit`). A spreadsheet that was never picked fails with "Seleqt can't open this spreadsheet any more".

### Available Endpoints

* **[GET /public/sheet-syncs/](#get-sheet-syncs)** - List the syncs of the workspace, a lead list or a campaign
* **[POST /public/sheet-syncs/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-create.md)** - Connect a tab (runs the first sync right away)
* **[POST /public/sheet-syncs/preview/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-preview.md)** - What a sync would do, without writing anything
* **[GET /public/sheet-syncs/fields/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-fields.md)** - The lead fields a column can map to
* **[GET /public/sheet-syncs/:id/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-get.md)** - One sync
* **[PATCH /public/sheet-syncs/:id/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-update.md)** - Change its settings, pause or resume it
* **[DELETE /public/sheet-syncs/:id/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-delete.md)** - Disconnect (the Sheet and the leads stay)
* **[POST /public/sheet-syncs/:id/sync-now/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-sync-now.md)** - Run it now
* **[GET /public/sheet-syncs/:id/logs/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-logs.md)** - Its log

### How a sync works

* **Runs:** every 5 minutes, plus on demand with [sync now](https://docs.seleqt.ai/api-reference/public/sheet-syncs-sync-now.md).
* **Matching:** each row is a lead by its key column. Columns are found by their header text (in `header_row`), so renaming the tab, reordering or inserting columns doesn't break anything. A mapped column that is gone is skipped and reported. Blank rows and rows without a key are skipped; when a key repeats, only its first row is synced.
* **Sheet → Seleqt** (`in` / `both`): a cell that changed since the last run updates the lead.
* **Seleqt → Sheet** (`out` / `both`): a lead value that changed since the last run is written to its cell. Write-only fields (company, last reply, campaign status, ...) always follow the lead.
* **Changed in both places:** the Sheet wins, and the log keeps the Seleqt value it replaced.
* **First run for a row:** nothing is overwritten on either side; only empty cells and empty lead fields are filled. A Status that stops outreach still applies.
* **Empty values** never clear the other side. The one exception is `next_action` / `next_action_date`: when the lead has no pending step, the cell is cleared, but only while it still holds the value the sync wrote there (anything typed in the Sheet stays).
* **The key column** is never overwritten from the Sheet. When the key changes in Seleqt, the row is still found and gets the new value.
* **New rows → new leads** when `create_leads` is on, at most **500 per run** (the rest follow on the next runs). In a campaign, new leads then follow the campaign's "Automatically launch new leads" setting.
* **New leads → new rows** when `append_rows` is on, at most 2000 per run.
* **Deleted rows** never delete leads: the lead stays in Seleqt (logged once) and isn't added back to the Sheet.
* A sync reads up to 20,000 rows and columns up to `ZZ`.

### The sync object

```json theme={null}
{
  "id": 42,
  "search_id": null,
  "campaign_id": 456,
  "spreadsheet_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789",
  "spreadsheet_name": "Q4 pipeline",
  "sheet_id": 0,
  "sheet_name": "Leads",
  "header_row": 1,
  "key_field": "email",
  "key_column": "Email",
  "mappings": [
    { "column": "First name", "field": "first_name", "direction": "both" },
    { "column": "Company", "field": "company.name", "direction": "out" },
    { "column": "Status", "field": "lead_status", "direction": "both" },
    { "column": "Deal stage", "field": "custom_fields.deal_stage", "direction": "in" }
  ],
  "status_values": { "Closed lost": "STOPPED", "Demo planned": "MEETING_BOOKED" },
  "create_leads": true,
  "append_rows": true,
  "enabled": true,
  "last_synced_at": "2026-11-24T10:05:12Z",
  "last_error": "",
  "last_stats": {
    "rows": 214, "matched": 208, "leads_updated": 3, "cells_written": 5, "rows_appended": 1,
    "leads_created": 2, "rows_deleted": 0, "duplicates": 1, "no_key": 3, "leads_no_key": 0,
    "overwritten": 0, "missing_columns": [], "status_unknown": ["On hold"]
  },
  "created_at": "2026-11-20T14:31:09Z"
}
```

| Field | Type | Description |
| - | - | - |
| `id` | integer | Sync ID. |
| `search_id` | integer \| null | The lead list it syncs with (the API calls lead lists "searches" here). |
| `campaign_id` | integer \| null | The campaign it syncs with. Exactly one of `search_id` / `campaign_id` is set. |
| `spreadsheet_id` | string | Google spreadsheet ID. |
| `spreadsheet_name` | string | The spreadsheet's title, refreshed on every run. |
| `sheet_id` | integer \| null | The tab's Google ID. It survives a rename. |
| `sheet_name` | string | The tab's title, refreshed on every run. |
| `header_row` | integer | The row that holds the column headers (1–50). Data starts on the next row. |
| `key_field` | string | What identifies a lead: `email` or `linkedin_profile_url`. |
| `key_column` | string | The header of the column holding the key. |
| `mappings` | array | Which column is which lead field, and which way it flows — see below. |
| `status_values` | object | Your Sheet's words for lead statuses: `{ "<Sheet value>": "<STATUS>" }` — see below. |
| `create_leads` | boolean | New rows in the Sheet become new leads. |
| `append_rows` | boolean | New leads in Seleqt get a new row in the Sheet. |
| `enabled` | boolean | `false` while the sync is paused (by you, or because the spreadsheet or tab is gone). |
| `last_synced_at` | string \| null | When the last run finished (ISO 8601). |
| `last_error` | string | Why the last run failed; empty when it succeeded. |
| `last_stats` | object | The last run's counts — see below. |
| `created_at` | string | ISO 8601 timestamp. |

#### Mappings

Each mapping is `{ "column": "<header>", "field": "<lead field>", "direction": "both" | "in" | "out" }`.

* `field`: a lead field from [GET /public/sheet-syncs/fields/](https://docs.seleqt.ai/api-reference/public/sheet-syncs-fields.md) — `first_name`, `last_name`, `email`, `phone_number`, `job_title`, `linkedin_profile_url`, `location`, `headline`, `about`, `lead_status`, or a custom field as `custom_fields.<name>`; write-only fields `full_name`, `company.name`, `company.website_url`, `company.industry`, `campaign_status`, `next_action`, `next_action_date`, `last_reply`, `replied_at`, `score`.
* `direction`: `both` (default), `in` (Sheet → Seleqt only) or `out` (Seleqt → Sheet only).
* Saved mappings are cleaned: a column is used at most once; write-only fields are always `out` (an `in` mapping of one is dropped); the field used as the key is always `out`.

#### Next action

`next_action` is the lead’s next pending step in its campaign, the same one the campaign’s lead table shows: the step’s name, else its type (`LinkedIn invite`, `Email`, `Checking if invite accepted`, ...). `next_action_date` is when that step is scheduled, as `YYYY-MM-DD HH:MM` in UTC. Both are write-only and are refreshed on every run.

#### Status values

A column mapped to `lead_status` reads and writes lead statuses. A Sheet value matches a status when it is:

1. a key of `status_values` (up to 100 entries, values up to 100 characters), or
2. the status code or label (`STOPPED`, `Meeting booked`, ...), or
3. one of the built-in words: active, in progress, contacted, in sequence → `ACTIVE`; replied, responded → `REPLIED`; interested, hot → `INTERESTED`; meeting booked, meeting scheduled, meeting → `MEETING_BOOKED`; not interested → `NOT_INTERESTED`; bounced → `BOUNCED`; unsubscribed, opted out → `UNSUBSCRIBED`; stopped, stop, do not contact, dnc, closed lost, lost → `STOPPED`.

Matching ignores case, extra spaces, `_` and `-`. A value that matches nothing is skipped and reported in `last_stats.status_unknown`. When Seleqt writes a status to the Sheet, it writes the first `status_values` key mapped to that status, else the status label.

A status from the Sheet that stops outreach stops the person in **every campaign**. Changing it back in the Sheet does not restart anything — outreach is resumed in the app or with the [lead status endpoints](https://docs.seleqt.ai/api-reference/public/lead-status-set.md). Changes from a sync are recorded with source `SHEET`.

#### Last run stats

| Field | Description |
| - | - |
| `rows` | Data rows read from the tab. |
| `matched` | Rows matched to a lead. |
| `leads_updated` | Leads updated from the Sheet. |
| `cells_written` | Cells Seleqt wrote to the Sheet. |
| `rows_appended` | Rows added for new leads. |
| `leads_created` | Leads created from new rows. |
| `rows_deleted` | Leads whose row was deleted from the Sheet. |
| `duplicates` | Rows whose key repeats a row above (skipped). |
| `no_key` | Rows without a valid key (skipped). |
| `leads_no_key` | Leads without an email / LinkedIn URL, so they can't be synced. |
| `overwritten` | Values changed in both places where the Sheet won. |
| `missing_columns` | Mapped columns no longer in the header row. |
| `status_unknown` | Status values that match no lead status. |
| `error_kind` | After a failed run: `access`, `gone`, `quota` or `other`. |

### When a run fails

The error is saved in `last_error` and logged; the sync keeps running every 5 minutes unless noted.

| `error_kind` | `last_error` | What to do |
| - | - | - |
| `access` | `Google Sheets isn't connected. Reconnect it in Settings › Integrations.` | Reconnect Google Sheets in the app. |
| `access` | `Seleqt can't open this spreadsheet any more. Pick it again in Google Sheets (or reconnect Google).` | Access was revoked, or the spreadsheet was never picked in Seleqt. Pick it again in the app. |
| `gone` | `The spreadsheet was deleted or moved out of reach.` / `The tab "<name>" is no longer in the spreadsheet.` | **The sync is paused** (`enabled: false`). Fix the spreadsheet, then resume with `PATCH {"enabled": true}`. |
| `quota` | `Google's rate limit was reached — the next run tries again.` | Nothing; the next run retries. |
| `other` | `The key column "<name>" isn't in row <n> of the sheet.` | Restore the column or change `key_column` / `header_row`. |
| `other` | `Google Sheets error: ...` | Check the message; the next run retries. |

***

## GET /api/v1/public/sheet-syncs/

List Google Sheet syncs, newest first.

Auth: `X-API-Key`

### Query Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `campaign_id` | integer | No | Only the syncs of this campaign. |
| `search_id` | integer | No | Only the syncs of this lead list. |

Without either, every sync in the workspace is returned.

### Response

```json theme={null}
{
  "success": true,
  "connected": true,
  "syncs": [
    {
      "id": 42,
      "search_id": null,
      "campaign_id": 456,
      "spreadsheet_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789",
      "spreadsheet_name": "Q4 pipeline",
      "sheet_name": "Leads",
      "key_field": "email",
      "key_column": "Email",
      "enabled": true,
      "last_synced_at": "2026-11-24T10:05:12Z",
      "last_error": "",
      "...": "see the sync object above"
    }
  ]
}
```

| Field | Type | Description |
| - | - | - |
| `success` | boolean | Always `true` on a successful response. |
| `connected` | boolean | Whether Google Sheets is connected in the workspace. |
| `syncs` | array | [Sync objects](#the-sync-object). Empty when the campaign or list isn't found. |

### Example

```bash theme={null}
curl -H "X-API-Key: <key>" \
  "https://api.seleqt.ai/api/v1/public/sheet-syncs/?campaign_id=456"
```


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