Site Settings
The six endpoints behind the company details, the site systems and the search engine details.
Overview
These six endpoints hold the settings that describe the installation itself: who the company is, how to reach it, which systems are on, and what the site tells search engines.
All three pairs work the same way: one endpoint reads every setting, the other applies the fields you send and leaves the rest alone. But the shape changes in three places, and those are this article's pitfalls.
Reference
Reading the Basic Settings
Returns the company details, the contact channels and the contact form settings.
curl 'https://panel.example.com/api/v1/admin/settings/basic' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.example.com/api/v1/admin/settings/basic', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/basic');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The company details are kept PER LANGUAGE: each carries its own name and address.
$basic = Api::Settings()->GetBasicSettings()['data'];
$name = $basic['company']['en']['company_name'];{
"data": {
"company": {
"en": {
"company_name": "Example Inc.",
"address": "123 Market Street",
"informations": ""
}
},
"email_addresses": ["[email protected]"],
"phone_numbers": ["+1 555 0100"],
"social_links": [
{ "icon": "fa-x", "name": "X", "url": "https://x.com/example" }
],
"map_embed_code": "",
"contact_form": 1,
"contact_form_mandatory_phone": 0,
"contact_map": 1
}
}Writing the Basic Settings
Applies the fields you send. The list fields are replaced, not merged.
curl -X PUT 'https://panel.example.com/api/v1/admin/settings/basic' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"company":{"en":{"company_name":"Example Inc.","address":"123 Market Street","informations":""}},"email_addresses":["[email protected]"],"contact_form":1}'const res = await fetch('https://panel.example.com/api/v1/admin/settings/basic', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
company: {
en: {
company_name: 'Example Inc.',
address: '123 Market Street',
informations: '',
},
},
contact_form: 1,
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/basic');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'company' => ['en' => ['company_name' => 'Example Inc.']],
'contact_form' => 1,
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// To ADD one address send the existing list too: the list is written whole.
$basic = Api::Settings()->GetBasicSettings()['data'];
$emails = $basic['email_addresses'];
$emails[] = '[email protected]';
Api::Settings()->UpdateBasicSettings(['email_addresses' => $emails]);Reading the Advanced Settings
Returns the settings for the basket, orders, support, limits, cache and embedded codes.
curl 'https://panel.example.com/api/v1/admin/settings/advanced' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.example.com/api/v1/admin/settings/advanced', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/advanced');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// File sizes come back in BYTES but are written in megabytes; convert the unit.
$adv = Api::Settings()->GetAdvancedSettings()['data'];
$mb = (int) round($adv['attachment_max_file_size'] / 1048576);Writing the Advanced Settings
Applies the fields you send and leaves the rest as they are.
curl -X PUT 'https://panel.example.com/api/v1/admin/settings/advanced' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"basket_system":1,"use_coupon":1,"cookie_policy":{"status":1,"page":0},"cache":1}'const res = await fetch('https://panel.example.com/api/v1/admin/settings/advanced', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
basket_system: 1,
use_coupon: 1,
cache: 1,
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/advanced');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'basket_system' => 1,
'use_coupon' => 1,
'cache' => 1,
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The size is written in MEGABYTES; do not send back the byte value you read.
Api::Settings()->UpdateAdvancedSettings([
'attachment_max_file_size' => 10,
]);Reading the SEO Settings
Returns what the home page tells search engines.
curl 'https://panel.example.com/api/v1/admin/settings/seo' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.example.com/api/v1/admin/settings/seo', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/seo');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The response is keyed by language; the write is keyed by FIELD. The two shapes differ.
$seo = Api::Settings()->GetSeoSettings()['data'];
$en = $seo['en']['title'];Writing the SEO Settings
Writes the home page meta details. The body is keyed by field, not by language.
curl -X PUT 'https://panel.example.com/api/v1/admin/settings/seo' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title":{"en":"Home"},"description":{"en":"Welcome."}}'const res = await fetch('https://panel.example.com/api/v1/admin/settings/seo', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
title: { en: 'Home' },
description: { en: 'Welcome.' },
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/settings/seo');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'title' => ['en' => 'Home'],
'description' => ['en' => 'Welcome.'],
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Reading is keyed by language, writing by field: you have to invert the shape.
$seo = Api::Settings()->GetSeoSettings()['data'];
$titles = [];
foreach ($seo as $lang => $meta) $titles[$lang] = $meta['title'];
$titles['en'] = 'Home';
Api::Settings()->UpdateSeoSettings(['title' => $titles]);Pitfalls
The read returns objects grouped by language code; the write expects objects grouped by field name. Sending back what you read does not work, you have to invert the shape. The other two pairs have no such difference.
On the advanced settings the maximum file size fields come back in bytes but are written in megabytes. Sending the value you read straight back raises the limit a millionfold, and no error says a word about it.
The contact e-mails, the phone numbers and the social links are replaced by the list you send. Adding one address means reading the current list and appending to it, or the rest are deleted.
The company name, the address and the extra information are kept separately for each language. Writing to one language leaves the others as they were, so on a multilingual site a visitor can see a different company name depending on their language.
In the payment activation setting only keys that already exist are updated. Trying to switch on a method that is not installed is ignored without a word; the method has to be installed first.
Related Articles
Vielen Dank für Ihre Rückmeldung!
Unser Support-Team ist rund um die Uhr für Sie da, wenn Sie oben nicht fündig werden.