BareCMS provides a RESTful API for content management and public data access. All authenticated endpoints require a JWT token in the Authorization header.
http://localhost:8080Include the JWT token in the Authorization header for all authenticated endpoints:
Authorization: Bearer <your-jwt-token>Check if the API is running and healthy.
Endpoint: GET /api/health
Description: Returns the health status of the API. No authentication required.
Example Request:
curl -X GET http://localhost:8080/api/healthExample Response:
{
"status": "up"
}Retrieve all site content publicly without authentication. This is the primary endpoint for headless usage.
Endpoint: GET /api/:siteSlug/data
Description: Returns all collections and entries for a site using its slug. BareCMS keeps it simple by organizing all content under a data field, where each collection is accessible by its slug containing an array of entries with their field values directly accessible.
Parameters:
siteSlug(path) - The unique slug of the site
Example Request:
curl -X GET http://localhost:8080/api/myblog/dataExample Response:
{
"id": "44394f36-daa3-451c-970f-59238c46ce36",
"name": "myblog",
"slug": "myblog",
"data": {
"articles": [
{
"content": "this is my article post content",
"draft": "false",
"published": "2025-07-21",
"title": "my sample article"
}
],
"products": [
{
"name": "Sample Product",
"price": "29.99",
"description": "A great product for everyone"
}
]
}
}Response Structure:
id- The unique identifier of the sitename- The name of the siteslug- The URL-friendly slug of the sitedata- Object containing all collections, where:- Each key is a collection slug (e.g., "articles", "products")
- Each value is an array of entries for that collection
- Entry objects contain field names as keys with their values directly accessible (no nested
dataobject)
This simple structure makes it easy to consume in frontend applications - you can directly access response.data.articles to get all articles, or response.data.products for products, etc.
Create a new user account.
Endpoint: POST /api/auth/register
Request Body:
{
"email": "user@example.com",
"password": "securepassword",
"username": "myuser"
}Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "user123",
"email": "user@example.com",
"username": "myuser"
},
"message": "User created successfully"
}Authenticate and receive a JWT token.
Endpoint: POST /api/auth/login
Request Body:
{
"email": "user@example.com",
"password": "securepassword"
}Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "user123",
"email": "user@example.com",
"username": "myuser"
}
}Invalidate the current session.
Endpoint: POST /api/auth/logout
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"message": "User logged out successfully"
}Retrieve details of the currently authenticated user. Requires authentication.
Endpoint: GET /api/user
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"id": "user123",
"email": "user@example.com",
"username": "myuser"
}Delete the currently authenticated user. Requires authentication.
Endpoint: DELETE /api/user/:userId
Parameters:
userId(path) - The ID of the user to delete (must match authenticated user)
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"message": "User deleted successfully"
}Get all sites for the authenticated user.
Endpoint: GET /api/sites
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"sites": [
{
"id": "site123",
"userId": "user789",
"name": "My Blog",
"slug": "my-blog"
},
{
"id": "site456",
"userId": "user789",
"name": "My Portfolio",
"slug": "my-portfolio"
}
]
}Create a new site for the authenticated user.
Endpoint: POST /api/sites
Headers:
Authorization: Bearer <your-jwt-token>Request Body:
{
"name": "My New Site",
"userId": "user789"
}Response:
{
"message": "Site created!"
}Retrieve details of a specific site by its ID.
Endpoint: GET /api/sites/:id
Parameters:
id(path) - The ID of the site to retrieve
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"site": {
"id": "site123",
"userId": "user789",
"name": "My Blog",
"slug": "my-blog"
}
}Retrieve details of a specific site by its ID, including all its collections.
Endpoint: GET /api/sites/:id/collections
Parameters:
id(path) - The ID of the site
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"site": {
"id": "site123",
"userId": "user789",
"name": "My Blog",
"slug": "my-blog"
},
"collections": [
{
"id": "col123",
"siteId": "site123",
"name": "Posts",
"slug": "posts",
"fields": [
{ "name": "title", "type": "string" },
{ "name": "content", "type": "string" }
],
"entries": []
}
]
}Delete a site and all its associated collections and entries. This action is irreversible.
Endpoint: DELETE /api/sites/:id
Parameters:
id(path) - The ID of the site to delete
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"message": "Site deleted!"
}Create a new collection.
Endpoint: POST /api/collections
Headers:
Authorization: Bearer <your-jwt-token>Request Body:
{
"siteId": "site123",
"name": "Products",
"fields": [
{ "name": "title", "type": "string" },
{ "name": "price", "type": "number" }
]
}Supported Field Types:
| Type | Description | Input |
|---|---|---|
string |
Single line text | Text input |
text |
Multi-line text | Textarea |
number |
Numeric values | Number input |
boolean |
True/false values | Select (Yes/No) |
date |
Date picker | Date input |
image |
Image URL | URL input |
url |
Website links | URL input |
Response:
{
"message": "Collection created!"
}Retrieve details of a specific collection.
Endpoint: GET /api/collections/:id
Parameters:
id(path) - The ID of the collection
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"id": "col123",
"siteId": "site123",
"name": "Posts",
"slug": "posts",
"fields": [
{ "name": "title", "type": "string" },
{ "name": "content", "type": "string" }
],
"entries": [
{
"id": "entry1",
"collection_id": "col123",
"data": {
"title": "Sample Post",
"content": "Sample content"
}
}
]
}Get all collections for a specific site.
Endpoint: GET /api/collections/:siteId
Parameters:
siteId(path) - The ID of the site
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"collections": [
{
"id": "col123",
"siteId": "site123",
"name": "Posts",
"slug": "posts",
"fields": [{ "name": "title", "type": "string" }],
"entries": []
}
]
}Get all entries for a specific collection.
Endpoint: GET /api/collections/:id/entries
Parameters:
id(path) - The ID of the collection
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"id": "col123",
"siteId": "site123",
"name": "Posts",
"slug": "posts",
"fields": [{ "name": "title", "type": "string" }],
"entries": [
{
"id": "entry1",
"collection_id": "col123",
"data": {
"title": "Sample Post"
}
}
]
}Delete a collection and all its entries.
Endpoint: DELETE /api/collections/:id
Parameters:
id(path) - The ID of the collection
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"message": "Collection deleted!"
}Create a new entry.
Endpoint: POST /api/entries
Headers:
Authorization: Bearer <your-jwt-token>Request Body:
{
"collectionId": "col123",
"data": {
"title": {
"value": "New Blog Post",
"type": "string"
},
"content": {
"value": "Content of the blog post...",
"type": "string"
},
"published": {
"value": "true",
"type": "boolean"
}
}
}Response:
{
"message": "Collection created!"
}Retrieve details of a specific entry.
Endpoint: GET /api/entries/:id
Parameters:
id(path) - The ID of the entry
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"id": "entry1",
"collection_id": "col123",
"data": {
"title": "Blog Post Title",
"content": "Blog post content...",
"slug": "blog-post-title"
}
}Delete an entry.
Endpoint: DELETE /api/entries/:id
Parameters:
id(path) - The ID of the entry
Headers:
Authorization: Bearer <your-jwt-token>Response:
{
"message": "Entry deleted!"
}All endpoints may return the following error responses:
{
"error": "Invalid request data"
}{
"error": "Authentication required"
}{
"error": "Access denied"
}{
"error": "Resource not found"
}{
"error": "Internal server error"
}-
Register and Login
# Register curl -X POST http://localhost:8080/api/auth/register \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com", "password": "password123", "username": "myuser"}' # Login curl -X POST http://localhost:8080/api/auth/login \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com", "password": "password123"}'
-
Create Site Structure
# Create site curl -X POST http://localhost:8080/api/sites \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name": "My Blog", "userId": "user123"}' # Create collection curl -X POST http://localhost:8080/api/collections \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"siteId": "site123", "name": "Posts", "fields": [{"name":"title","type":"string"},{"name":"content","type":"string"}]}' # Create entry curl -X POST http://localhost:8080/api/entries \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"collectionId": "col123", "data": {"title": {"value": "Hello World", "type": "string"}, "content": {"value": "My first post!", "type": "text"}}}'
-
Access Data Publicly
# Get all site data (no authentication needed) curl -X GET http://localhost:8080/api/my-blog/data
This workflow demonstrates the core concept: use the authenticated API to manage content, then access it publicly via the site slug for your frontend applications.