Learn how to retrieve layouts information using the Get Layouts by IDs endpoint
The Get Layouts by IDs endpoint allows you to fetch complete information about a several layouts configuration at once from your JustCMS project. This endpoint is essential for retrieving layouts data that can be used to structure and display content across your application.
The base URL structure follows this pattern:
GET https://api.justcms.co/public/{projectId}/layouts/{id1};{id2};{id3}
Where {projectId} represents your unique project identifier and {idN} is the specific layout ID you want to retrieve.
To authenticate your requests, you must include the following header:
Authorization: Bearer YOUR_TOKEN
Without proper authentication, the API will return a 401 Unauthorized response.
To successfully retrieve layouts using the Get Layouts by IDs endpoint, you'll need to include specific parameters and headers in your request. Here's what you need:
Your unique project identifier that must be included in the base URL path
The unique identifier of the specific layouts you want to retrieve separated by ";"
The complete URL structure follows this pattern:
GET https://api.justcms.co/public/{projectId}/layouts/{id1};{id2};{idN}
Authentication is required to access the API. Include the following header with your request:
Bearer YOUR_TOKEN - Include your API access token
Important Notes:
Replace {projectId} with your actual project identifier
Replace {id1}...{idN} with the specific layout identifiers you want to retrieve
Ensure your authorization token is valid and not expired
The Authorization header must use the Bearer authentication scheme
When retrieving a layout via the API, the response follows a consistent JSON structure that includes essential information about the layout and its items. The response contains metadata about the layout as well as an array of layout items with their specific properties.
The request was successful and returns the layouts data as array
The request lacks valid authentication credentials
The specified layout or project ID could not be found
A successful response includes the array of objects with the following main fields:
id: The unique identifier of the layout
name: The display name of the layout
items: An array of layout items containing the actual content
The display name for the content item
Additional context about the content item
Unique identifier for the specific content item
Content type (e.g., text, html, flag)
The actual content or data for the item
[
{
"id": "footer",
"name": "Footer",
"items": [
{
"label": "Description",
"description": "",
"uid": "description",
"type": "html",
"value": "<p><strong>AI-driven headless CMS</strong> that streamlines content creation and management, offering fast, scalable, and secure solutions for developers and content creators.</p>"
},
{
"label": "Copyrights",
"description": "",
"uid": "copirights",
"type": "text",
"value": "Copyright © 2025 JustCMS. All rights reserved."
},
{
"label": "Privacy Link Copy",
"description": "",
"uid": "Privacy-link-copy",
"type": "text",
"value": "Privacy Policy"
},
{
"label": "Terms Link Copy",
"description": "",
"uid": "terms-link-copy",
"type": "text",
"value": "Terms of Service"
}
]
},
{
"id": "header",
"name": "Header",
"items": [
{
"label": "Logo Alt",
"description": "",
"uid": "logoAlt",
"type": "text",
"value": "JustCMS Logo"
},
{
"label": "Show Promo Banner",
"description": "",
"uid": "showPromoBanner",
"type": "boolean",
"value": true
}
]
}
]
Each item in the layout can have different types, such as 'text', 'html' or "flag", which determine how the content should be rendered. The 'value' field contains the actual value and its format depends on the specified type.
Below is a complete example demonstrating how to make a request to the Get Layouts by IDs endpoint and handle the response. We'll show both the request process and how to parse the returned data.
// Example using JavaScript/Node.js with fetch
async function getLayouts(projectId, layoutIds, token) {
const url = `https://api.justcms.co/public/${projectId}/layouts/${layoutIds.join(';')}`;
try {
const response = await fetch(url, {
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const layoutData = await response.json();
return layoutData;
} catch (error) {
console.error('Error fetching layout:', error);
throw error;
}
}
Once you receive the layout data, you can process it according to your application's needs.