Skip to content
KnockDevelopers
Magic links

Wrap chat links for their recipients

Chat with a Developer
POST
/v1/magic-links/wrap

Personalises your chat links for the people you email, with no call from the recipient's browser. Send up to 100 of your start-chat.com links, each with who will receive it: your own ID for the person (externalUserId), their email, or both. Knock returns each link with UID (a visitor ID for that recipient), kt (when it was wrapped) and ks (Knock's signature over both) added. When the recipient opens it, the chat opens as that visitor, and the email you sent appears on their lead.

The same recipient gets the same visitor ID on every call, unique to your account. The link carries no email or externalUserId: only that pseudonymous visitor ID, the time and the signature.

Knock records the email as you assert it, unverified, in your workspace only. It never replaces an email Knock already has for that person, and their lead shows it only while it has no better email. Wrapping creates no contact, sends nothing and uses no credits: the email reaches the lead when the recipient opens the link, and is then enriched and synced to your CRM like any email a lead gives.

A link identifies its recipient for 60 days (identityExpiresAt), so wrap links close to when you send them. After that the link still opens the chat, with an anonymous visitor. Until then, whoever opens a forwarded link is identified as the recipient. Use wrapped links in emails, not on your website: on a page with the Knock tag, the tag sets its own visitor ID.

All or nothing: when any item cannot be wrapped, none is, nothing is recorded and the 422 lists every failing item. Retrying is safe: the same items give the same visitor IDs (only kt and ks change).

Send Content-Type: application/json. Unknown fields are ignored.

Authorization

ApiKeyAuth
headerx-api-key<token>

Your Knock API key. Ask your Knock account team for one: a key with the Enrichment API role to enrich and route leads and find warm intros, the Viewer role to read chats, meetings, routing rules, FAQs, analytics, magic links, meeting routing rules, marketing cards and members, the Admin, Editor or AI Manager role to change FAQs, the Admin, Editor or Partner Contributor role to create marketing cards and wrap chat links, or the Admin role to set the working hours of your members.

Request Body

application/json
  1. body

The chat links to wrap, each with its recipient.

items*array<>

The links to wrap, 1 to 100. The response lists them in the same order. The same link may appear for many recipients.

Items1 <= items <= 100

Response Body

Every link, wrapped, in request order.

application/json
  1. response

Every link you sent, wrapped, in request order.

identityExpiresAt*string

Until when opening the links identifies their recipients: 60 days after they were wrapped, the same for every link of the call. After it a link still opens the chat, with an anonymous visitor.

Formatdate-time
items*array<>

One per item you sent, in the same order.

Example Request
curl -X POST 'https://app.knock-ai.com/v1/magic-links/wrap' \  -H 'x-api-key: <YOUR_API_KEY>' \  -H 'Content-Type: application/json' \  -d '{  "items": [    {      "url": "https://start-chat.com/slack/acme/AbC123?utm_source=newsletter&utm_campaign=nov"    }  ]}'
Example Response
{  "identityExpiresAt": "2027-01-09T12:00:00.000Z",  "items": [    {      "url": "https://start-chat.com/slack/acme/AbC123?utm_source=newsletter&utm_campaign=nov&UID=kml1.8xQmVb2sT0fK2mN1xYzA9w&kt=1794312000&ks=q3Vb8sT0fK2mN1xYzA9w7Q"    }  ]}