Content Types API
Define custom content schemas to use Fig1 as a headless CMS with AI integration. Create structured content types for any domain—products, recipes, courses, documentation, or any custom schema your application needs.
Why Content Types?
Content types let you:
- Define custom schemas with fields specific to your domain
- Validate content automatically based on field definitions
- Control AI indexing per content type and field
- Organize content with consistent structure across your application
POST /api/sdk/content-types
Create a new content type with custom fields.
Request Body
{
// Required
name: string; // Display name (e.g., "Recipe", "Product Guide")
slug: string; // URL-safe identifier (e.g., "recipe", "product-guide")
// Optional
pluralName?: string; // Plural form (e.g., "Recipes")
description?: string; // Description for editors
icon?: string; // Icon identifier
// Custom fields (see Field Types below)
fields?: FieldDefinition[];
// Built-in fields to include
builtInFields?: {
title?: boolean; // Default: true
slug?: boolean; // Default: true
excerpt?: boolean; // Default: false
featuredImage?: boolean; // Default: false
content?: boolean; // Default: true
author?: boolean; // Default: false
publishedAt?: boolean; // Default: true
};
// AI Configuration
aiConfig?: {
indexed?: boolean; // Include in knowledge base (default: true)
summarize?: boolean; // Auto-generate summaries
extractKeywords?: boolean; // Auto-extract keywords
generateEmbeddings?: boolean; // Create embeddings (default: true)
instructionTemplate?: string; // AI context template
};
accessLevel?: 'public' | 'authenticated' | 'premium';
status?: 'active' | 'draft' | 'archived';
}
Example: Create a Recipe Content Type
curl -X POST https://app.fig1.ai/api/sdk/content-types \
-H "Content-Type: application/json" \
-H "X-Fig1-API-Key: fig1_sdk_abc123" \
-d '{
"name": "Recipe",
"slug": "recipe",
"pluralName": "Recipes",
"description": "Cooking recipes with ingredients and instructions",
"fields": [
{
"name": "prepTime",
"label": "Prep Time (minutes)",
"type": "number",
"validation": { "min": 0 }
},
{
"name": "cookTime",
"label": "Cook Time (minutes)",
"type": "number",
"validation": { "min": 0 }
},
{
"name": "servings",
"label": "Servings",
"type": "number",
"validation": { "min": 1 }
},
{
"name": "difficulty",
"label": "Difficulty",
"type": "select",
"validation": { "options": ["easy", "medium", "hard"] }
},
{
"name": "ingredients",
"label": "Ingredients",
"type": "textarea",
"description": "One ingredient per line"
},
{
"name": "cuisine",
"label": "Cuisine Type",
"type": "multiselect",
"validation": { "options": ["italian", "mexican", "asian", "american", "french"] }
}
],
"builtInFields": {
"title": true,
"content": true,
"featuredImage": true
},
"aiConfig": {
"indexed": true,
"summarize": true,
"instructionTemplate": "This is a recipe. Focus on ingredients, techniques, and dietary information."
}
}'
Response
{
"success": true,
"data": {
"_id": "ct_abc123",
"name": "Recipe",
"slug": "recipe",
"pluralName": "Recipes",
"fields": [...],
"builtInFields": {...},
"aiConfig": {...},
"status": "active",
"createdAt": "2024-01-15T10:00:00Z"
}
}
GET /api/sdk/content-types
List all content types for your site.
Query Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| status | string | Filter by status (default: 'active') |
| includeFields | boolean | Include full field definitions (default: false) |
curl -X GET "https://app.fig1.ai/api/sdk/content-types?includeFields=true" \
-H "X-Fig1-API-Key: fig1_sdk_abc123"
GET /api/sdk/content-types/:slug
Get a specific content type by slug.
curl -X GET "https://app.fig1.ai/api/sdk/content-types/recipe" \
-H "X-Fig1-API-Key: fig1_sdk_abc123"
PUT /api/sdk/content-types/:slug
Update a content type.
curl -X PUT "https://app.fig1.ai/api/sdk/content-types/recipe" \
-H "Content-Type: application/json" \
-H "X-Fig1-API-Key: fig1_sdk_abc123" \
-d '{
"description": "Updated description",
"fields": [...]
}'
DELETE /api/sdk/content-types/:slug
Delete a content type. Content using this type will retain their data but the type definition is removed.
curl -X DELETE "https://app.fig1.ai/api/sdk/content-types/recipe" \
-H "X-Fig1-API-Key: fig1_sdk_abc123"
Field Types
| Type | Description | Validation Options |
|------|-------------|-------------------|
| text | Single line text | min, max, pattern |
| textarea | Multi-line / rich text | min, max |
| number | Numeric value | min, max |
| boolean | True/false toggle | - |
| date | Date picker | - |
| datetime | Date and time | - |
| select | Single selection | options[] |
| multiselect | Multiple selections | options[] |
| media | Image/video reference | allowedTypes[], maxSize |
| file | Document/file reference | allowedTypes[], maxSize |
| reference | Link to another content | referenceTo (content type slug) |
| references | Multiple content links | referenceTo |
| url | URL field | pattern |
| email | Email field | - |
| json | Raw JSON data | - |
| color | Color picker | - |
| location | Lat/lng coordinates | - |
Field Definition
interface FieldDefinition {
name: string; // camelCase identifier
label: string; // Display label
type: FieldType;
description?: string; // Help text
placeholder?: string; // Input placeholder
defaultValue?: any; // Default value
validation?: {
required?: boolean;
min?: number; // Min length or value
max?: number; // Max length or value
pattern?: string; // Regex pattern
options?: string[]; // Select/multiselect options
allowedTypes?: string[]; // MIME types for media/file
maxSize?: number; // Max file size in bytes
referenceTo?: string; // Content type for references
};
// Display options
showInList?: boolean; // Show in content list
searchable?: boolean; // Include in search (default: true)
sortable?: boolean; // Allow sorting
group?: string; // Group name for UI
order?: number; // Display order
hidden?: boolean; // Hide from editors
aiIndexed?: boolean; // Include in AI (default: true)
}
Using Custom Content Types
Creating Content with Custom Fields
When you create content of a custom type, use the customFields object:
curl -X POST https://app.fig1.ai/api/sdk/content \
-H "Content-Type: application/json" \
-H "X-Fig1-API-Key: fig1_sdk_abc123" \
-d '{
"externalId": "pasta-carbonara",
"type": "recipe",
"title": "Classic Pasta Carbonara",
"content": "<p>A traditional Italian pasta dish...</p>",
"customFields": {
"prepTime": 10,
"cookTime": 20,
"servings": 4,
"difficulty": "medium",
"ingredients": "400g spaghetti\n200g guanciale\n4 egg yolks\n100g pecorino romano",
"cuisine": ["italian"]
},
"featuredImage": "https://cdn.example.com/carbonara.jpg"
}'
Querying by Custom Type
# Get all content of a custom type
curl -X GET "https://app.fig1.ai/api/sdk/content?type=recipe" \
-H "X-Fig1-API-Key: fig1_sdk_abc123"
AI Integration
Knowledge Base Indexing
When aiConfig.indexed is true (default), content is automatically added to your knowledge base. The AI can then answer questions about your content.
Instruction Template
Use aiConfig.instructionTemplate to give the AI context about how to handle this content type:
{
"aiConfig": {
"instructionTemplate": "This is a product. Focus on features, pricing, and compatibility when answering questions."
}
}
Per-Field AI Control
Set aiIndexed: false on specific fields to exclude them from AI responses:
{
"name": "internalNotes",
"label": "Internal Notes",
"type": "textarea",
"aiIndexed": false
}
Example: Product Catalog
curl -X POST https://app.fig1.ai/api/sdk/content-types \
-H "Content-Type: application/json" \
-H "X-Fig1-API-Key: fig1_sdk_abc123" \
-d '{
"name": "Product",
"slug": "product",
"fields": [
{ "name": "sku", "label": "SKU", "type": "text", "validation": { "required": true } },
{ "name": "price", "label": "Price", "type": "number", "validation": { "min": 0 } },
{ "name": "salePrice", "label": "Sale Price", "type": "number" },
{ "name": "inStock", "label": "In Stock", "type": "boolean", "defaultValue": true },
{ "name": "category", "label": "Category", "type": "select", "validation": { "options": ["electronics", "clothing", "home"] } },
{ "name": "specifications", "label": "Specifications", "type": "json" },
{ "name": "relatedProducts", "label": "Related", "type": "references", "validation": { "referenceTo": "product" } }
],
"builtInFields": {
"title": true,
"content": true,
"featuredImage": true,
"excerpt": true
}
}'
Example: Documentation
curl -X POST https://app.fig1.ai/api/sdk/content-types \
-H "Content-Type: application/json" \
-H "X-Fig1-API-Key: fig1_sdk_abc123" \
-d '{
"name": "Documentation",
"slug": "doc",
"fields": [
{ "name": "version", "label": "Version", "type": "text" },
{ "name": "category", "label": "Category", "type": "select", "validation": { "options": ["guide", "reference", "tutorial", "faq"] } },
{ "name": "relatedDocs", "label": "Related Docs", "type": "references", "validation": { "referenceTo": "doc" } },
{ "name": "lastReviewed", "label": "Last Reviewed", "type": "date" }
],
"aiConfig": {
"indexed": true,
"instructionTemplate": "This is technical documentation. Provide accurate, detailed answers with code examples when relevant."
}
}'
Best Practices
- Use meaningful slugs - They become part of your API (
type=recipe) - Set field validations - Catch errors early with
required,min,max - Configure AI context - Use
instructionTemplateto improve AI responses - Group related fields - Use the
groupproperty to organize complex types - Index strategically - Set
aiIndexed: falseon fields that shouldn't affect AI responses - Use references - Link related content using
referenceandreferencesfields