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

# Migrate from the legacy routes

> Move your integration to /v1.

Migrate if your integration calls routes without `/v1`, such as `/bots/{id}/leads` or `/bots/{id}/templates/send`, with an API key. Those routes will stop accepting API keys, and we will [announce it in advance](https://docs.newlead.ai/versioning.md#deprecation-notice).

If you use a route that is not listed here, contact us before you migrate.

## Route map

| Legacy route | `/v1` route |
| - | - |
| `GET /bots` | `GET /v1/text_agents` |
| `GET /bots/{id}/templates` | `GET /v1/text_agents/{text_agent_id}/templates` |
| `GET /bots/{id}/qualifier/config` | `GET /v1/text_agents/{text_agent_id}/qualification`, with the questions only: no extraction settings or policies |
| `POST /bots/{id}/templates/send` | `POST /v1/messages` with `type: "template"` |
| `POST /bots/{id}/leads/{lead}/messages/manual` | `POST /v1/messages` with `type: "text"` |
| `GET /bots/{id}/leads` | `GET /v1/leads?text_agent_id={text_agent_id}`, which returns one [page](https://docs.newlead.ai/pagination.md) |
| `GET /bots/{id}/leads/{lead}` | `GET /v1/leads/{lead_id}` |
| `GET /bots/{id}/leads/{lead}/conversation` | `GET /v1/leads/{lead_id}/messages` |
| `DELETE /bots/{id}/leads/{lead}` | `DELETE /v1/leads/{lead_id}` |
| `POST /bots/{id}/leads` | `POST /v1/leads` |
| `PATCH /bots/{id}/leads/{lead}` | `PATCH /v1/leads/{lead_id}` |
| `POST /bots/{id}/leads/{lead}/ai-pause` | `POST /v1/leads/{lead_id}/pause_ai` |
| `POST /bots/{id}/leads/{lead}/ai-resume` | `POST /v1/leads/{lead_id}/resume_ai` |
| `GET /bots/{id}/leads/{lead}/ai-status` | `ai_paused` and `ai_paused_until` in `GET /v1/leads/{lead_id}` |
| `GET /properties/lookup?reference=` | `GET /v1/properties?reference=`, which returns a list of up to 3 properties and `400 parameter_invalid` if more match |

## Response changes

* **No wrapper.** The response is the resource, without `success` or `data`. Lists have `object: "list"`, `data`, `has_more` and `next_cursor`.
* **New field names.** `lead_id` becomes `id`, `bot_id` becomes `text_agent_id`, `phone_number` becomes `phone` and `dynamic_variables` becomes `variables`.
* **Phone numbers in E.164.** They always include the `+` and the country code.
* **A failed send is an error.** The legacy routes could return `200` with `sent: false`.
* **A new error format.** See [Errors](https://docs.newlead.ai/errors.md).

## Request changes

* `text_agent_id` goes in the body of `POST /v1/messages`, not in the URL.
* On leads, `phone_number` becomes `phone` and `dynamic_variables` becomes `variables`.
* On `pause_ai`, `duration_min` becomes `duration_minutes`.

### Template message fields

| Legacy field | `/v1` field |
| - | - |
| `template_name` and `template_language` | `template.name` and `template.language` |
| `components` | `template.components` |
| `dynamic_variables` | `lead_variables` |
| `manual: true` | `pause_ai: true` |
| `link_lead_id` | `source_lead_id` |

### Send text to a phone

`POST /v1/messages` with `type: "text"` requires `lead_id`. The legacy route accepted a phone and created the lead. To write to a new number, send a template, which accepts `to` and creates the lead, or create the lead first with `POST /v1/leads`.

## n8n node

Updating the package does not change your workflows: each saved node stays on version 1 and keeps calling the legacy routes. Version 1 stops working when those routes stop accepting API keys. To move a workflow, add a new **Newlead** node and configure it again.

Check these points before you migrate:

* Version 2 needs a **subaccount** key. An organization key fails the credential test.
* Phone numbers need the country code. A local number such as `600111222` returns an error.
* Version 2 cannot be used as a tool of an AI agent. A workflow that needs it has to stay on version 1 for now.
* **Message** > **Send** by phone only finds a lead that already exists. For a new number, send a template or create the lead first.
* **Lead** > **Get Many** returns 50 leads by default. Turn on **Return All** to get them all.
* Running a finished execution again sends again, unless you [set an Idempotency Key](https://docs.newlead.ai/n8n.md#retry-without-sending-twice).
* Results have the `/v1` shape, without `success` or `data`.
* In a property, `sales_agent_phone` is `null` if the phone was saved without a country code, `summary` no longer adds a note when the listing is unavailable, and `description` is no longer cut at 1,200 characters.

Version 2 does not include:

* Finding a lead by WhatsApp ID (BSUID). Use the ID or the phone.
* The `currency` and `date_time` template variables. Send them as text.
* `quick_reply` button parameters. Only URL buttons are supported.

> [accordion] Renamed fields in the node
>
> | Version 1 | Version 2 |
> | - | - |
> | **Bot Name or ID** (`botId`) | **Text Agent Name or ID** (`textAgentId`) |
> | **Lead Name or ID** and **Lead ID (Manual)** in **AI Control** | **Lead**: from the list, by ID or by phone |
> | **Lead ID, Phone or WhatsApp ID** in **Message** | **Lead**: from the list, by ID or by phone |
> | **Components** in **Template** | **Header Type**, **Header Value**, **Header Filename**, **Body Variables** and **URL Buttons** |
> | **Dynamic Variables** | **Lead Variables** |
> | **Manual Mode** | **Options** > **Pause AI** |
> | **Clear Previous Chat** | **Options** > **Clear Previous Chat** |
> | **Source Lead ID** | **Options** > **Source Lead ID** |
> | **Additional Fields** > **Name** in **Lead** > **Create** | **Name** |
> | **Options** > **Status** in **Lead** > **Get Many** | **Filters** > **Status** |

## Example: send a template

```bash Legacy route theme={null}
curl -X POST https://rest.newlead.ai/bots/<TEXT_AGENT_ID>/templates/send \
  -H "Authorization: Bearer $NEWLEAD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+34600111222",
    "template_name": "welcome",
    "template_language": "en",
    "dynamic_variables": { "city": "Madrid" },
    "manual": true
  }'
```

```bash /v1 route theme={null}
curl -X POST https://rest.newlead.ai/v1/messages \
  -H "Authorization: Bearer $NEWLEAD_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: welcome-ana-ferrer-001" \
  -d '{
    "type": "template",
    "text_agent_id": "<TEXT_AGENT_ID>",
    "to": "+34600111222",
    "template": { "name": "welcome", "language": "en" },
    "lead_variables": { "city": "Madrid" },
    "pause_ai": true
  }'
```


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