Content Models
Content models define the structure of your content. Think of them as schemas or blueprints — each model describes what fields a piece of content has, what types those fields are, and how they relate to other content.
What Is a Content Model?
A content model is a reusable schema that defines the shape of your content entries. For example, a Blog Post model might have fields like title, body, author, publishedAt, and coverImage.
Blog Post
title, body, author, tags, coverImage, publishedAt
Product
name, price, description, images, category, inStock
Author
name, bio, avatar, socialLinks, posts
Creating a Content Model
You can create content models directly from the Contensa.ai dashboard under Content Model.
- 1
Navigate to Content Model
In your project dashboard, click Content Model in the left sidebar.
- 2
Click "New Model"
Give your model a name (e.g.,
Blog Post) and an optional description. The API name is auto-generated (e.g.,blog_post). - 3
Add Fields
Click Add Field to add fields to your model. Choose from field types like Text, Number, Boolean, Date, Media, Reference, and more.
- 4
Configure Field Options
For each field, set options like Required, Unique, default values, and validation rules.
- 5
Save the Model
Click Save. Your model is now available for creating content entries.
AI-Assisted Model Generation
Powered by AI
Contensa.ai can suggest content model structures based on a simple description. Just describe what you want to model and the AI will propose fields and types for you.
To use AI model generation:
- Click New Model in the Content Model section
- Click the ✨ Generate with AI button
- Describe your content type in plain English (e.g., "A blog post with title, body, author, tags, and a featured image")
- Review the suggested fields and types
- Accept, modify, or reject individual suggestions
- Save the model
Fetching Content Models via SDK
You can retrieve your content models programmatically using the Contensa.ai SDK.
import { createClient } from '@mybe/sdk';
const client = createClient({
projectId: 'your-project-id',
apiKey: process.env.CONTENSA_API_KEY,
});
// Get all content models for a project
const models = await client.contentModels.list();
console.log(models);
// [
// { id: 'cm_abc123', name: 'Blog Post', apiName: 'blog_post', fields: [...] },
// { id: 'cm_def456', name: 'Product', apiName: 'product', fields: [...] },
// ]
// Get a specific content model by ID
const blogPostModel = await client.contentModels.get('cm_abc123');
console.log(blogPostModel.fields);
// [
// { name: 'title', type: 'text', required: true },
// { name: 'body', type: 'rich_text', required: false },
// { name: 'author', type: 'reference', referenceModel: 'author' },
// { name: 'coverImage', type: 'media' },
// ]REST API
You can also interact with content models directly via the REST API.
List Content Models
curl https://api.mybe.app/api/v1/projects/{projectId}/content-models \
-H "Authorization: Bearer YOUR_API_KEY"Get a Content Model
curl https://api.mybe.app/api/v1/projects/{projectId}/content-models/{modelId} \
-H "Authorization: Bearer YOUR_API_KEY"Create a Content Model
curl -X POST https://api.mybe.app/api/v1/projects/{projectId}/content-models \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Blog Post",
"apiName": "blog_post",
"description": "A blog post with title, body, and author",
"fields": [
{ "name": "title", "type": "text", "required": true },
{ "name": "body", "type": "rich_text" },
{ "name": "publishedAt", "type": "date" }
]
}'Model Relationships
Content models can reference other models using Reference and References (Many) field types.
Reference (One-to-One)
Links to a single entry of another model.
Blog Post → Author
References Many (One-to-Many)
Links to multiple entries of another model.
Blog Post → Tags[]