# Continue links

Let a visitor who left a session part way carry on where they stopped, with a private link your server makes through the API.

A continue link lets a visitor who left a session part way pick up where they stopped. The agent welcomes them back by name, recaps last time in a line, and carries on from the next part of its brief, without the visitor form or the opening questions. Your server makes the link through the API when the visitor is back, and gives it only to them.

**Insurge turns this on for your workspace**

A continue link opens your agent's page, and that page has to be set up to read it. Until Insurge has set it up for your workspace, the link opens the agent's usual start, as a new session. Ask your Insurge contact before you build on continue links.

## Before you start

- An agent of the **Tour guide**, **Help desk** or **Training** kind, live (not **Paused**), with a live [share link](/docs/share/share-links). Sessions with other agents can't be continued.
- Ideally, a brief with numbered sections. Then Insurge knows exactly which section comes next. Without them the agent judges where to carry on from what it covered. See [Write the brief](/docs/agents/write-the-brief).
- An [API key](/docs/integrations/api-keys) with **Create continue links** switched on. It stays on your server.
- A [webhook](/docs/developers/webhooks) for **Meeting ended**, to hear when a visitor leaves part way. You can also find these meetings through the [API](/docs/developers/api/meetings).

## How it works

### A visitor leaves part way

When the session closes, `meeting.ended` arrives with `meeting.status` set to `abandoned`, `resumable: true`, and `progress` saying which sections they finished and which comes next. Store the meeting id against the person in your own system.

### The visitor comes back

When they are back, for example signed in to your site, your server calls `POST /api/v1/resume-links` with the meeting id, or with their email. You get a `url` that works for 7 days by default.

### You give them the link

Open the `url` in your page's iframe, or send it in a message only they receive. If you build the address yourself, the `token` field is the part after `#resume=`.

### The agent carries on

The page opens the session for that visitor, without the visitor form. In an English session the agent says "Welcome back" with the visitor's first name; in other languages it welcomes them back in that language. It recaps last time in a sentence, does whatever the brief says must happen at the start of every session, then goes to the next section. It doesn't ask the opening questions again or repeat sections already covered, unless the visitor asks.

## Make a link

**cURL**

```bash title="Make a continue link from a meeting"
curl -X POST 'https://api.insurgeai.com/api/v1/resume-links' \
  -H "Authorization: Bearer $INSURGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"meeting_id": "your_meeting_id"}'
```

**Node.js**

```js title="Make a continue link for a returning user"
// Your server, when a signed-in user opens the page with the agent on it.
async function continueLinkFor(user) {
  const res = await fetch("https://api.insurgeai.com/api/v1/resume-links", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.INSURGE_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ email: user.email, agent_id: "your_agent_id", ttl_hours: 24 }),
  });
  if (!res.ok) return null; // nothing to continue: show the agent's usual link
  const { url } = await res.json();
  return url; // put it in your iframe's src
}
```

**Python**

```python title="Make a continue link for a returning user"
import os

import requests


def continue_link_for(email: str) -> str | None:
    r = requests.post(
        "https://api.insurgeai.com/api/v1/resume-links",
        json={"email": email, "agent_id": "your_agent_id", "ttl_hours": 24},
        headers={"Authorization": f"Bearer {os.environ['INSURGE_API_KEY']}"},
        timeout=30,
    )
    if not r.ok:
        return None  # nothing to continue: show the agent's usual link
    return r.json()["url"]  # put it in your iframe's src
```

```json title="200 OK"
{
  "url": "https://acme.insurgeai.com/s/Ab3dE6gH#resume=BwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSY",
  "token": "BwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSY",
  "expires_at": "2026-12-08T11:03:10Z",
  "meeting_id": "4e1d8a2c7b5f4c3a9e6d1b8f2a7c5e30",
  "lead_id": "c41e7b2a9d3f4e6a8b1c5d7f9e2a4b6c",
  "agent_id": "product-tour",
  "progress": {
    "sections_done": [
      "Workspace",
      "Pipelines"
    ],
    "sections_total": 4,
    "next_section": "Alerts"
  }
}
```

The agent id is the last part of the agent's address in the dashboard, and `agent.id` in meeting webhooks. Every field, and every reason a link can't be made, is in the [API reference](/docs/developers/api/continue-links).

## Which sessions can be continued

`resumable` on meeting webhooks and on [Get a meeting](/docs/developers/api/meetings#get-a-meeting) is `true` when all of these hold:

- The visitor left before the end: `meeting.status` is `abandoned`.
- The visitor gave their email. Anonymous visitors can't be continued.
- The meeting was opened from a share link, not a test link or a Preview.
- The agent is a Tour guide, Help desk or Training agent, and isn't paused.

A link can still be refused when the agent has no live share link left (`no_link`), or when the visitor has since finished in a later visit (`already_completed`).

## Progress across visits

A visitor can come back more than once. Insurge treats a visit and every visit continued from it through continue links as one chain. A visit started from the agent's usual link begins a new chain.

- A link always carries on from the newest visit in the chain, even if you give the id of an older one. The answer's `meeting_id` is that newest visit. With `email`, Insurge starts from the visitor's newest meeting with the agent.
- `progress` is merged across the chain: `sections_done` lists everything they covered in any visit, and `next_section` is where the next visit starts.
- Each continued session is a new meeting, with `resumed_from_meeting_id` pointing at the visit it carried on from. It sends its own webhooks and, when the agent's meetings get briefs, has its own brief.
- When a visit reaches the end, the chain is finished: its links stop working, and new ones are refused.

## Expiry and ending links

- A link works for `ttl_hours`: 168 hours (7 days) unless you choose between 1 and 720 hours.
- It can be opened any number of times until then. Each opening starts a new session that carries on from the newest visit.
- End links early with `DELETE /api/v1/resume-links`: one by its `token`, or all of a visitor's by their `lead_id`. They stop working at once.
- A link also stops working when the visitor finishes, or when the agent is paused or changes to a kind that can't be continued.

An expired or ended link doesn't continue the session. The page opens the agent's usual start instead.

## Security

- **The link is the key.** Anyone who opens it carries on as that visitor and sees what they covered. Make it only after you know who the visitor is, for example once they have signed in to your site, and give it only to them.
- **Keep links short-lived.** Choose the shortest `ttl_hours` that fits. A link made for an iframe as the visitor arrives needs hours, not days.
- **End links you no longer need**, for example when the visitor finishes on your side or their account closes.
- **The token stays out of server logs.** It sits after `#` in the address, a part browsers don't send to servers or in the `Referer` header. Insurge keeps only a hash of it, so it can't show it again. If you lose one, make a new link.
- **A link works only where it belongs**: in your workspace, on that agent's link, for that visitor. A link for one agent can't open another.
- **Make links on your server.** The API key that makes them must never reach a browser.

## Troubleshooting

#### The link opens a new session instead of continuing

The page isn't set up to read continue links yet: ask your Insurge contact. If it is, check the link hasn't expired or been ended, that the visitor hasn't finished, and that the address still has everything after `#resume=`.

#### 422 anonymous_lead

The visitor never gave their email, so there is no one to continue. Turn on the [visitor form](/docs/agents/visitor-form) for the agent if you want returning visitors to carry on.

#### 422 not_resumable

The meeting's agent isn't a Tour guide, Help desk or Training agent, or it is paused.

#### 422 no_link

The agent has no live share link: they all expired or were removed. Make a new [share link](/docs/share/share-links) and try again.

#### 409 already_completed

The visitor reached the end in their latest visit. Send them the agent's usual link if they want to see it again.

#### 404 no_meeting with an email

No visitor with that email, or they have no meeting with an agent that can be continued. Check the email they used with the agent and, if you sent one, the `agent_id`.
