Client Security
The five endpoints that manage the password, verification, two-step sign-in and the security rules set on a client.
Overview
These five endpoints carry the security decisions an operator applies to a client account: setting the password, marking a field verified, turning on two-step verification, tightening sign-in and payment rules, and limiting support access.
None of them ask the client anything. They all apply directly, which is why a key carrying these endpoints is worth keeping narrow.
Reference
Changing the Password
Sets the client's password directly. The current one is not asked for.
options/password-length characters; defaults to 6.password exactly. Leave it out and no check is made.error.details.min.curl -X PUT 'https://panel.example.com/api/v1/admin/clients/42/password' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"password":"Str0ngP@ssw0rd","password_confirmation":"Str0ngP@ssw0rd"}'const res = await fetch('https://panel.example.com/api/v1/admin/clients/42/password', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
password: 'Str0ngP@ssw0rd',
password_confirmation: 'Str0ngP@ssw0rd',
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/clients/42/password');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'password' => $newPassword,
'password_confirmation' => $newPassword,
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Clients()->SetClientPassword([
'id' => 42,
'password' => $newPassword,
]);Verifying Email and Phone
Marks a field as verified. No code is sent to the client; the flag is set directly.
email or phone.email or phone.type is neither of the two values.curl -X POST 'https://panel.example.com/api/v1/admin/clients/42/verify' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"type":"email"}'const res = await fetch('https://panel.example.com/api/v1/admin/clients/42/verify', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ type: 'email' }),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/clients/42/verify');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['type' => 'email']),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// You set the flag here after running your own verification flow.
$response = Api::Clients()->VerifyClient([
'id' => 42,
'type' => 'email',
]);Two-Step Verification
Turns the client's two-step verification on or off; a method that could not deliver its code is refused and nothing is written. Turning it off also closes the client's open sessions and removes their trusted devices.
Email or Sms. It must be active in the 2FA method list and its delivery channel needs a module (mail/SMTP for Email, SMS for Sms); Sms also needs a mobile phone number on the client. Totp needs the client's own authenticator setup and is refused. Required only when enabling; not needed to disable.method was missing on an enable request.curl -X PUT 'https://panel.example.com/api/v1/admin/clients/42/2fa' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"enabled":true,"method":"Email"}'const res = await fetch('https://panel.example.com/api/v1/admin/clients/42/2fa', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ enabled: true, method: 'Email' }),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/clients/42/2fa');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'enabled' => true,
'method' => 'Email',
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// You do not need to send a method when turning it off.
$response = Api::Clients()->SetClient2fa([
'id' => 42,
'enabled' => false,
]);Security Settings
Changes the security rules that apply to this client. Only the fields you send change.
clients/document-filters.curl -X PATCH 'https://panel.example.com/api/v1/admin/clients/42/security-settings' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"block_proxy":true,"blocked_gateways":["PayPal"]}'const res = await fetch('https://panel.example.com/api/v1/admin/clients/42/security-settings', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ block_proxy: true, blocked_gateways: ['PayPal'] }),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/clients/42/security-settings');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'block_proxy' => true,
'blocked_gateways' => ['PayPal'],
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Clients()->UpdateClientSecuritySettings([
'id' => 42,
'block_proxy' => true,
]);Support Settings
Restricts or closes the client's ability to open support tickets.
block_tickets; the other restrictions are left alone.curl -X PATCH 'https://panel.example.com/api/v1/admin/clients/42/support-settings' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"ticket_restricted":true}'const res = await fetch('https://panel.example.com/api/v1/admin/clients/42/support-settings', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ ticket_restricted: true }),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/clients/42/support-settings');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['ticket_restricted' => true]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Clients()->UpdateClientSupportSettings([
'id' => 42,
'ticket_restricted' => true,
]);Pitfalls
The endpoint is an operator tool: it writes a new password without knowing the current one. The flow where a client changes their own password is a different one and lives in the Client API.
verify only sets the flag; no email or SMS reaches the client. Call it after your own verification flow has run, not instead of it.
block_proxy blocks and allow_proxy exempts. Sending both as on leaves a contradictory state; send only the one you mean.
Related Articles
Ευχαριστούμε για τα σχόλιά σας!
Η ομάδα υποστήριξής μας είναι διαθέσιμη όλο το εικοσιτετράωρο για οτιδήποτε δεν βρίσκετε παραπάνω.