Creating Entities
Base44 entities are defined locally in your project and then pushed to the Base44 backend.Critical: File Naming
Entity files MUST use kebab-case naming:{kebab-case-name}.jsonc
| Entity Name | File Name |
|---|---|
Task | task.jsonc |
TeamMember | team-member.jsonc |
ActivityLog | activity-log.jsonc |
TeamMember.jsonc, teamMember.jsonc
RIGHT: team-member.jsonc
Table of Contents
Entity Directory
All entity definitions must be placed in thebase44/entities/ folder in your project root. Each entity is defined in its own .jsonc file.
Example structure:
How to Create an Entity
- Create a new
.jsoncfile in thebase44/entities/directory - Define your entity schema following the structure below
- Push the changes to Base44 using the CLI
Entity Schema Structure
Each entity file follows a JSON Schema-like structure:Common Mistake: Nested Schema Property
WRONG - Do NOT wrap properties in aschema object:
type and properties at the top level:
Supported Field Types
String
Basic text field:date, date-time, time, email, uri, hostname, ipv4, ipv6, uuid, file, regex, richtext
String with Enum
Constrained to specific values:Number
Integer
For whole numbers only:Binary
For file/blob data:Boolean
Array of Strings
Array of Objects
Field Properties
| Property | Description |
|---|---|
type | Data type: string, number, integer, boolean, array, object, binary |
description | Human-readable description of the field |
enum | Array of allowed values (for strings) |
enumNames | Human-readable labels for enum values (same order as enum) |
default | Default value when not provided |
format | Format hint: date, date-time, time, email, uri, hostname, ipv4, ipv6, uuid, file, regex, richtext |
items | Schema for array items |
properties | Nested properties for object types |
$ref | Reference to another schema definition |
minLength | Minimum string length |
maxLength | Maximum string length |
pattern | Regex pattern for string validation |
minimum | Minimum value for numbers |
maximum | Maximum value for numbers |
rls | Field-level security rules (see Field Level Security section) |
Complete Example
Here’s a complete entity definition for a Task:Naming Conventions
- Entity name: Use PascalCase with alphanumeric characters only (e.g.,
Task,TeamMember,ActivityLog)- Must match pattern:
/^[a-zA-Z0-9]+$/ - Valid:
Task,TeamMember,Order123 - Invalid:
Team_Member,Team-Member,Team Member
- Must match pattern:
- File name: Use kebab-case matching the entity (e.g.,
task.jsonc,team-member.jsonc,activity-log.jsonc) - Field names: Use snake_case (e.g.,
board_id,user_email,due_date)
Relationships Between Entities
To create relationships between entities, use ID reference fields:Row Level Security (RLS)
Row Level Security (RLS) controls which records users can access based on their identity and attributes. RLS rules are defined per entity inside therls field of the schema.
Important: If no RLS is defined, all records are accessible to all users.
RLS Operations
RLS supports five operations:| Operation | Description |
|---|---|
create | Control who can add new records |
read | Control who can view records |
update | Control who can modify records |
delete | Control who can remove records |
write | Shorthand for create, update, and delete combined |
Permission Values
Each operation accepts one of the following values:true- Allow all users (including anonymous/unauthenticated)false- Block all users- Condition object - Allow users matching the condition
Template Variables
Use template variables to reference the current user’s attributes:| Template | Description |
|---|---|
{{user.id}} | The user’s ID |
{{user.email}} | The user’s email |
{{user.role}} | The user’s role |
{{user.data.field_name}} | Custom field from the user’s data object |
Built-in Entity Attributes
Every entity record has these built-in attributes available for RLS rules:| Attribute | Description |
|---|---|
id | Unique record identifier |
created_date | Timestamp when record was created |
updated_date | Timestamp when record was last updated |
created_by | Email of the user who created the record |
Rule Types
There are two condition types you can use: 1. Entity-to-user comparison - Compare record fields to the current user’s values:user_condition:
user_conditiononly supports simple equality (e.g.,{ "role": "admin" })- Entity field filtering requires
data.prefix: Use{ "data.fieldname": value }to filter by entity field values - For
data.*field comparisons, you can use operators:$in,$nin,$ne,$all - Logical operators
$or,$and,$norare available for combining conditions
RLS Examples
Owner-only access:Common RLS Patterns
Public create, admin-only management (e.g., contact forms, waitlists):Limitations
- user_condition is equality only:
user_conditiononly supports exact match (e.g.,{ "role": "admin" }) - no operators - No comparison operators on user_condition:
$gt,$lt,$regex,$expr,$whereare NOT supported for user conditions - No deeply nested templates: Templates like
{{user.data.profile.department}}may not work
- Logical operators:
$or,$and,$norfor combining multiple conditions - Field operators (for
data.*fields only):$in,$nin,$ne,$all - Entity field filtering: Use
data.prefix to filter by entity field values (e.g.,{ "data.status": "published" }or{ "data.completed": true })
Complex Access Patterns
For complex access patterns that require multiple conditions (e.g., “owner OR admin”), you have two options:- Use the Base44 Dashboard UI - The dashboard allows adding multiple rules per operation with OR logic
- Use separate entities - Split data into multiple entities with different access rules
- Use backend functions - Implement custom access logic in backend functions
Field Level Security (FLS)
Field Level Security allows you to control access to individual fields within an entity. FLS rules are defined within each field’s schema using therls property.
FLS Operations
FLS supports the same operations as entity-level RLS:| Operation | Description |
|---|---|
create | Control who can set this field when creating records |
read | Control who can view this field |
update | Control who can modify this field |
delete | Control who can clear this field |
write | Shorthand for create, update, and delete combined |
FLS Example
hr role can read or update the salary field. All users with access to the entity can read/update other fields.
FLS Notes
- If no field-level RLS is defined, the field inherits the entity-level RLS rules
- FLS rules follow the same condition format as entity-level RLS
- Use FLS for sensitive fields like salary, SSN, or internal notes
Pushing Entities
Theentities push command will push all entities that exist in the base44/entities folder.

