Skip to content
Quenza
MCPNew: use this help center in Claude, ChatGPT or CursorConnect →

Sync clients from your CRM

2 min read

Create clients in Quenza when a lead in your CRM becomes a client, find clients who already exist, and keep their details up to date.

Many practices keep leads in a CRM and move them to Quenza once they book. This guide connects the two: when a lead becomes a client in the CRM, your integration creates them in Quenza, remembers their Quenza ID and keeps their details in step.

Sarah Bennett, for example, tracks enquiries for Bright Path Coaching in her CRM. When she marks Emma Clarke as Booked, the CRM calls her integration, Emma gets her invitation from Quenza, and the CRM stores Emma’s Quenza ID for later updates.

Every example comes in JavaScript (Node.js 18 or later), Python (with requests) and PHP (with Guzzle); pick your language in the tabs. They all use this small helper, which sends a request and stops with an error when Quenza answers with one:

const API = 'https://developers.quenza.com/v1';
async function quenza(method, path, body) {
const response = await fetch(`${API}${path}`, {
method,
headers: {
Authorization: `Bearer ${process.env.QUENZA_API_TOKEN}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: body && JSON.stringify(body),
});
const json = response.status === 204 ? null : await response.json();
if (!response.ok) throw Object.assign(new Error(json.message), { status: response.status, errors: json.errors });
return json;
}

Create a client with their email and name. Quenza sends the invitation email straight away and assigns the client to the professional who owns the token.

const { data: client } = await quenza('POST', '/clients', {
email: 'emma.clarke@example.com',
first_name: 'Emma',
last_name: 'Clarke',
timezone: 'Europe/Amsterdam',
language_code: 'en',
});
// Store client.id ("8GJ4D9KQ") on the contact in your CRM.

Store the returned id in your CRM, for example in a custom field. Every later request about this client uses it.

An email address can belong to only one client in a workspace. When the client is already in Quenza, for example because they signed up through a landing page, the request fails with 422 and an errors.email entry. The API has no search, so look the client up in the list of clients:

async function findClientByEmail(email) {
let path = '/clients?limit=100';
while (path) {
const { data, links } = await quenza('GET', path);
const match = data.find((c) => c.email.toLowerCase() === email.toLowerCase());
if (match) return match;
path = links.next && links.next.replace(API, '');
}
return null;
}
async function createOrFindClient(contact) {
try {
return (await quenza('POST', '/clients', contact)).data;
} catch (error) {
if (error.status === 422 && error.errors?.email) return findClientByEmail(contact.email);
throw error;
}
}

A 422 without errors.email means something else, for example that your plan’s client limit is reached; the code passes those errors on. Reading the whole list for every contact is slow in a large workspace. Do it once, store the IDs in your CRM, and only fall back to the list when a contact has no ID yet.

When a phone number or name changes in the CRM, update the client with only the fields that changed:

await quenza('PATCH', `/clients/${contact.quenzaId}`, { phone: '+31 6 9876 5432' });

Leave out the fields you do not want to change. To clear an optional field, send null.

When a client leaves, archive them. Their history stays in Quenza, their assignments are cancelled and their chats become read-only. If they come back, unarchive them.

To update the CRM when something happens in Quenza, for example when a client accepts their invitation, use webhooks. Together with the API, both systems stay in step without anyone copying data by hand.

Enlarged screenshot from this article