Client Registration
The seven endpoints deciding what the registration form asks and which extra fields it carries.
Overview
These seven endpoints decide what a client is asked when they register. There are two layers: the fields the system already has, and the custom ones you add.
On the built-in fields three things are set separately for each question: whether it is asked, whether it is required, and whether the client can change it later. They are independent keys, so making a field required does not start asking for it.
Custom fields belong to a language: the same field is opened as a separate record in each language, with an id of its own.
Reference
Reading the Registration Settings
Returns which fields the sign-up and sign-in flow asks for, and which are required.
curl 'https://panel.example.com/api/v1/admin/settings/client' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.example.com/api/v1/admin/settings/client', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/client');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Asking for a field and REQUIRING it are separate keys: read them together.
$cfg = Api::Settings()->GetClientSettings()['data'];
$asksGsm = $cfg['sign_up_gsm_status'] === 1;
$needsIt = $asksGsm && $cfg['sign_up_gsm_required'] === 1;Writing the Registration Settings
Applies the keys you send and leaves the rest as they are.
curl -X PUT 'https://panel.example.com/api/v1/admin/settings/client' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"sign_up_status":1,"sign_up_email_verify":1,"security_question_status":0}'const res = await fetch('https://panel.example.com/api/v1/admin/settings/client', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
sign_up_status: 1,
sign_up_email_verify: 1,
security_question_status: 0,
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/client');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'sign_up_status' => 1,
'sign_up_email_verify' => 1,
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Making a field required needs it to be ASKED FOR; switch both on together.
Api::Settings()->UpdateClientSettings([
'sign_up_gsm_status' => 1,
'sign_up_gsm_required' => 1,
]);Listing the Custom Fields
Returns the extra fields added to the registration form. They are kept per language.
active or inactive.curl -G 'https://panel.example.com/api/v1/admin/settings/client-fields' \
-H "Authorization: Bearer $API_KEY" \
-d lang=enconst url = new URL('https://panel.example.com/api/v1/admin/settings/client-fields');
url.searchParams.set('lang', 'en');
const res = await fetch(url, { headers: { Authorization: `Bearer ${apiKey}` } });
const body = await res.json();$url = 'https://panel.example.com/api/v1/admin/settings/client-fields?' . http_build_query(['lang' => 'en']);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The fields BELONG to a language: a separate list, with separate ids, for each.
$en = Api::Settings()->GetClientFields([], ['lang' => 'en'])['data'];
$tr = Api::Settings()->GetClientFields([], ['lang' => 'tr'])['data'];{
"data": [
{
"id": 5,
"lang": "en",
"type": "text",
"name": "VAT Number",
"status": "active",
"required": false,
"uneditable": false,
"client_hidden": false,
"invoice": true,
"sign_form": true,
"options": "",
"rank": 0
}
],
"meta": { "lang": "en", "total": 1 }
}Adding a Custom Field
Adds a new field to the registration form.
curl -X POST 'https://panel.example.com/api/v1/admin/settings/client-fields' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"lang":"en","name":"VAT Number","type":"text","required":1,"invoice":1,"sign_form":1}'const res = await fetch('https://panel.example.com/api/v1/admin/settings/client-fields', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
lang: 'en',
name: 'VAT Number',
type: 'text',
required: 1,
invoice: 1,
sign_form: 1,
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/client-fields');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'lang' => 'en',
'name' => 'VAT Number',
'required' => 1,
'sign_form' => 1,
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The field opens in the GIVEN language only; you have to add it for each one.
foreach (['en', 'tr'] as $lang) {
Api::Settings()->CreateClientField([
'lang' => $lang,
'name' => $lang === 'tr' ? 'Vergi No' : 'VAT Number',
'required' => 1,
'sign_form' => 1,
]);
}Ordering the Fields
Writes the order the fields appear in on the form, for one language.
curl -X PUT 'https://panel.example.com/api/v1/admin/settings/client-fields/order' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"lang":"en","order":[7,5,9]}'const res = await fetch('https://panel.example.com/api/v1/admin/settings/client-fields/order', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ lang: 'en', order: [7, 5, 9] }),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/client-fields/order');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['lang' => 'en', 'order' => [7, 5, 9]]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The order is PER LANGUAGE: each one has to be ordered separately, with its own ids.
$ids = array_column(
Api::Settings()->GetClientFields([], ['lang' => 'en'])['data'],
'id',
);
Api::Settings()->ReorderClientFields(['lang' => 'en', 'order' => array_reverse($ids)]);Updating a Custom Field
Changes an existing field. The name cannot be emptied.
curl -X PATCH 'https://panel.example.com/api/v1/admin/settings/client-fields/5' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"name":"Tax ID","required":0}'const res = await fetch('https://panel.example.com/api/v1/admin/settings/client-fields/5', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ name: 'Tax ID', required: 0 }),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/client-fields/5');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['name' => 'Tax ID', 'required' => 0]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Hiding and requiring CONTRADICT each other: a client cannot fill a field they never see.
Api::Settings()->UpdateClientField([
'id' => 5,
'client_hidden' => 1,
'required' => 0,
]);Deleting a Custom Field
Removes the field. The answers clients gave to it go as well.
curl -X DELETE 'https://panel.example.com/api/v1/admin/settings/client-fields/5' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.example.com/api/v1/admin/settings/client-fields/5', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/client-fields/5');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Switching it OFF instead of deleting keeps the answers: the field leaves the form, the data stays.
Api::Settings()->UpdateClientField(['id' => 5, 'status' => 0]);Pitfalls
Each built-in field has separate keys for being asked and for being required. Switching on the requirement alone does not put the field on the form; the client never sees it and the setting quietly does nothing. Switch both on together.
Adding a custom field creates it in the language you gave and nowhere else. With two languages on the site, clients on the second one never see that field. You have to add it for each language, and write the order for each separately.
Hiding a field from the client removes it from the account, the registration form, the invoice and the client API. Leaving it required at the same time makes registration impossible: a client cannot fill a field they never see. Clear the requirement when you hide it.
Deleting a custom field does not merely change the form: every answer clients gave to it goes with it. To stop asking without losing them, switch the field off instead; the form is tidied and the data collected stays.
Registration and sign-in are separate keys. Closing registration does not stop existing clients signing in, so shutting the system for maintenance means closing both. The reverse also holds: closing sign-in while registration stays open produces clients who can open an account but not get into it.
Related Articles
Merci pour votre retour !
Notre équipe d'assistance est disponible 24h/24 pour tout ce que vous ne trouvez pas ci-dessus.