Schema Management
Content schemas define the structure of your content. This document outlines the API endpoints for managing schemas in the system.
Authentication
All schema management endpoints require Super Admin role access.
List Schemas
Retrieve a list of all content schemas.
Get all schemas. Requires Super Admin role.
GET
Base URL
/admin/schema
Headers1
Get Schema by ID
Retrieve a specific schema by its ID.
Get a specific schema. Requires Super Admin role.
GET
Base URL
/admin/schema/:id
Headers1
Create Schema
Create a new content schema.
Create a new schema. Requires Super Admin role.
POST
Base URL
/admin/schema
Headers1
Request Body
Request Body Parameters
name
(required): Schema name, must be uniquetype
(required): Schema type, eitherlist
orsingle
list
: Multiple entries allowed (e.g., Blog Posts)single
: Only one entry allowed (e.g., Homepage)
slug
(required): URL-friendly identifier, must be:- Lowercase
- No spaces
- No underscores
- Unique across schemas
fields
(required): Array of field definitions
Field Definition Structure
Each field in the fields
array must contain:
name
: Field identifiertype
: One of the following field types:text
: Short texttextarea
: Multi-line textrichText
: Rich text editornumber
: Numeric valueboolean
: True/falsedate
: Date pickerdatetime
: Date and time pickermedia
: Media file selectorreference
: Reference to other content
required
: Boolean indicating if the field is mandatoryoptions
: Object containing field-specific options:- Text fields:
minLength
: Minimum character lengthmaxLength
: Maximum character length
- Number fields:
min
: Minimum valuemax
: Maximum value
- Reference fields:
schemaId
: ID of the referenced schemamultiple
: Allow multiple references
- Text fields:
Update Schema
Update an existing schema. Note that some changes might affect existing content.
Update an existing schema. Requires Super Admin role.
PUT
Base URL
/admin/schema/:id
Headers1
Request Body
Update Restrictions
- Cannot change schema type if content exists
- Field updates must maintain data integrity
- Slug must remain unique
- Name must remain unique
Delete Schema
Delete a schema and optionally its content.
Delete a schema. Requires Super Admin role.
DELETE
Base URL
/admin/schema/:id
Headers1
Request Body
Deletion Restrictions
- Cannot delete schemas with existing content unless forced
- System schemas cannot be deleted
- Requires Super Admin role
Error Responses
The API may return the following error responses:
400 Bad Request
- Missing required fields
- Invalid schema type
- Invalid slug format
- Duplicate slug or name
- Invalid field configuration
{
"error": "Error message describing the issue"
}
401 Unauthorized
- Invalid or missing authentication token
{
"error": "Invalid token"
}
403 Forbidden
- Insufficient permissions (requires Super Admin)
{
"error": "Access denied"
}
404 Not Found
- Schema not found
{
"error": "Schema not found"
}
500 Internal Server Error
- Server-side errors
{
"error": "Internal server error"
}
Best Practices
- Plan your schema structure carefully before creation
- Use descriptive names for fields
- Consider content relationships when designing schemas
- Keep field names consistent across schemas
- Use appropriate field types for better data validation
- Document schema changes for content editors
Last updated on