# Save people to the Leads table

Puts people in the user's Leads table, the way `save_leads` does on the assistant server. Give each person an id from mySDR (`per_…` from a search or POST /leads), or their name with `linkedin_url` and what you know: for someone you found yourself, and for people from POST /person/search and POST /person/enrich, which give no id (each match of POST /person/enrich carries these fields as `save_input`). Add a `note` on why; the user reads it in the table. Saving the same person again updates their row: what you send replaces the old value, what you leave out keeps it, and another employer replaces the old one as a whole. The Leads and Companies tables are what the user sees in mySDR. Your agent decides what goes in them: search results do not land there by themselves. The user keeps the overview there; your agent reads the same tables here and fills them with POST.

Each person can carry their state in the same call (status, next action, email, your own fields, campaign); a wrong value refuses the whole call and names the field. mySDR keeps your whole process, so the user never needs a spreadsheet next to it: the state of each company and person (status with a reason, next action, email and contact points, your own fields), every email, reply and bounce you log, the exclusions, and a check before every send. The user sees all of it in the Leads and Companies tabs.

## Authentication

Send `Authorization: Bearer gtk_…`. Create the key under **Connect assistant → API keys**. Every `gtk_` key can call these routes, also while the Signals API is closed. A missing, invalid or revoked key is **401**.

### Body parameters

- **`leads`** `object[]` · **required** — 1 to 100 people.
- **`leads[].id`** `string` — A `per_…` from the Signals API (a search or POST /leads). When given, the other fields are ignored except `note`.
- **`leads[].linkedin_url`** `string` — LinkedIn profile URL of someone you found yourself.
- **`leads[].name`** `string` — Full name. Required without `id`.
- **`leads[].title`** `string` — Job title.
- **`leads[].headline`** `string` — LinkedIn headline.
- **`leads[].company`** `string` — Employer name.
- **`leads[].company_linkedin_url`** `string` — LinkedIn page of the employer.
- **`leads[].company_domain`** `string` — Website domain of the employer.
- **`leads[].location`** `string` — Where they are based.
- **`leads[].country_code`** `string` — ISO 3166-1 alpha-2.
- **`leads[].why_now`** `string` — What happened that makes this person worth contacting now.
- **`leads[].note`** `string` — Why you save this one, up to 500 characters. The user reads it in the table.
- **`leads[].status`** `string` — `new` (in the work), `needs_decision` (waits for the user; say why in `status_reason`), `snoozed` (until `snooze_until`, then `new` again) or `archived` (out; say why). One of: `new`, `needs_decision`, `snoozed`, `archived`.
- **`leads[].status_reason`** `string | null` — Why, in a few words: "Below 50 FTE", "Rescan 23/11". Up to 500 characters.
- **`leads[].snooze_until`** `string | null` — The day the row comes back as `new`: a date (`2026-11-23`, 09:00 Brussels time) or an ISO time. Alone it snoozes the row.
- **`leads[].lead_status`** `string | null` — What they said. `not_interested` also stops LinkedIn for them and blocks a new sequence. One of: `interested`, `meeting`, `later`, `not_interested`.
- **`leads[].next_action`** `object | null` — Your next step and when: `at` (a date or ISO time), `kind` (`follow_up`, `recontact`, `rescan`, `approval`, `other`), `note`, and `email` when that step is an email you will send yourself: `{ "text", "subject", "step", "template", "to" }` (`text` required, up to 20,000 characters; `subject` up to 200 and `template` up to 80, as in POST /outreach/activity; `step` 1 to 20; `to` only if it is not the row’s address; `kind` defaults to `follow_up`). The user sees the planned email on Templates, with the emails you already logged above it, and GET /agenda gives it back on its day, so you keep no copy. A list (GET /tables/leads, /tables/companies) gives it without `text`; one row (GET /tables/leads/{id}, /tables/companies/{id}), the response of a change and GET /agenda give the text. Logging `email_sent` with the same `step` clears it (logged without a step, it clears one planned without a step), and so do a reply, a meeting, a bounce, an unsubscribe, a referral and `not_interested`; plan the next one. A new `next_action` replaces the current one and the email planned for it (`replaced` in the response gives them back); `null` clears both. GET /agenda lists the due ones.
- **`leads[].out_of_office_until`** `string | null` — Away until this day (from an out-of-office reply).
- **`leads[].email`** `string | null` — Their email address.
- **`leads[].email_status`** `string | null` — What verification said about that address. One of: `verified`, `catch_all`, `unverifiable`, `not_found`, `bounced`.
- **`leads[].fields`** `object` — Your own columns, merged with what is there: a name in lowercase letters, digits and `_` (`fte`, `ats`, `open_roles`) with a value (text, number, true/false) or `{ "value", "label", "source_url", "observed_at" }`; `null` removes one. Up to 40 per row. The user sees them as columns.
- **`leads[].campaign_id`** `string` — Put the row in this campaign (POST /outreach/campaigns, or one from a LinkedIn sequence).
- **`leads[].campaign_ids`** `string[]` — Replaces the campaigns of the row.
- **`leads[].stage`** `string | null` — One of the organization's own stages (GET /stages), by its key (`mql`) or its name ("MQL"); `null` clears it. A stage sits next to `status`: it stops nothing and changes no status. A change is logged.
- **`leads[].owner`** `string | null` — Who in the team follows the row up: `me` (the user behind the key), or the email address or user id of a colleague (GET /team); `null` clears it. A change is logged.

## Response

- **`added`** `integer` · **required** — New rows.
- **`updated`** `integer` · **required** — Rows that were there already. Saving again updates the row: what you send replaces the old value, what you leave out keeps it.
- **`skipped`** `integer` · **required** — Items that were not saved.
- **`saved`** `object[]` · **required** — Each saved item: `ref` (the id, LinkedIn URL or name you sent), `id` (what DELETE takes), `name` and `status` (`added` or `updated`).
- **`not_saved`** `object[]` · **required** — Each skipped item: `ref`, `code` (`invalid_ref`, `not_found`, `no_name`, `duplicate`, `table_full`) and `reason`.
- **`saved_by_assistant`** `integer` · **required** — How many rows of this kind agents saved in total.
- **`dashboard_url`** `string` · **required** — The table in mySDR.
- **`state`** `object[]` — With a state in the body: per saved row its `id` and `status` (`set`, `unchanged`, `not_ready` or `failed`, with a `reason`), and `replaced` when a new `next_action` replaced one (with its planned email).

## Credits

Free. This call never uses credits.

## Errors

- **400** `invalid_request` — No `leads`, more than 100, an unknown field (the error names it in `param`), a value that is too long, or a state that is not valid (`param` names it, e.g. `leads[1].snooze_until`).
- **401** `authentication_error` — The Authorization header is missing, or the key is unknown or revoked.
- **403** `permission_error` — API access is not part of your plan, or your account is suspended.
- **429** `rate_limit_error` — More than 60 requests per minute, or more than 3 at the same time, on one key. Wait for the Retry-After header.
- **503** `service_unavailable` — The API is temporarily unavailable. Retry later.
- **500** `internal_error` — Something went wrong on our side.

## Example

### cURL

```bash
curl -X POST "https://mysdr.app/api/v1/tables/leads" \
  -H "Authorization: Bearer $MYSDR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "leads": [
      {
        "id": "per_01J9Z6P8C8V0K3W6T2N8R5M1XB",
        "note": "CFO at a company that raised a Series A last week."
      },
      {
        "name": "Ann Example",
        "linkedin_url": "https://www.linkedin.com/in/ann-example",
        "company": "Gamma",
        "note": "Posted about switching CRM."
      }
    ]
  }'
```

### JavaScript

```javascript
const response = await fetch('https://mysdr.app/api/v1/tables/leads', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MYSDR_API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "leads": [
      {
        "id": "per_01J9Z6P8C8V0K3W6T2N8R5M1XB",
        "note": "CFO at a company that raised a Series A last week."
      },
      {
        "name": "Ann Example",
        "linkedin_url": "https://www.linkedin.com/in/ann-example",
        "company": "Gamma",
        "note": "Posted about switching CRM."
      }
    ]
  })
});
const body = await response.json();
```

### Python

```python
import json
import os
import urllib.request

payload = {
  "leads": [
    {
      "id": "per_01J9Z6P8C8V0K3W6T2N8R5M1XB",
      "note": "CFO at a company that raised a Series A last week."
    },
    {
      "name": "Ann Example",
      "linkedin_url": "https://www.linkedin.com/in/ann-example",
      "company": "Gamma",
      "note": "Posted about switching CRM."
    }
  ]
}

request = urllib.request.Request(
    "https://mysdr.app/api/v1/tables/leads",
    headers={
    "Authorization": f"Bearer {os.environ['MYSDR_API_KEY']}",
    "Content-Type": "application/json"
    },
    data=json.dumps(payload).encode(),
    method="POST",
)
with urllib.request.urlopen(request) as response:
    body = json.load(response)
```

### Example response

```json
{
  "added": 2,
  "updated": 0,
  "skipped": 0,
  "saved": [
    {
      "ref": "per_01J9Z6P8C8V0K3W6T2N8R5M1XB",
      "id": "per_01J9Z6P8C8V0K3W6T2N8R5M1XB",
      "name": "Jane Example",
      "status": "added"
    },
    {
      "ref": "https://www.linkedin.com/in/ann-example",
      "id": "sav_7c1f2a40-5b0e-4c3e-9a71-2f7d3e0c9b11",
      "name": "Ann Example",
      "status": "added"
    }
  ],
  "not_saved": [],
  "saved_by_assistant": 14,
  "dashboard_url": "https://mysdr.app/en/gtm/leads"
}
```
