# Migrate to 4.0

> Every removed SDK call, attribute, Console setting, Conversation API field and webhook event, with its replacement.

Source: https://docs.gydr.ai/migrate-to-4

Version 4.0 replaces the two-token model with one simple idea: the page gives the widget the visitor’s own token, Gydr checks it through a sign-in source, and Gydr alone makes every visitor id. Read [Signed-in visitors](https://docs.gydr.ai/widget/signed-in-visitors) first; this page is the old-to-new lookup.

**The old calls do nothing, they do not break your page.** Each removed SDK name logs one line (`[Gydr] identify() was removed in 4.0 — use setVisitorDetails()`), does nothing and never throws. Details and sign-in are off until you migrate. The notices stay until Gydr’s telemetry shows no calls for 30 days.

### Who has to do something

| If you… | What happens | Do this |
| --- | --- | --- |
| run WordPress with plugin 1.4.x or older | Visitors are guests (`source_not_ready`) until the plugin updates. | Update to 1.5.0 through the normal WordPress updater (published right after the v4 release). |
| sign tokens for Gydr on your server (a shared secret) | Sign-in stops and the old key is disabled. | Use Your keys (your own key pair) or Your backend. |
| call identify() or the old setters or attributes | A removal notice; details and sign-in are off. | Use setVisitorDetails and setVisitorTokenProvider or the endpoint attribute. |
| set data-visitor-id yourself | Those visitors get a new vis\_ id; history under the old id is not reachable. | Add a sign-in source for cross-device history. |
| call the Conversation API with your own visitorId or an identity | Refused. | Send userId (scope user:assert) or the visitorId Gydr returned; send visitorDetails. |
| consume webhooks | visitor.identified is gone; visitor events carry new fields. | Subscribe to visitor.details\_updated. |
| receive Custom Desk payloads | verifiedSubject is gone. | Read visitor.userId and visitor.signInSourceId. |
| link signed-in visitors to a desk with a custom id claim | The link is switched off. | Re-enable it after choosing the source's User ID claim. |

### SDK calls and attributes

| Before (3.x) | Now (4.0) |
| --- | --- |
| `Gydr.identify({ name, email, phone, company })` | `Gydr.setVisitorDetails({ name, email, phone, company })` |
| `identify({ latitude, longitude })` | `setVisitorDetails({ location: { latitude, longitude, name? } })` |
| `identify({ visitorId })` | Removed. Gydr makes the visitor id. For cross-device history use a sign-in source. |
| `identify({ identityToken })` | `Gydr.setVisitorTokenProvider(...) or data-visitor-token-endpoint` |
| `identify({ visitorIdentity })` | The same call: the token (or the origin map) you give `setVisitorTokenProvider`. |
| `identify({ shopifyCartId })` | `Gydr.setCart({ shopifyCartId })` |
| `shopifyCustomerToken (chatbox context field)` | Retired. Supply the buyer’s Customer Account API token as the visitor token keyed by the store origin: `setVisitorTokenProvider(async () => ({ visitorToken: { "https://shop.myshopify.com": token } }))`. |
| `Gydr.setIdentityTokenProvider(fn)` | `Gydr.setVisitorTokenProvider(fn)` |
| `Gydr.setGydrIdentityProvider(fn)` | `Gydr.setVisitorTokenProvider(fn)` |
| `Gydr.setVisitorIdentityProvider(fn)` | `Gydr.setVisitorTokenProvider(fn)` |
| — | New: `Gydr.refreshVisitorToken()` after your own sign-in or sign-out. |
| `data-identity-endpoint` | `data-visitor-token-endpoint` |
| `data-identity-token` | Removed. Never put a token in the page; serve it from the endpoint. |
| `data-visitor-id` | Removed. Gydr makes the visitor id. |
| `data-visitor-name`, `-email`, `-phone`, `-company`, `-latitude`, `-longitude` | Unchanged. |

Before and after:

```js
// 3.x
Gydr.setGydrIdentityProvider(async () => await auth.getToken())
Gydr.identify({ name: 'Siti', email: 'siti@example.com' })

// 4.0
Gydr.setVisitorTokenProvider(async () => ({ visitorToken: await auth.getToken() }))
Gydr.setVisitorDetails({ name: 'Siti', email: 'siti@example.com' })
```

### Console and plugins

| Before (3.x) | Now (4.0) |
| --- | --- |
| Settings → Signed-in visitors, with identity providers (shared secret, JWKS) | Settings → Visitor sign-in, with sign-in sources: WordPress, Your keys, Your backend. One source per widget, plus a token origin. |
| “Gydr Identity” and “Visitor Identity” as two tokens | One visitor token. The token your identity provider issues is the visitor token. |
| Plugin Identity tab: identity fields, mapping, trusted sources | Removed. Plugins are sent the token; the mapping and trust lists are gone. |
| Plugin setting: forward Gydr Identity or Visitor Identity | **Send the visitor’s token** (REST API, MCP) or **Uses the visitor’s token automatically** (Shopify, WooCommerce). |
| `requiresVisitorAuth` | `requiresVisitorToken` |
| `forwardsVisitorIdentity` | `forwardsVisitorToken` |
| `visitorIdentity { source, headerName, headerScheme, sendPluginAuth }` | `visitorToken { enabled, headerName, headerScheme, sendPluginAuth }` |
| `visitor_identity_rejected` | `visitor_token_rejected` |
| `visitor_identity_forbidden` | `visitor_token_forbidden` |
| `VisitorIdentityUnmatched` | `VisitorTokenUnmatched` |
| `X-Gydr-Visitor-Identity` | `X-Gydr-Visitor-Token` |
| `gydr_visitor_identity_rejected` | `gydr_visitor_token_rejected` |
| `identity:assert` | `user:assert` (existing keys are converted for you) |

### Conversation API

| Before (3.x) | Now (4.0) |
| --- | --- |
| `createSession` with your own `visitorId` | Omit it. Gydr returns `visitorId`; pass that back only to continue a conversation you created. |
| `identity { sub, … }` (scope `identity:assert`) | `userId` (scope `user:assert`; the widget needs a sign-in source, else 400 `no_sign_in_source`) |
| `visitorContext` | `visitorDetails` |
| `sendMessage` with `identity` | Refused (400). The user is fixed per session at createSession. |
| `submitForm` with `visitorId` or `identity` | `{ formId, answers }` only. |
| `getSession.visitorId` (a database id) | Gydr’s visitor id string, plus `userId` for a signed-in session. |

### Webhooks and desks

| Before (3.x) | Now (4.0) |
| --- | --- |
| `visitor.identified` | `visitor.details_updated` — fired when a value actually changes, from every writer. |
| Visitor events carry visitorId only | Every visitor-bearing event carries `visitorId`, `userId` (signed-in only) and `signInSourceId`. |
| `visitorContext` | `visitorDetails` |
| Custom Desk `shareVerifiedIdentity` | `linkSignedInVisitors` — the same link Zendesk, Freshchat and LiveChat use |
| Custom Desk `data.verifiedSubject` | `visitor.userId` and `visitor.signInSourceId` |
| Custom Desk `visitor { visitorId, name, email, phone }` | `visitor { visitorId, userId?, signInSourceId?, visitorDetails }` |
| Desk link `identityProviderId` and `externalIdClaim` | A switch plus a sign-in source pin. Vendor ids (Zendesk external id, Freshchat reference id, LiveChat entity id) come from the User ID. |
| Zanroo | Unchanged. |

### Ids and history

-   A visitor id you chose is replaced by a fresh `vis_…` id at the cutover. Browser-minted ids from earlier SDK versions keep working.
-   A signed-in visitor’s id begins `usr_`. Existing signed-in ids carry over unchanged.
-   History is no longer unlocked because your backend accepted a token. A visitor who is signed in through a sign-in source has history on every device; everyone else has this browser’s.
-   A guest conversation never follows into a sign-in, and a sign-out starts a fresh visitor.

Check your setup after migrating

In Console → Settings → Visitor sign-in use **Test a token** with a real token: it runs the same check as production and shows the User ID or the reason code from the [reason-code table](https://docs.gydr.ai/widget/signed-in-visitors).
