Website Pages
The seven endpoints for pages, contracts, news, blog posts and references.
Overview
The panel's Pages, Contracts, News, Blog and References tabs are all one content type. All five are managed through these seven endpoints, and the only thing separating them is the type you send.
Content is kept per language: title, address, body and search-engine fields each live separately in every language. The list gives you the current language while the detail gives you all of them, so translation work starts at the detail.
Images are uploaded through their own endpoints and named by kind. Which kinds are valid depends on the page type. The same call can work on one type and be refused on another.
Reference
Listing the Pages
Returns the pages of the content type you pick.
normal, contract, news, articles, references. The plain page by default.curl 'https://panel.example.com/api/v1/admin/website/pages?type=news&limit=25' \
-H "Authorization: Bearer $API_KEY"const url = new URL('https://panel.example.com/api/v1/admin/website/pages');
url.searchParams.set('type', 'news');
const res = await fetch(url, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/website/pages?' . http_build_query(['type' => 'news', 'limit' => 25]));
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Leave the type out and only PLAIN pages come back; news lives at the same endpoint.
$news = Api::Website()->GetPages([], ['type' => 'news'])['data'];Reading One Page
Returns one page with all its languages and images.
normal, contract, news, articles, references.curl 'https://panel.example.com/api/v1/admin/website/pages/5' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.example.com/api/v1/admin/website/pages/${id}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/website/pages/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The list gives ONE language and the detail gives them ALL; translation work starts here.
$page = Api::Website()->GetPage(['id' => $id])['data'];
$en = $page['languages']['en'] ?? null;Creating a Page
Opens a new page and writes its languages.
normal, contract, news, articles, references. It cannot be changed later.curl -X POST 'https://panel.example.com/api/v1/admin/website/pages' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"type":"normal","languages":{"tr":{"title":"Hakkimizda","content":"<p>Merhaba</p>"}}}'const res = await fetch('https://panel.example.com/api/v1/admin/website/pages', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
type: 'normal',
languages: {
en: { title: 'About Us', content: '<p>Hello</p>' },
},
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/website/pages');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'type' => 'normal',
'languages' => ['en' => ['title' => 'About Us', 'content' => '<p>Hello</p>']],
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Leave the address out and it is built from the title; a clash in that language returns 422.
Api::Website()->CreatePage([
'type' => 'news',
'languages' => ['en' => ['title' => 'Maintenance notice']],
]);Updating a Page
Changes the page fields and languages you send.
curl -X PATCH 'https://panel.example.com/api/v1/admin/website/pages/5' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"status":"inactive","languages":{"tr":{"title":"Sirketimiz"}}}'const res = await fetch(`https://panel.example.com/api/v1/admin/website/pages/${id}`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
status: 'inactive',
languages: { en: { title: 'About Our Company' } },
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/website/pages/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'status' => 'inactive',
'languages' => ['en' => ['title' => 'About Our Company']],
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Only the language you send is written and the rest are KEPT; the type field is ignored.
Api::Website()->UpdatePage([
'id' => $id,
'languages' => ['en' => ['title' => 'About Our Company']],
]);Deleting a Page
Removes a page along with all its languages.
curl -X DELETE 'https://panel.example.com/api/v1/admin/website/pages/5' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.example.com/api/v1/admin/website/pages/${id}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/website/pages/' . $id);
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);// To take a page down, switch its STATUS off rather than delete: the address survives.
Api::Website()->UpdatePage(['id' => $id, 'status' => 'inactive']);Uploading a Page Image
Uploads a page image and puts it in place of the one before.
header-background, cover, mockup. The cover suits news, blog posts and references, while the mock-up suits references alone.curl -X PUT 'https://panel.example.com/api/v1/admin/website/pages/5/images/header-background' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"image":"https://ornek.com/afis.jpg"}'const res = await fetch(`https://panel.example.com/api/v1/admin/website/pages/${id}/images/header-background`, {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ image: 'https://example.com/banner.jpg' }),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/website/pages/' . $id . '/images/header-background');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['image' => 'https://example.com/banner.jpg']),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The cover and mock-up kinds also BUILD a thumbnail; the banner kind leaves one file.
Api::Website()->UploadPageImage([
'id' => $id, 'kind' => 'cover', 'image' => $data,
]);Removing a Page Image
Removes a page image along with its thumbnail.
header-background, cover, mockup.curl -X DELETE 'https://panel.example.com/api/v1/admin/website/pages/5/images/header-background' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.example.com/api/v1/admin/website/pages/${id}/images/header-background`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/website/pages/' . $id . '/images/header-background');
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);// To REPLACE an image there is no need to delete first; the upload takes its place.
Api::Website()->DeletePageImage(['id' => $id, 'kind' => 'cover']);Pitfalls
The content type is part of what a record is, and the update ignores it. A record opened as a plain page cannot become a news item. You have to create it again with the right type and remove the old one. Getting the type wrong costs the address and the images as well.
The same address can sit side by side in different languages, yet two pages in one language cannot share it. The clash error names the language it happened in. Leave the address out and it is built from the title, so two news items with similar titles can collide unexpectedly.
The banner suits every type. The cover is taken only on news, blog posts and references, and the mock-up only on references. A kind that does not suit comes back as a 422. This holds at creation too: an invalid kind in the body means the page is never created at all.
The contract acceptance switches work on contracts alone. So do showing a news item in the client panel, and a reference's rank and address. Sent on another type they raise no error and do nothing. When behaviour does not follow, check the record's type first.
On an update the languages you send are written and the ones you leave out are kept. Correcting one language does not mean carrying the others along. This differs from some other write endpoints, where the body counts as the whole definition and whatever is missing gets dropped.
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.