Build
createEntityDef() — Schema Manager
Create a new data table and its initial properties.
Contract source
@gsb-core/mcp-docs:getDefDocs("createEntityDef") Creates a new entity definition (data table) with the specified schema.
Request Format
createEntityDef(
entityDef: GsbEntityDef, // Entity definition object
token: string, // Authentication token
tenantCode?: string // Optional tenant code
): Promise<{
success: boolean,
data?: string, // ID of the created entity definition
error?: string
}>
GsbEntityDef Structure
interface GsbEntityDef {
id?: string; // Unique identifier (auto-generated if not provided)
name?: string; // Entity name (must be unique)
title?: string; // Display title
description?: string; // Description
dbTableName?: string; // Database table name
publicAccess?: boolean; // Whether entity is publicly accessible
activityLogLevel?: ActivityLogLevel; // Level of activity logging
properties?: GsbProperty[]; // Array of properties (columns)
isActive?: boolean; // Whether entity is active
isDeleted?: boolean; // Whether entity is deleted
permissions?: GsbPermission[]; // Entity permissions
workflowTriggers?: GsbWorkflowTrigger[]; // Associated workflow triggers
}
Default Properties
When creating a new entity definition, these properties are automatically added:
id- Primary key (UUID), Requiredtitle- Display titlecreatedBy- User who created the recordlastUpdatedBy- User who last updated the recordcreateDate- Creation timestamplastUpdateDate- Last update timestamp
Response Format
{
"success": boolean,
"data": "string", // ID of the created entity definition
"error": "string" // Present only if success is false
}
Example
const entityDef = {
name: "Customer",
title: "Customer Information",
description: "Stores customer data",
properties: [
{
name: "email",
title: "Email Address",
description: "Customer email",
definition_id: "df7ce94b-d59c-4b67-8519-aa4c98ab477c", // Email type
isRequired: true,
isUnique: true,
isSearchable: true,
orderNumber: 10
},
{
name: "phoneNumber",
title: "Phone Number",
description: "Customer phone number",
definition_id: "c6c34bf3-f51b-4e69-a689-b09847be74b9", // String type
isSearchable: true,
orderNumber: 20
}
]
};
const result = await createEntityDef(entityDef, "your-auth-token");